# Julia vs (R/STATA/Matlab/SAS/Python) for common data analysis tasks (2022 edition)

**URL:** https://discourse.julialang.org/t/julia-vs-r-stata-matlab-sas-python-for-common-data-analysis-tasks-2022-edition/85801
**Category:** General Usage
**Tags:** data
**Created:** [August 16, 2022, 12:23am UTC](https://discourse.julialang.org/t/julia-vs-r-stata-matlab-sas-python-for-common-data-analysis-tasks-2022-edition/85801 "2022-08-16T00:23:49Z")
**Posts on this page:** 7
**Page:** 1

<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 16, 2022, 12:23am UTC](https://discourse.julialang.org/t/julia-vs-r-stata-matlab-sas-python-for-common-data-analysis-tasks-2022-edition/85801/1 "2022-08-16T00:23:49Z")

</div>

From a previous discussion

> [@Choosing a numerical programming language for economic research: Julia,](https://discourse.julialang.org/t/choosing-a-numerical-programming-language-for-economic-research-julia/85697/96):
>
> It seems like people here in this conversation believe that Julia is really quite difficult and annoying to use for reading in data sets, transforming them, plotting them, and then fitting 5-20 different models on those datasets. I find this bizarre, because it’s what I literally just did for the last few weeks and it couldn’t have been more enjoyable. Are there a few warts? Yes, for example there was some situation where by reading in all the census ACS microdata for 5 years I wound up hitting…

So I’m starting this thread with the idea that people could come here with some example data analysis problems and Julia users can reproduce something like them here to give people a sense of how easy or difficult it is to accomplish common tasks.

I don’t want this to become “do my research project for me” of course, but if you’ve worked on a project in another language and want to see how you’d accomplish something similar in Julia, propose a project, preferably with links to a github or a blog page or etc with the code from the other language. Let’s use this as a way to get some simple hand-holding type howtos for data analysis in Julia.

What’s in scope:

1. Reading datasets in various common formats
2. Munging data from multiple sources into a particular data set structure / calculating statistics
3. Plotting various common 2D type plots: scatter, line, histogram, density, small-multiples of each, etc
4. Fitting regression models
5. Running simulations of some sort based on data (random number generation, dynamic processes etc)
6. Optimization / decision making based on data.

Not in scope:

1. Open research problems
2. Proprietary datasets
3. Do my homework for me
4. Reproducing the output of proprietary software/algorithms etc where the method isn’t public
5. Lots of precise tweaking of the output of graphs to get very precise visual results / exactly reproduce the output of another piece of software.

To make this really doable the problems should be the kind of thing you’d expect a grad student to be able to do in an afternoon or two. Keep it reasonably scoped.

---

<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 16, 2022, 6:08am UTC](https://discourse.julialang.org/t/julia-vs-r-stata-matlab-sas-python-for-common-data-analysis-tasks-2022-edition/85801/2 "2022-08-16T06:08:33Z")

</div>

Would be interesting to hear from @JackStrauss what Julia is lacking to replace dynlm() in R as mentioned in the other thread.

---

<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 16, 2022, 6:05pm UTC](https://discourse.julialang.org/t/julia-vs-r-stata-matlab-sas-python-for-common-data-analysis-tasks-2022-edition/85801/3 "2022-08-16T18:05:28Z")

</div>

I guess I’ll link to this repo, where Phil Price and I started comparing some tasks in R vs Julia. We never really finished this project. In particular, I wrote a fairly trivial looping simulation in Julia and Phil tried to come up with something performant in R and eventually gave up because both it’s not trivial and also he had lots of real world things to do.

> **[GitHub - dlakelan/juliatidycomp: A comparison of Julia and R+Tidyverse for...](https://github.com/dlakelan/juliatidycomp)**
>
> A comparison of Julia and R+Tidyverse for basic data exploration and analysis - GitHub - dlakelan/juliatidycomp: A comparison of Julia and R+Tidyverse for basic data exploration and analysis

I think the Olympics example shows how trivial stuff in R is still trivial in Julia.

The simulation.jl shows how trivial stuff in Julia may well be nearly impossible in R

The COVID example is unfinished I think. But still of interest.

---

<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: [September 1, 2022, 5:14am UTC](https://discourse.julialang.org/t/julia-vs-r-stata-matlab-sas-python-for-common-data-analysis-tasks-2022-edition/85801/4 "2022-09-01T05:14:24Z")

</div>

Looks like this package brings many STATA data cleaning commands to Julia:

> **[GitHub - eirikbrandsaas/PanelDataTools.jl: Convenient functions for working...](https://github.com/eirikbrandsaas/PanelDataTools.jl)**
>
> Convenient functions for working with panel (longitudinal) data in Julia - GitHub - eirikbrandsaas/PanelDataTools.jl: Convenient functions for working with panel (longitudinal) data in Julia

I wish these things (including regressionformulae.jl) weren’t scattered around the ecosystem…

---

<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: [September 1, 2022, 9:06am UTC](https://discourse.julialang.org/t/julia-vs-r-stata-matlab-sas-python-for-common-data-analysis-tasks-2022-edition/85801/5 "2022-09-01T09:06:13Z")

</div>

If you want to use Stata syntax from Julia there’s

> **[GitHub - jmboehm/Douglass.jl: Stata-like toolkit for data wrangling on Julia...](https://github.com/jmboehm/Douglass.jl)**
>
> Stata-like toolkit for data wrangling on Julia DataFrames - GitHub - jmboehm/Douglass.jl: Stata-like toolkit for data wrangling on Julia DataFrames

---

<div class="post-metadata">

### Author: ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)
#### Post date: [September 1, 2022, 9:20am UTC](https://discourse.julialang.org/t/julia-vs-r-stata-matlab-sas-python-for-common-data-analysis-tasks-2022-edition/85801/6 "2022-09-01T09:20:33Z")

</div>

I’m hoping [Effects.jl](https://github.com/beacon-biosignals/Effects.jl) and [Vcov.jl](https://github.com/FixedEffects/Vcov.jl) become supported widely by the modeling packages.

---

<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: [September 1, 2022, 10:01am UTC](https://discourse.julialang.org/t/julia-vs-r-stata-matlab-sas-python-for-common-data-analysis-tasks-2022-edition/85801/7 "2022-09-01T10:01:22Z")

</div>

I was referring specifically to these types of commands (from my previous discussion w @dlakelan):

> <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.
