Choosing Julia, Matlab, Python or R in economics?
cepr.org
cepr.org
[1] https://www.gnu.org/software/emacs/manual/html_mono/calc.htm...
54 USD - 25 SAR, and Frink will spit out 47.33 dollar (currency)
I use the graphic example program and customize it to print out graph paper. You can set the graphics to print at true measurement!Animations, input forms, graphics, all with mixed-unit calcs. You program in Frink's lang, which is a simplified Java. Reminds me of Groovy. I just like the fact it is a desktop IDE with choices on programming or simply converting units.
The examples you can download off the main page are amazing and fun. The documentation is great too. I have been using Frink for a long time now, so I just made a donation to Alan who created and maintains the project. It has saved many a headache and error with carrying different units, and I've had fun with it. It's like a cool little programming environment.
EDIT: It also runs on Android, and there is a GCJ compiled exe version for Windows (experimental).
I'd add that for very many people, computation speed is second order. I work with datasets of about half a million rows, which is large for economics, and I'm basically OK using R on a ten-year-old laptop. Sometimes a little pipeline management is necessary.
Actually, pipeline software would be a good addition to the article. In my experience, R's "drake" is pretty overengineeered, and I suspect its successor "targets" is not much better. It would be interesting to compare the solutions in other languages.
Another useful addition would be the ease of expressing simple data management tasks. So far my impression is that R with the tidyverse excels. There's not much simpler than
dataset |>
filter(row == cond) |>
mutate(a = b + c) |>
group_by(group_variable) |>
summarize(x = per_group_computation(a,b,c))
where the code hews very closely to the problem domain.For one-off code written by an expert, this doesn't matter much, and criteria such as those mentioned in the article might be paramount. In many cases, however, code starts off as a modification of something that already exists, and forms a seed from which other new things might spring. If everyone chooses their own language, collaboration can be hard.
In an academic environment, cost is a serious factor that argues against Matlab. Even in a place with a site license, somebody must be paying, and many groups have grown weary of the expense, particularly because it locks their students into a language that might not be available to them wherever they go after graduation.
A few years later I wrote an open source economics library in R: https://github.com/stevecondylios/priceR#pricer- It converts between nominal and real prices, converts between 171 currencies, and has a few regex's for pulling numeric data out of text (e.g. salaries out of job descriptions).
Some specific observations regarding the article:
- Comparing computation speed seems a bizarre metric to care about. 6x faster matters on things that take minutes, hours or days, but less so for operations that already run in under 1000ms. Developer experience is usually more important IME.
- The article mentions R library support is superior (which may or may not be true), but it would nice to see the most useful highly-regarded libraries from each language reviewed, or at least mentioned.
- The statement "(Julia) does not have any historical baggage" seems odd since a language doesn't need to be old before people find problems with it. Example from recent HN post: https://yuri.is/not-julia/
Btw thanks for a very interesting take on a generally neglected topic (language choice for economists). I hope you do more and deeper discussion on this as I think a lot of economists never make it to open source and get stuck using whatever they learned in university (eviews or spss).
I found that R has the best libraries. It's the easiest language to use but it's also easy to write spaghetti code. Static analysis is a joke.
Writing code in Julia is slower/more tiresome. I have to annotate all structs and function input types. In languages like typescript, I would see this as an investment because tsserver will later use that information for linting and autocompletion, so the net return is clearly positive. In Julia however static analysis is very primitive and limited, you feel like having to write code twice: once for annotations and then again for the implementation, with very limited cross-checking between the two. When writing functions, output types are so hard to annotate that I just skip them completely and only annotate input types. Type errors are usually caught at runtime. The runtime messages are helpful though.
Unfortunately I couldn't even find a reputable Poisson-binomial package for Python so I stopped here. From my limited experience with python in other projects, I think that static analysis using pyright is mature and worth using (nets a positive return, although inferior to tsserver). This experience varies greatly between frameworks and packages, it's only worth to annotate the code if the underlying libraries also provide type hints.
And I definitely don't get what you mean by having to write the code twice: To me the beauty of Julia is exactly that you write it once, then optimise it for speed (or robustness, with gradual typing and all) instead of rewriting it in another language.
Unfortunately, I also don't agree that the runtime error messages are good in Julia. I find them pretty bad :( even if stack traces are good. And also, the lack of automatic type checking in the editor is also a problem for productivity.
That has been my experience as well: among optionally-typed languages, Julia is pretty good at inference, and at telling you why it gave up. This is critical when dealing with a language with a Sufficiently Smart Compiler that takes some convincing to do what you want.
[1]https://docs.scipy.org/doc/scipy/reference/generated/scipy.s...
[2]https://docs.scipy.org/doc/scipy/reference/generated/scipy.s...
[1] https://en.wikipedia.org/wiki/Poisson_binomial_distribution
The attempt to shoehorn in the Python version of the R Fourier variation was closed 18 days ago with a "doesn't quite fit, try again later"
[1]https://en.wikipedia.org/wiki/Poisson_binomial_distribution
[2]https://cran.r-project.org/web/packages/PoissonBinomial/inde...
Looking at some child comments it looks like there have been attempts to get it added to scipy since 2016.
Can you elaborate on that? Argument types in function definitions do not help the compiler infer types - you can leave them completely untyped. It's really only required in struct fields, so that the compiler can know the size of your struct and doesn't have to box everything.
(I don't recommend it though, having some idea of type safety is in general a good idea)
julia> struct Foo
a
end
julia> Foo(17)
Foo(17)
julia> Foo("bar")
Foo("bar")
People should absolutely criticise Julia for its faults, but I would expect them to at least learn and understand the very basics of the language before doing so.Structs and functions do not need to have type annotations. They are completely optional and learning when to annotate is one of the first learning challenges for newcomers to the language.
There are code generation advantages to type annotations for structs, but they are not required. As for functions, this will only ever be the case if type inference fails, which should be so rare that you hardly even need to consider it.
Regardless, that's orthogonal to being type safe.
Actually the only non perfect side of matlab is pricing. It also has the best help ever devised in history of cs. U can build a math PhD. Curriculum from matlab help pages.
- zoom and pan
- Data cursor/data tip.
- Export data under cursor to a workspace variable
- Interactive editing of the plot, with code export.
Zoom/pan and data tips should be table stakes for a plotting package. A package that doesn't support that is not fit for use. IMO.
R has more niche libraries (macroeconomics, climate economics, finance and game theory etc) and more open paper codes, Python is easier for me.
My supervisor uses Matlab though.
Haven't heard of anyone using Julia in Economics yet.
FWIW, it wasn't a recent addition. It was added in 2015 so it's quite matured. https://github.com/QuantEcon/QuantEcon.jl/graphs/contributor...
In the implementation of the julia code there is a slight performance bug though (not sure if the authors submitted the article - the username certainly suggests it):
function likelihood(o, a, b, h, y2, N)
local lik = 0.0
for i in 2:N
@inbounds h = o+a*y2[i-1]+b*h
lik += log(h)+y2[i]/h
end
return(lik)
end
Only one use of y2 is marked @inbounds - in this case, either the second use too or the whole loop could be marked @inbounds (or the loop could be modified to run for all of eachindex(y2), with the first index being explicitly skipped).Then process data frames in R or python. R for non-neural models and Python for GPU stuff. Visualizations also R.
Octave is wonderful, and getting better every year.