This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
How to | Perform a Linear Regression
One of the most common statistical models is the linear regression model. A linear model predicts the value of a response variable by the linear combination of predictor variables or functions of predictor variables. In Mathematica, LinearModelFit returns an object that contains fitting information for a linear regression model and allows for easy extraction of results and diagnostics.
Simulate a dataset:
Use LinearModelFit to construct a linear model for the data:
 Out[2]=
Extract the functional form of the model:
 Out[4]=
Plot the functional form of the model:
 Out[5]=
Show the data and the line of best fit:
 Out[6]=
Obtain information about the parameter estimates:
 Out[7]=
Extract and plot the standardized residuals and fit residuals:
 Out[9]=
Plot the Cook distances by observation number:
 Out[10]=
Alternatively, plot the Cook distances versus predictor value:
 Out[11]=
The previous examples demonstrated a selection of properties supported by LinearModelFit; many more are available:
 Out[12]=