represents a linear combination of the input features.
LinearModel[{f1,…},vars]
represents a linear combination of the functions fi in the variables vars.
LinearModel[{f1,…},pars,vars]
uses explicit parameter values and names pars.
LinearModel
represents a linear combination of the input features.
LinearModel[{f1,…},vars]
represents a linear combination of the functions fi in the variables vars.
LinearModel[{f1,…},pars,vars]
uses explicit parameter values and names pars.
Details
- LinearModel represents a linear combination of a list of functions (basis) for the purpose of symbolic or numerical evaluation and fitting.
- Linear models describe phenomena with constant rates of change, such as proportional relationships, steady trends and first-order approximations of more complex behavior.
- Multivariate linear models are especially useful when multiple factors contribute additively to an outcome, allowing each variable’s effect to be interpreted independently.
- LinearModel[{f1,…,fn},{c1,…,cn},{x1,…,xm}] corresponds to the function
. - When not specified, variables will automatically be enumerated using x[i].
- Valid variable specifications vars include:
-
n the number of variables symb a symbolic representation of a single variable {symb1,…} a list of symbolic variables - When not specified, parameters will automatically be enumerated using C[i].
- Valid parameter pars specifications in the form {par1,…} include:
-
val a fixed parameter value val par a symbolic parameter name par parval a symbolic name par set to a fixed value val {par,val0} a symbolic parameter named par with the initial value val0 - Model properties can be extracted using Information[PowerModel[…],prop].
- Valid basic properties include:
-
"BaseType" model base type "Name" model name "ShortName" short identifier to use as label "InputType" supported input types "OutputType" supported output types - Valid data-related properties include:
-
"ColumnNames" names of the input features "ColumnVariableMap" map between column names and model variables "InputSize" dimensionality of the input "OutputSize" dimensionality of the output "Trainable" whether the model is fully specified and can be trained "Trained" whether the model can be evaluated numerically "VariableColumnMap" map between model variables and column names "Variables" name of the model variables - Best model-related properties include:
-
"Expression" model expression "Function" model as a pure function "SymbolicExpression" model expression with symbolic parameters "TabularFunction" pure function suitable to work on a tabular row - Parameter-related properties include:
-
"ParameterAssociation" association of parameter names and values "ParameterCount" the number of parameters "ParameterInitialValues" initial values for the fit "ParameterNames" parameter names "ParameterRules" list of rules with parameter names and values "Parameters" parameter values if present; names otherwise "ParameterValues" parameter values "Constraints" parameter constraints - Hyperparameter-related properties include:
-
"Hyperparameters" hyperparameter values
Variables
Parameters
Properties
Examples
open all close allBasic Examples (4)
Define a straight-line model in the x variable:
LinearModel[{1, x}, x]Evaluate an untrained model on the symbolic variable y:
LinearModel[{1, x}, x][y]Specify custom named parameters:
model = LinearModel[{x, 1}, {m, c}, x]model[y]Create a linear model based on multiple variables:
LinearModel[{x ^ 2, Log[x], y}, {x, y}]LinearModel[{b x ^ 2, Log[a x], c y}, {a, b, c}, {x, y}]Fit the model on a given dataset:
ModelFit[{{1, 4.}, {2.4, 9.63547}, {5.3, 32.7577}, {7.8, 65.8941}}, LinearModel[{x, x ^ 2, Log[x], 1}, x]]Scope (18)
Hyperparameters (3)
Basis (3)
Use a linear combination of all the input features:
LinearModel[]The basis will automatically be created when data is provided:
LinearModel[][{x, y, z}]LinearModel[{Tan[x], Cos[x]}, x]Use the explicit hyperparameter name:
LinearModel[<|"Basis" -> {Tan[x], Cos[x]}|>, x]Naked expressions are automatically converted to a list:
LinearModel[x, x]Variables (3)
Parameters (4)
Parameter names are assigned automatically:
LinearModel[{x ^ 2, Log[x]}, x]Specify custom parameter names:
LinearModel[{x ^ 2, Log[x]}, {a, b}, x]Set a parameter to a specific value:
LinearModel[{x ^ 2, Log[x]}, {12, b}, x]Specify both parameter names and values:
LinearModel[{x ^ 2, Log[x]}, {a -> 12, b}, x]Evaluation (4)
Symbolically evaluate a single-variable model:
LinearModel[{x ^ 2, Log[x]}, x][x]Symbolically evaluate a two-variable model:
LinearModel[{x ^ 2, Log[x], y}, {x, y}][{var1, var2}]Evaluate a model on multiple symbolic variables:
LinearModel[{x ^ 2, Log[x], y}, {x, y}][{{x, y}, {a, b}}]Evaluate a model on a list of points:
LinearModel[{x ^ 2, Log[x]}, {-.3, 1}, x][{1, 2, 3}]Interactive Examples (1)
Interactively select the basis functions:
Manipulate[
Module[
{data = {...}, fit},
fit = ModelFit[data, LinearModel[Append[basis, 1], x]];
Labeled[Show[
ListPlot[data, PlotRange -> All, PlotStyle -> StandardGray],
Plot[Evaluate[fit[x]], {x, -3, 5}],
PlotRange -> MinMax /@ Transpose[data], Frame -> True, PlotRangePadding -> Scaled[.1]
],
Style[TraditionalForm[NumberForm[Information[fit, "Expression"], 2]], "Label"]]
],
{{basis, {x}}, {x, x ^ 2, Sin[x], Cos[x]}, ControlType -> TogglerBar}
]Related Guides
History
Text
Wolfram Research (2026), LinearModel, Wolfram Language function, https://reference.wolfram.com/language/ref/LinearModel.html.
CMS
Wolfram Language. 2026. "LinearModel." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/LinearModel.html.
APA
Wolfram Language. (2026). LinearModel. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/LinearModel.html
BibTeX
@misc{reference.wolfram_2026_linearmodel, author="Wolfram Research", title="{LinearModel}", year="2026", howpublished="\url{https://reference.wolfram.com/language/ref/LinearModel.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_linearmodel, organization={Wolfram Research}, title={LinearModel}, year={2026}, url={https://reference.wolfram.com/language/ref/LinearModel.html}, note=[Accessed: 12-June-2026]}