# 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:** 26

<div class="post-metadata">

**Author:** ![dmbates](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmbates/32/44_2.png) [@dmbates](https://discourse.julialang.org/u/dmbates)\
**Post date:** [November 21, 2019, 4:24pm UTC](https://discourse.julialang.org/t/efficient-way-of-doing-linear-regression/31232/26 "2019-11-21T16:24:08Z")

</div>

I describe a number of different ways of performing a simple linear regression in

[https://github.com/dmbates/CopenhagenEcon/blob/master/jmd/03-LinearAlgebra.jmd](https://github.com/dmbates/CopenhagenEcon/blob/master/jmd/03-LinearAlgebra.jmd)

As shown in the `README.md` file for the repository an effective way of running the .jmd file is to use `Weave.convert_doc` to create a Jupyter notebook and run that. (By the way, this notebook also shows using the R `ggplot2` graphics package from Julia through `RCall`.).

It is difficult to benchmark a simple calculation like this but I suspect that the method of augmenting the model matrix with the response vector and using a Cholesky factorization will be competitive. It has the advantage of also providing the sum of squared residuals without needing to evaluate the residuals.

---

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