# The simplest linear fit with GLM

**URL:** <https://discourse.julialang.org/t/the-simplest-linear-fit-with-glm/71316>\
**Category:** Tooling\
**Tags:** glm\
**Created:** [November 11, 2021, 8:17am UTC](https://discourse.julialang.org/t/the-simplest-linear-fit-with-glm/71316 "2021-11-11T08:17:56Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [November 11, 2021, 9:30am UTC](https://discourse.julialang.org/t/the-simplest-linear-fit-with-glm/71316/4 "2021-11-11T09:30:46Z")

</div>

I’d say at a minimum univariate regression without intercept is something fairly non-standard in the world of regression modelling, and you might as well just do `x\y` without using any packages if that’s all you’re after? Or alternatively read [this very detailed thread](https://discourse.julialang.org/t/efficient-way-of-doing-linear-regression/31232/37) on all the different ways to do linear regression in Julia.

I’m not sure there’s a particular reason why all methods in GLM require a matrix for the covariates (other than I assume this is by far the most common use case for people using GLM, and even for a univariate regression people will generally `hcat` a vector of ones to `x` to include an intercept, creating a matrix), but I’m also not sure it needs new methods when you can just do `lm(reshape(x, length(x), 1)` if you absolutely want to use `lm` to do `x\y`. But I guess you could try a PR that defines `lm(x::AbstractVector, y::AbstractVector) = lm(reshape(x, length(x), 1), y)` and see what the maintainers think.

---

_[View the full topic](https://discourse.julialang.org/t/the-simplest-linear-fit-with-glm/71316)._
