# \#linear-regression

**URL:** https://discourse.julialang.org/tag/linear-regression/906.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [Structured multivariate regression](https://discourse.julialang.org/t/structured-multivariate-regression/133954)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 2\
**Last updated:** [November 21, 2025, 12:41pm UTC](https://discourse.julialang.org/t/structured-multivariate-regression/133954 "2025-11-21T12:41:46Z")

</div>

I have a multivariate linear model which imposes the specific structure for each vector observation \\mathbf{y}\_i \\mathbf{y}\_i = \\mathbf{b}\_0 + \\begin{bmatrix} X\_{1,i} & 0 & X\_{c,i} \\\\ 0 & X\_{2,i} & X\_{c,i} \\\\ X\_{1,i} & …

---

## [Adding base level when interacting categorical variables](https://discourse.julialang.org/t/adding-base-level-when-interacting-categorical-variables/132796)

<div class="topic-metadata">

**Author:** [@miguelborrero](https://discourse.julialang.org/u/miguelborrero)\
**Replies:** 0\
**Last updated:** [September 30, 2025, 11:00pm UTC](https://discourse.julialang.org/t/adding-base-level-when-interacting-categorical-variables/132796 "2025-09-30T23:00:24Z")

</div>

High level problem: reg from FixedEffectModels seem to ignore contrasts for a categorical variable if I interact this variable with another one. MWE df = DataFrame(y = rand(100), x1 = categorical(rand(1:3, 100)), x2 =…

---

## [Solving a Shifted Linear System of 2 Symmetric Positive Semi Definite (SPSD) Matrices](https://discourse.julialang.org/t/solving-a-shifted-linear-system-of-2-symmetric-positive-semi-definite-spsd-matrices/131636)

<div class="topic-metadata">

**Author:** [@RoyiAvital](https://discourse.julialang.org/u/RoyiAvital)\
**Replies:** 31\
**Last updated:** [August 18, 2025, 6:20pm UTC](https://discourse.julialang.org/t/solving-a-shifted-linear-system-of-2-symmetric-positive-semi-definite-spsd-matrices/131636 "2025-08-18T18:20:18Z")

</div>

I have the following linear system: \\left( \\boldsymbol{A} + \\lambda \\boldsymbol{C} \\right) \\boldsymbol{x} = \\boldsymbol{A}^{T} \\boldsymbol{b} Where \\boldsymbol{A}, \\boldsymbol{C} \\in \\mathcal{S}\_{+}^{n} are Symmetric …

---

## [Repeated linear least squares problem with large dimensions](https://discourse.julialang.org/t/repeated-linear-least-squares-problem-with-large-dimensions/130023)

<div class="topic-metadata">

**Author:** [@JADekker](https://discourse.julialang.org/u/JADekker)\
**Replies:** 6\
**Last updated:** [June 19, 2025, 6:17pm UTC](https://discourse.julialang.org/t/repeated-linear-least-squares-problem-with-large-dimensions/130023 "2025-06-19T18:17:55Z")

</div>

Hi, I’m working with a larger algorithm in which a recurring step (done 5 - 20 times) is to carry out a linear regression y^k = X\\beta^k + \\varepsilon^k with roughly 100.000 observations and 1.000-5.000 variables, where…

---

## [Multiple fixed effects using FixedEffects.jl](https://discourse.julialang.org/t/multiple-fixed-effects-using-fixedeffects-jl/117113)

<div class="topic-metadata">

**Author:** [@shilong-sun](https://discourse.julialang.org/u/shilong-sun)\
**Replies:** 2\
**Last updated:** [July 17, 2024, 2:16am UTC](https://discourse.julialang.org/t/multiple-fixed-effects-using-fixedeffects-jl/117113 "2024-07-17T02:16:30Z")

</div>

Hi I’m using FixedEffects.jl to residualize matrices with fixed effects. I might be missing something with the syntax, but I couldn’t get the same results using a simple regression approach. Below is the code from the r…

---

## [Piecewise linear regression with automatic knot selection](https://discourse.julialang.org/t/piecewise-linear-regression-with-automatic-knot-selection/93984)

<div class="topic-metadata">

**Author:** [@meghapatnaik](https://discourse.julialang.org/u/meghapatnaik)\
**Replies:** 9\
**Last updated:** [January 2, 2024, 8:42pm UTC](https://discourse.julialang.org/t/piecewise-linear-regression-with-automatic-knot-selection/93984 "2024-01-02T20:42:04Z")

</div>

Hi everyone, I am new to Julia, mostly work with R. I am looking for the equivalent of the “segmented” package in R, to fit a piecewise linear (constant in my special case) regression where the knot location is automate…

---

## [What are the t-tests in the GLM.jl's models?](https://discourse.julialang.org/t/what-are-the-t-tests-in-the-glm-jls-models/103261)

<div class="topic-metadata">

**Author:** [@bertulli](https://discourse.julialang.org/u/bertulli)\
**Replies:** 7\
**Last updated:** [August 28, 2023, 7:38pm UTC](https://discourse.julialang.org/t/what-are-the-t-tests-in-the-glm-jls-models/103261 "2023-08-28T19:38:53Z")

</div>

Hi all, I’m not sure about the meaning of the pretty prints of GLM.jl’s models: julia\> model StatsModels.TableRegressionModel{LinearModel{GLM.LmResp{Vector{Float64}}, GLM.DensePredChol{Float64, LinearAlgebra.CholeskyPiv…

---

## [How can I substitute NaN in a GLM model with zeroes?](https://discourse.julialang.org/t/how-can-i-substitute-nan-in-a-glm-model-with-zeroes/102038)

<div class="topic-metadata">

**Author:** [@bertulli](https://discourse.julialang.org/u/bertulli)\
**Replies:** 0\
**Last updated:** [July 24, 2023, 7:44pm UTC](https://discourse.julialang.org/t/how-can-i-substitute-nan-in-a-glm-model-with-zeroes/102038 "2023-07-24T19:44:03Z")

</div>

Hi all! I have a linear model, created with GLM.jl. Since I correlated some variables with a categorical one, I have lots of NaN as coefficients, when the data are provided for only some of the categorical values: juli…

---

## [How can I use a linear model with NaN parameters due to missing train data?](https://discourse.julialang.org/t/how-can-i-use-a-linear-model-with-nan-parameters-due-to-missing-train-data/101648)

<div class="topic-metadata">

**Author:** [@bertulli](https://discourse.julialang.org/u/bertulli)\
**Replies:** 0\
**Last updated:** [July 15, 2023, 10:09am UTC](https://discourse.julialang.org/t/how-can-i-use-a-linear-model-with-nan-parameters-due-to-missing-train-data/101648 "2023-07-15T10:09:28Z")

</div>

Hi all! I am trying to build a model to predict electrical powers from a sequence of binary computer instructions. I thought to use a multiple linear regression, as from each instruction there are a lot of variables I c…

---

## [Basis functions to approximate the inverse of quadratic function](https://discourse.julialang.org/t/basis-functions-to-approximate-the-inverse-of-quadratic-function/101449)

<div class="topic-metadata">

**Author:** [@EricJohnson](https://discourse.julialang.org/u/EricJohnson)\
**Replies:** 33\
**Last updated:** [July 14, 2023, 10:58pm UTC](https://discourse.julialang.org/t/basis-functions-to-approximate-the-inverse-of-quadratic-function/101449 "2023-07-14T22:58:55Z")

</div>

I have many observations of measuring a physical parameter over time. Each observation is basically a function p(t), t \\in \[t\_1, t\_2\]. I also have the value \\int\_{t\_1}^{t\_2} q (t) dt = Q I have many observations: \\le…

---

## [This linear regression fails in Julia (GLM) vs Python (sklearn)](https://discourse.julialang.org/t/this-linear-regression-fails-in-julia-glm-vs-python-sklearn/101154)

<div class="topic-metadata">

**Author:** [@SantiagoOrtiz](https://discourse.julialang.org/u/SantiagoOrtiz)\
**Replies:** 7\
**Last updated:** [July 4, 2023, 7:05pm UTC](https://discourse.julialang.org/t/this-linear-regression-fails-in-julia-glm-vs-python-sklearn/101154 "2023-07-04T19:05:29Z")

</div>

I have not figured out why the Julia and Python implementations yield different results when performing this “simple” linear regression with the following data. While sklearn is consistent with Excel, GLM fails to perfor…

---

## [Learning Julia by an example of a simple Bayesian linear regression](https://discourse.julialang.org/t/learning-julia-by-an-example-of-a-simple-bayesian-linear-regression/99811)

<div class="topic-metadata">

**Author:** [@Boris](https://discourse.julialang.org/u/Boris)\
**Replies:** 10\
**Last updated:** [June 4, 2023, 8:58pm UTC](https://discourse.julialang.org/t/learning-julia-by-an-example-of-a-simple-bayesian-linear-regression/99811 "2023-06-04T20:58:49Z")

</div>

Hello everyone, long-time lurker, very occasional poster. I decided to give Julia a try once more with 1.9. So far I have struggled with the language on and off (I have touched on this previously) but would really like …

---

## [Can I do linear regression over physical data with Unitful?](https://discourse.julialang.org/t/can-i-do-linear-regression-over-physical-data-with-unitful/99229)

<div class="topic-metadata">

**Author:** [@bertulli](https://discourse.julialang.org/u/bertulli)\
**Replies:** 0\
**Last updated:** [May 22, 2023, 3:27pm UTC](https://discourse.julialang.org/t/can-i-do-linear-regression-over-physical-data-with-unitful/99229 "2023-05-22T15:27:17Z")

</div>

Hi all! I want to fit a multiple linear model on some data I collected. I decorated my data with units of measure using Unitful.jl, and I use GLM.jl’s lm function to produce the model. However, I can’t make it work. To …

---

## [VARX Model Estimation and Analysis](https://discourse.julialang.org/t/varx-model-estimation-and-analysis/96503)

<div class="topic-metadata">

**Author:** [@DionysisPap](https://discourse.julialang.org/u/DionysisPap)\
**Replies:** 8\
**Last updated:** [March 24, 2023, 4:51pm UTC](https://discourse.julialang.org/t/varx-model-estimation-and-analysis/96503 "2023-03-24T16:51:38Z")

</div>

As a beginner, i would like to ask if Julia provides any package (or function) for black box polynomial model estimation (preferably VARX model) and anaylis.

---

## [How can I perform GLM regression on column names with spaces?](https://discourse.julialang.org/t/how-can-i-perform-glm-regression-on-column-names-with-spaces/96442)

<div class="topic-metadata">

**Author:** [@bertulli](https://discourse.julialang.org/u/bertulli)\
**Replies:** 6\
**Last updated:** [March 22, 2023, 5:06pm UTC](https://discourse.julialang.org/t/how-can-i-perform-glm-regression-on-column-names-with-spaces/96442 "2023-03-22T17:06:37Z")

</div>

Hi all, very noob question but I can’t find an answer. I’m trying to do a linear regression on some data I have: julia\> df\_under\_test\[:, \[instruction\_sym, measure\_power\_sym, binary\_weight\_sym\]\] 1165×3 DataFrame Row │…

---

## [\[ANN\] LinearRegressionKit](https://discourse.julialang.org/t/ann-linearregressionkit/73769)

<div class="topic-metadata">

**Author:** [@Eric](https://discourse.julialang.org/u/Eric)\
**Replies:** 9\
**Last updated:** [November 22, 2022, 2:53pm UTC](https://discourse.julialang.org/t/ann-linearregressionkit/73769 "2022-11-22T14:53:34Z")

</div>

LinearRegressionKit is now in version 0.7.4 and is now registered (you can use add LinearRegressionKit from the package prompt). See LinearRegressionKit project page for details. The package LinearRegression will not be…

---

## [Regression with categorical variables. Reference porevious levels. Dummy](https://discourse.julialang.org/t/regression-with-categorical-variables-reference-porevious-levels-dummy/90194)

<div class="topic-metadata">

**Author:** [@Juan](https://discourse.julialang.org/u/Juan)\
**Replies:** 5\
**Last updated:** [November 14, 2022, 11:08pm UTC](https://discourse.julialang.org/t/regression-with-categorical-variables-reference-porevious-levels-dummy/90194 "2022-11-14T23:08:49Z")

</div>

Hello. If a do a linear regression model I can include the year as a categorical variable (instead of numerical) in order to estimate a different coefficient for each year. This is commonly done when the variable is not…

---

## [Discrepancy between lme4 and GLM.jl](https://discourse.julialang.org/t/discrepancy-between-lme4-and-glm-jl/85601)

<div class="topic-metadata">

**Author:** [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Replies:** 7\
**Last updated:** [November 1, 2022, 4:18pm UTC](https://discourse.julialang.org/t/discrepancy-between-lme4-and-glm-jl/85601 "2022-11-01T16:18:30Z")

</div>

There I was, happily running thousands of linear models with GLM.jl, but the results didn’t seem quite right. For one thing, all of my p-values were exceptionally low (\>90% of features significant, even after FDR correct…

---

## [Meaning of \`GLM.lm\` results (\`t\` and \`Pr(\>|t|)\`)](https://discourse.julialang.org/t/meaning-of-glm-lm-results-t-and-pr-t/88042)

<div class="topic-metadata">

**Author:** [@bertulli](https://discourse.julialang.org/u/bertulli)\
**Replies:** 9\
**Last updated:** [October 1, 2022, 4:30pm UTC](https://discourse.julialang.org/t/meaning-of-glm-lm-results-t-and-pr-t/88042 "2022-10-01T16:30:52Z")

</div>

Hi all! This is a very noobish question, I was uncertain if I should put it in “New to Julia” section, so sorry about it. Anyway, when I fit a linear model using the GLM package, like this: using DataFrames using CSV …

---

## [How can I tell Julia what are the parameters in a linear model?](https://discourse.julialang.org/t/how-can-i-tell-julia-what-are-the-parameters-in-a-linear-model/87692)

<div class="topic-metadata">

**Author:** [@bertulli](https://discourse.julialang.org/u/bertulli)\
**Replies:** 14\
**Last updated:** [September 26, 2022, 5:24pm UTC](https://discourse.julialang.org/t/how-can-i-tell-julia-what-are-the-parameters-in-a-linear-model/87692 "2022-09-26T17:24:11Z")

</div>

Hi all! So, I’m experimenting with the linear regression ecosystem (GLM, Plots, DataFrames, StatsPlots and CSV). I understood how to produce a simple linear regression model and a multivariate one. I know that OLS work…

---

## [ErrorsInVariables.jl: Reducing errors-in-variables bias in linear regression](https://discourse.julialang.org/t/errorsinvariables-jl-reducing-errors-in-variables-bias-in-linear-regression/86853)

<div class="topic-metadata">

**Author:** [@jbytecode](https://discourse.julialang.org/u/jbytecode)\
**Replies:** 0\
**Last updated:** [September 6, 2022, 7:22pm UTC](https://discourse.julialang.org/t/errorsinvariables-jl-reducing-errors-in-variables-bias-in-linear-regression/86853 "2022-09-06T19:22:59Z")

</div>

I am happy to announce that my Julia package ErrorsInVariables is now available in Julia package repository and ready to install. The package is the Julia implementation of our published algorithm and the R package eive.…

---

## [\[FixedEffectModels.jl\] Switching from Dummy to Categorical Variables](https://discourse.julialang.org/t/fixedeffectmodels-jl-switching-from-dummy-to-categorical-variables/85800)

<div class="topic-metadata">

**Author:** [@teamtelefunken](https://discourse.julialang.org/u/teamtelefunken)\
**Replies:** 2\
**Last updated:** [August 16, 2022, 6:01pm UTC](https://discourse.julialang.org/t/fixedeffectmodels-jl-switching-from-dummy-to-categorical-variables/85800 "2022-08-16T18:01:13Z")

</div>

I am trying to use FixedEffectModels.jl with a dataset with a continuous explanatory variable, and want to run regressions on a binned version of this variable. I have two approaches: a) I can either, via cut, produce ca…

---

## [Using LsqFit to make a line using a model](https://discourse.julialang.org/t/using-lsqfit-to-make-a-line-using-a-model/76321)

<div class="topic-metadata">

**Author:** [@Shamil-Luqman](https://discourse.julialang.org/u/Shamil-Luqman)\
**Replies:** 0\
**Last updated:** [February 12, 2022, 11:03pm UTC](https://discourse.julialang.org/t/using-lsqfit-to-make-a-line-using-a-model/76321 "2022-02-12T23:03:37Z")

</div>

“”" @. model(x, p) = (p\[1\] + p\[2\]\*x) + (p\[3\]/(p\[5\]√(2π) ))exp(-(x-p\[4\])^2/(2p\[5\]^2)) end “”" I have to fit this data into a steppere line graph I have and I can’t figure out how to use LsqFit to integrate the data.

---

## [Have confusion regarding Linear Regression](https://discourse.julialang.org/t/have-confusion-regarding-linear-regression/75399)

<div class="topic-metadata">

**Author:** [@mirror63](https://discourse.julialang.org/u/mirror63)\
**Replies:** 7\
**Last updated:** [January 29, 2022, 11:59am UTC](https://discourse.julialang.org/t/have-confusion-regarding-linear-regression/75399 "2022-01-29T11:59:37Z")

</div>

Blood pressure is normally measured using cuff based methods. New contactless methods for blood pressure measurements rely on measuring time difference between two biomedical waveforms. This time difference is called pul…
