WOLFRAM

Enable JavaScript to interact with content and submit forms on Wolfram websites. Learn how
Wolfram Language & System Documentation Center

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
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Hyperparameters  
Basis  
Variables  
Parameters  
Evaluation  
Information  
Fitting  
Interactive Examples  
See Also
Related Guides
History
Cite this Page

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 variables effect to be interpreted independently.
  • LinearModel [{f1,,fn},{c1,,cn},{x1,,xm}] corresponds to the function .
  • Variables
  • 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
  • Parameters
  • 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
  • Properties
  • 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

Examples

open all close all

Basic Examples  (4)

Define a straight-line model in the x variable:

Wolfram Language code: LinearModel[{1, x}, x]

Evaluate an untrained model on the symbolic variable y:

Wolfram Language code: LinearModel[{1, x}, x][y]

Specify custom named parameters:

Wolfram Language code: model = LinearModel[{x, 1}, {m, c}, x]

Evaluate the model:

Wolfram Language code: model[y]

Create a linear model based on multiple variables:

Wolfram Language code: LinearModel[{x ^ 2, Log[x], y}, {x, y}]

Use custom parameterization:

Wolfram Language code: LinearModel[{b x ^ 2, Log[a x], c y}, {a, b, c}, {x, y}]

Fit the model on a given dataset:

Wolfram Language code: 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:

Wolfram Language code: LinearModel[]

The basis will automatically be created when data is provided:

Wolfram Language code: LinearModel[][{x, y, z}]

Specify the linear basis:

Wolfram Language code: LinearModel[{Tan[x], Cos[x]}, x]

Use the explicit hyperparameter name:

Wolfram Language code: LinearModel[<|"Basis" -> {Tan[x], Cos[x]}|>, x]

Naked expressions are automatically converted to a list:

Wolfram Language code: LinearModel[x, x]

Variables  (3)

Specify a single-variable model:

Wolfram Language code: LinearModel[{x ^ 2, Log[x]}, x]

Specify multiple variables:

Wolfram Language code: LinearModel[{x ^ 2, Log[x], y}, {x, y}]

Variable names are overwritten when the model is evaluated:

Wolfram Language code: LinearModel[{x ^ 2, Log[x], y}, {x, y}][{var1, var2}]

Parameters  (4)

Parameter names are assigned automatically:

Wolfram Language code: LinearModel[{x ^ 2, Log[x]}, x]

Specify custom parameter names:

Wolfram Language code: LinearModel[{x ^ 2, Log[x]}, {a, b}, x]

Set a parameter to a specific value:

Wolfram Language code: LinearModel[{x ^ 2, Log[x]}, {12, b}, x]

Specify both parameter names and values:

Wolfram Language code: LinearModel[{x ^ 2, Log[x]}, {a -> 12, b}, x]

Evaluation  (4)

Symbolically evaluate a single-variable model:

Wolfram Language code: LinearModel[{x ^ 2, Log[x]}, x][x]

Symbolically evaluate a two-variable model:

Wolfram Language code: LinearModel[{x ^ 2, Log[x], y}, {x, y}][{var1, var2}]

Evaluate a model on multiple symbolic variables:

Wolfram Language code: LinearModel[{x ^ 2, Log[x], y}, {x, y}][{{x, y}, {a, b}}]

Evaluate a model on a list of points:

Wolfram Language code: LinearModel[{x ^ 2, Log[x]}, {-.3, 1}, x][{1, 2, 3}]

Information  (3)

View general information about a model:

Wolfram Language code: Information[LinearModel[x, x]]

Extract a single property:

Wolfram Language code: Information[LinearModel[x, x], "Variables"]

Retrieve multiple properties:

Wolfram Language code: Information[LinearModel[x, x], {"Variables", "Parameters"}]

Fitting  (1)

Fit a linear model:

Wolfram Language code: ModelFit[{...}, LinearModel[{x, x ^ 2}, x]]

Interactive Examples  (1)

Interactively select the basis functions:

Wolfram Language code: 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} ]
Wolfram Research (2026), LinearModel, Wolfram Language function, https://reference.wolfram.com/language/ref/LinearModel.html.

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: 14-August-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: 14-August-2026]}

Top [フレーム]

AltStyle によって変換されたページ (->オリジナル) /