# Efficient way of doing linear regression

**URL:** <https://discourse.julialang.org/t/efficient-way-of-doing-linear-regression/31232>\
**Category:** Performance\
**Tags:** regression\
**Created:** [November 18, 2019, 5:21pm UTC](https://discourse.julialang.org/t/efficient-way-of-doing-linear-regression/31232 "2019-11-18T17:21:15Z")\
**Posts on this page:** 1\
**Showing post:** 42

<div class="post-metadata">

**Author:** ![Juan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juan/32/7657_2.png) [@Juan](https://discourse.julialang.org/u/Juan)\
**Post date:** [August 12, 2020, 11:26pm UTC](https://discourse.julialang.org/t/efficient-way-of-doing-linear-regression/31232/42 "2020-08-12T23:26:33Z")

</div>

Related to your question:

> [@GLM is slow on large datasets. Using OnlineStats for regressions? MixedModels?](https://discourse.julialang.org/t/glm-is-slow-on-large-datasets-using-onlinestats-for-regressions-mixedmodels/17695):
>
> Hello. I’m planning to move from R to Julia and doing some tests about how to properly deal with large datasets and do simple tasks like regressions or survival analysis. I’ve done a benchmark with R (microbenchmark) for the regressions. N ← 3000 x1 ← rep(1:N, N) x2 ← rep(1:N, each = N) x3 ← sqrt(rep(1:N^2)) x1x2 ← x1x2 gg ← rep(1:5, each=N^2/5) y ← 1-2x1+3x2+0.5x1x2+rnorm(N^2)+x3\*rnorm(N^2) dat ← data.frame(y,x1,x2,x1x2,x3, gg) dat2 ← cbind(1,x1,x2,x1x2,x3,gg) lm(y ~ x1 + x2 + x1…

---

_[View the full topic](https://discourse.julialang.org/t/efficient-way-of-doing-linear-regression/31232)._
