Get the equation for a linear regression model

79 visualizaciones (últimos 30 días)
Heather
Heather el 7 de Oct. de 2025 a las 19:32
Comentada: dpb el 9 de Oct. de 2025 a las 20:12
What code do I use to get the software to display the acutal equation instead of "[Linear formula with 18 terms in 7 predictors]"?
  11 comentarios
Torsten
Torsten el 9 de Oct. de 2025 a las 19:29
It seems that if second-order or interaction terms are present in the linear model, the main effects are not included in the formula for the regression model.
The example
Terms Matrix for Matrix Input
under
shows this (illogical) behaviour, but without commenting on it or giving a justification.
dpb
dpb el 9 de Oct. de 2025 a las 20:12
Well, it is logical in a sense, just not well documented what mdl.Formula property returns...it is the Wilkinson representation of the model in which "x1*x2" implies the interaction term plus all lower terms. There's a difference in specifying "x1*x2" and "x1:x2" which is easy to miss--the latter says to include only the specific interaction term.
I haven't yet investigated fully whether the returned formula property is always in Wilkinson notation regardless of how the input model is specified or whether it just reflects the user input specification.
I'll try to do some more spelunking and see; at least the doc needs to be explicit in what the user should expect; certainly for @Heather's Q? here, it isn't what she's looking for; one would have to build that expression from the table of coefficients similarly as your earlier examples. If that were to be so, that seems rude to be the only way to be able to generate the full representation of the model for presentation purposes, for example.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Descriptive Statistics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by