# Choosing a numerical programming language for economic research: Julia,

**URL:** <https://discourse.julialang.org/t/choosing-a-numerical-programming-language-for-economic-research-julia/85697>\
**Category:** Community\
**Tags:** blog, blog-post\
**Created:** [August 13, 2022, 7:37am UTC](https://discourse.julialang.org/t/choosing-a-numerical-programming-language-for-economic-research-julia/85697 "2022-08-13T07:37:53Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [August 14, 2022, 10:51am UTC](https://discourse.julialang.org/t/choosing-a-numerical-programming-language-for-economic-research-julia/85697/44 "2022-08-14T10:51:51Z")

</div>

Note however that the Distributions docs list things you can do with the package on the landing page, where the first point listed is “sampling from a distribution”.

Then there’s the “getting started” section next, which shows (using the example of a standard normal distribution) how to create a distribution object, get its mean, draw random numbers from it (!) and calculate quantiles.

[https://juliastats.org/Distributions.jl/stable/starting/](https://juliastats.org/Distributions.jl/stable/starting/)

So I would argue that anyone who manages to work out that at distribution is implemented in the Distributions package should be able to work out in under 5 minutes how to achieve the things that most users are likely looking for in the package.

Of course any package documentation is incomplete on the sense that it doesn’t necessarily show every specific use case of every user on every page of the documentation, but conciseness is also a value in and of itself. In your case it seems your main issue was that you were expecting the docstring of every distribution to include examples of how to apply methods to that distribution. I’m ambivalent on this (personally I think taking 2 minutes to look at the getting started section to understand the package I’m using isn’t unreasonable, on the other hand adding a simple rand example to the docstring isn’t exactly overkill) but you could just open a PR to add those two lines and see what the package maintainers say.

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [August 14, 2022, 11:25am UTC](https://discourse.julialang.org/t/choosing-a-numerical-programming-language-for-economic-research-julia/85697/45 "2022-08-14T11:25:49Z")

</div>

> [@JackStrauss](#):
>
> After spending some time, one figures out that one needs to use both the distribution page and the random number page together. Google only takes you to one. So you end up with 1/2 of the solution.

Well, on the same page you have: [Sampling (Random number generation)](https://juliastats.org/Distributions.jl/v0.14/univariate.html#Sampling-(Random-number-generation)-1), describing how to use `rand` and distributions together.

You need to scroll a bit, but it’s on the same page.

---

<div class="post-metadata">

**Author:** ![johnmyleswhite](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnmyleswhite/32/31_2.png) [@johnmyleswhite](https://discourse.julialang.org/u/johnmyleswhite)\
**Post date:** [August 14, 2022, 11:28am UTC](https://discourse.julialang.org/t/choosing-a-numerical-programming-language-for-economic-research-julia/85697/46 "2022-08-14T11:28:05Z")

</div>

Since documentation is on people’s minds again, I will note that people who are unhappy with documentation can actually step up to provide a lot of value. For example, if you want to see workflows documented, a good thing to do would be to write up 10-100 specific problems you’d like to see solved and then ask others to produce the solutions. This forum is very reliable at producing solutions, but I seldom see people systematically drive collating questions and solutions into usable documentation.

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [August 14, 2022, 11:48am UTC](https://discourse.julialang.org/t/choosing-a-numerical-programming-language-for-economic-research-julia/85697/47 "2022-08-14T11:48:34Z")

</div>

> [@nilshg](#):
>
> I’m ambivalent on this (personally I think taking 2 minutes to look at the getting started section to understand the package I’m using isn’t unreasonable, on the other hand adding a simple rand example to the docstring isn’t exactly overkill)

Indeed, the getting started section is very good. The issue (in this case then) is just that we live in a world that google drives what people reads first. It is not obvious to someone that reaches that page that there is a much better place to read the documentation. IMHO, redundancy in explaining things is hardly ever bad.

---

<div class="post-metadata">

**Author:** ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Post date:** [August 14, 2022, 12:08pm UTC](https://discourse.julialang.org/t/choosing-a-numerical-programming-language-for-economic-research-julia/85697/48 "2022-08-14T12:08:53Z")

</div>

To add to this, the [getting started](https://juliastats.org/Distributions.jl/v0.14/starting.html) page gets to this point immediately.

---

<div class="post-metadata">

**Author:** ![Albert\_Zevelev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albert_zevelev/32/11844_2.png) [@Albert\_Zevelev](https://discourse.julialang.org/u/Albert_Zevelev)\
**Post date:** [August 14, 2022, 2:10pm UTC](https://discourse.julialang.org/t/choosing-a-numerical-programming-language-for-economic-research-julia/85697/49 "2022-08-14T14:10:57Z")

</div>

Is there a “best practices for documentation”?

Sometimes package developers forget to do more hand-holding.  
Eg I added some details to the Julia VSCode [readme](https://github.com/julia-vscode/julia-vscode).  
1 install Julia (link)  
2 install VSCode (link)  
3 open VSCode…  
Handholding makes a difference.

---

<div class="post-metadata">

**Author:** ![mcreel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcreel/32/30088_2.png) [@mcreel](https://discourse.julialang.org/u/mcreel)\
**Post date:** [August 14, 2022, 2:25pm UTC](https://discourse.julialang.org/t/choosing-a-numerical-programming-language-for-economic-research-julia/85697/50 "2022-08-14T14:25:44Z")

</div>

Would it not be good to add a brief sentence to [julia/index.md at master · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/blob/master/stdlib/Random/docs/src/index.md) mentioning that random numbers from distributions other than those mentioned (e.g., uniform, normal, etc.) can be obtained by using the Distributions package? I would be happy to make a PR, but I’m just not certain what is the policy about mentioning packages in the main Julia documentation.

EDIT: I went ahead and made a PR: [Random numbers from other distributions by mcreel · Pull Request #46342 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/pull/46342)

---

<div class="post-metadata">

**Author:** ![jlperla](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlperla/32/34332_2.png) [@jlperla](https://discourse.julialang.org/u/jlperla)\
**Post date:** [August 14, 2022, 4:46pm UTC](https://discourse.julialang.org/t/choosing-a-numerical-programming-language-for-economic-research-julia/85697/51 "2022-08-14T16:46:33Z")

</div>

> [@y.lin](#):
>
> That said, we have a project where estimation takes hours on a multi-core machine and R is as fast as Julia and slightly slower than c

For sure. There are many tasks where R is superior and I wouldn’t even consider julia (though might choose Stata or python). My point is that we should all be careful making unconditional statements ranking languages. They should always be conditional on a particular class of tasks, as you do in your conclusions talking about Julia but not R.

There are **many** tasks where Julia (or C++, Python, Rust, R, Matlab, Fortran, …) doesn’t compare favorably to the others. When people trying to choose a language read about how painful Julia is for a particular task and how great R is, it can conflate a whole bunch of different use-cases. Similarly, if people hear how awesome Julia is and try it just for vanilla datacleaning and linear regressions they are going to come out of it with a pretty low opinion of the language and ecosystem.

Unconditional statements ranking languages are more a statement on the frequency of author’s fields most common tasks (i.e., some weighting of task-conditional rankings).

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [August 14, 2022, 5:14pm UTC](https://discourse.julialang.org/t/choosing-a-numerical-programming-language-for-economic-research-julia/85697/52 "2022-08-14T17:14:04Z")

</div>

Well, I would say that Julia superior to all the other languages you mentioned when it comes to the effort that is needed to write a new, performant package.

Therefore I think that the package ecosystem of Julia will evolve much faster that the ecosystem of any other language…

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [August 14, 2022, 5:32pm UTC](https://discourse.julialang.org/t/choosing-a-numerical-programming-language-for-economic-research-julia/85697/53 "2022-08-14T17:32:03Z")

</div>

> [@ufechner7](#):
>
> Did you create an issue in [Issues · JuliaStats/Distributions.jl · GitHub](https://github.com/JuliaStats/Distributions.jl/issues)

My gsoc student had this problem a couple of months ago and I encouraged them to open an issue:

> <https://github.com/JuliaStats/Distributions.jl/issues/1564>
>
> https://github.com/JuliaStats/Distributions.jl/blob/f889f9e56b0243d770c195b3eee8…baef4880bd2e/src/univariate/discrete/poisson.jl#L1-L22
> Hi, I think the docs should be more clear on the Poisson Object that is generated when Poisson ($\\lambda$) is executed. In Python we use numpy.random.poisson and give it an argument to generate an iterable over the Poisson Distribution, but here the function just takes one argument and the returned Poisson object has only one field ( $\\lambda$ itself). I later found out that the object can be used as an argument for rand to generate the iterable. A newcomer might get stuck as there is no help regarding the nature of the Poisson Object in Docs. 
> I think a line like this in the docs might work:
> \`The Poisson Object is of type UnivariateDistribution which can be passed to the rand() function as an argument along with an integer N, to generate an iterable of size N.\`
> I will make a pull request if the issue is considerable.

which has been already fixed.

> [@ufechner7](#):
>
> and in [Issues · JuliaRandom/RandomNumbers.jl · GitHub](https://github.com/JuliaRandom/RandomNumbers.jl/issues)

I’m missing how this package is related to anything.

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [August 14, 2022, 5:49pm UTC](https://discourse.julialang.org/t/choosing-a-numerical-programming-language-for-economic-research-julia/85697/54 "2022-08-14T17:49:44Z")

</div>

> [@jlperla](#):
>
> if people hear how awesome Julia is and try it just for vanilla datacleaning and linear regressions they are going to come out of it with a pretty low opinion of the language and ecosystem.

Linear regression is child’s play in Julia, no? ‘Data cleaning’ otoh is unfamiliar territory for me. What sort of tools appear to be missing?

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [August 14, 2022, 6:30pm UTC](https://discourse.julialang.org/t/choosing-a-numerical-programming-language-for-economic-research-julia/85697/55 "2022-08-14T18:30:17Z")

</div>

> [@giordano](#):
>
> I’m missing how this package is related to anything.

Or do you miss documentation at [Random Numbers · The Julia Language](https://docs.julialang.org/en/v1/stdlib/Random/#Base.rand) ?

Then you have to file an issue at [Issues · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues) …

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [August 14, 2022, 6:58pm UTC](https://discourse.julialang.org/t/choosing-a-numerical-programming-language-for-economic-research-julia/85697/56 "2022-08-14T18:58:09Z")

</div>

> [@ufechner7](#):
>
> Or do you miss documentation at [Random Numbers · The Julia Language](https://docs.julialang.org/en/v1/stdlib/Random/#Base.rand) ?

I don’t miss that. My point is that package you mentioned isn’t relevant at all.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [August 14, 2022, 7:01pm UTC](https://discourse.julialang.org/t/choosing-a-numerical-programming-language-for-economic-research-julia/85697/57 "2022-08-14T19:01:21Z")

</div>

> [@giordano](#):
>
> My point is that package you mentioned isn’t relevant at all.

I thought you were missing a reference to Distributions in the documentation of a random numbers package…

---

<div class="post-metadata">

**Author:** ![strickek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/strickek/32/14885_2.png) [@strickek](https://discourse.julialang.org/u/strickek)\
**Post date:** [August 14, 2022, 7:29pm UTC](https://discourse.julialang.org/t/choosing-a-numerical-programming-language-for-economic-research-julia/85697/58 "2022-08-14T19:29:39Z")

</div>

An undisclosed benefit of Julia is that most of Julia’s functionality is written in Julia. Anyone who works with the Julia language can also contribute to its further development. This should bring even more dynamism and quality to the libraries in the future.

---

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [August 15, 2022, 1:28am UTC](https://discourse.julialang.org/t/choosing-a-numerical-programming-language-for-economic-research-julia/85697/59 "2022-08-15T01:28:19Z")

</div>

> [@jlperla](#):
>
> Similarly, if people hear how awesome Julia is and try it just for vanilla datacleaning and linear regressions they are going to come out of it with a pretty low opinion of the language and ecosystem.

I don’t even remotely think this is true. CSV, DataFrames and DataFrameMeta, and either GLM or Turing are basically far superior to anything in any of the more common languages. And I spent 20 yrs doing that stuff in R.

The difference is that I have computer science background and a lot of people who do that sort of stuff don’t. A lot of people have learned some incantations but not really fundamentals. Those people will struggle no matter what they do when they get outside their incantation scope.

---

<div class="post-metadata">

**Author:** ![Albert\_Zevelev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albert_zevelev/32/11844_2.png) [@Albert\_Zevelev](https://discourse.julialang.org/u/Albert_Zevelev)\
**Post date:** [August 15, 2022, 3:03am UTC](https://discourse.julialang.org/t/choosing-a-numerical-programming-language-for-economic-research-julia/85697/60 "2022-08-15T03:03:52Z")

</div>

It depends very much on what exactly you were doing before Julia.

I do most of my data work in STATA.

Some data cleaning tasks (generating variables) are much easier in STATA.  
Some tasks are much easier in Dataframes.jl.

Some econometrics tasks are much easier in FixedEffectsModels.jl, some in STATA.

PS: ALL of the things that are easier (for me) in STATA can be eventually implemented in Julia.

---

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [August 15, 2022, 3:05am UTC](https://discourse.julialang.org/t/choosing-a-numerical-programming-language-for-economic-research-julia/85697/61 "2022-08-15T03:05:52Z")

</div>

Can you give an example of something that is very easy in STATA that you struggle with in Julia?

---

<div class="post-metadata">

**Author:** ![Albert\_Zevelev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albert_zevelev/32/11844_2.png) [@Albert\_Zevelev](https://discourse.julialang.org/u/Albert_Zevelev)\
**Post date:** [August 15, 2022, 3:15am UTC](https://discourse.julialang.org/t/choosing-a-numerical-programming-language-for-economic-research-julia/85697/62 "2022-08-15T03:15:57Z")

</div>

At risk of digressing:

> <https://github.com/kleinschmidt/RegressionFormulae.jl/issues/1>
>
> Hi @kleinschmidt,
> I think the Julia ecosystem would benefit from something like… this! 
> If we wanna do serious stats it should be easy to automatically generate all interactions (up order n) etc. 
> 
> Some things I find particularly useful in my other stats packages outside Julia: 
> 1. "i.x1" makes x1 into a \[factor variable\](https://www.stata.com/features/overview/factor-variables/) in a formula
> Suppose x1 takes the values: 1.2, 5, 6.4
> \`reg y x1\`: treats x1 as continuous & returns 1 coef (assuming no intercept)
> \`reg y i.x1\` creates 3 dummies for each level of x1 & returns 3 coefficients
> (if there is an intercept it randomly drops one level unless the user chooses which level to drop)
> 
> 2. \`i.x1#(c.x2 i.x3)\`
> Interacts all dummies of x1 w/ x2 (continuous)
> Interacts all dummies of x1 w/ all dummies of x3 
> 
> 3. Leads & Lags. Suppose D is at the state-year level. 
> \`L.D\`: creates a 1 year lag of D
> \`L(4).D\`: creates a 4 year lag of D
> \`F(4).D\`: creates a 4 year lead of D. $D\_{t+4}$
> \`reg y F(-1 0 1 2).D\`
> estimates: y\_t =b\_{-1} x\_{t-1} + b\_{0} x\_{t} +b\_{1} x\_{t+1} +b\_{2} x\_{t+2} 
> 
> If Julia is to be "\[as easy for statistics as R\](https://julialang.org/blog/2012/02/why-we-created-julia/)" these features should be in StatsModels.
> I'd love to help if I can.

---

<div class="post-metadata">

**Author:** ![samerb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samerb/32/9242_2.png) [@samerb](https://discourse.julialang.org/u/samerb)\
**Post date:** [August 15, 2022, 3:34am UTC](https://discourse.julialang.org/t/choosing-a-numerical-programming-language-for-economic-research-julia/85697/63 "2022-08-15T03:34:13Z")

</div>

> [@Albert\_Zevelev](#):
>
> PS: ALL of the things that are easier (for me) in STATA can be eventually implemented in Julia.

I’m curious how long it is expected that that will take. Most applied micro people appear to use R or Stata. I’m wondering how far away Julia is from those for panel data and causal inference econometrics or whatever other uses draws these people to R/Stata. Are there people working on these things with the goal of making Julia compete with R/Stata in these areas?

[Previous page](https://discourse.julialang.org/t/choosing-a-numerical-programming-language-for-economic-research-julia/85697.md?page=2)

[Next page](https://discourse.julialang.org/t/choosing-a-numerical-programming-language-for-economic-research-julia/85697.md?page=4)
