# How to | Get Results for Fitted Models

When fitting data to a model, it is often important to obtain additional results to compare the data to the fitted function. You may wish to check the significance of parameters and assess the assumptions of the model, the influence of data points, and the goodness of fit. In the Wolfram Language you can obtain these results directly from FittedModel objects returned by model fitting functions such as LinearModelFit, NonlinearModelFit, and GeneralizedLinearModelFit.

First, define a dataset to work with:

 In[1]:=

You can fit a simple linear regression model using LinearModelFit:

 In[2]:=
 Out[2]=

The output is a FittedModel object that contains information about the fitting and original data. You can get results and diagnostics directly from the object.

Use Normal to give the functional form of the fitted model:

 In[3]:=
 Out[3]=

You can also evaluate the model at specific points.

Evaluate the model as a function of z rather than the original variable x:

 In[4]:=
 Out[4]=

Evaluating at a numeric value gives the value predicted by the function at that numeric value of x:

 In[5]:=
 Out[5]=

Because the FittedModel object evaluates like a function, you can plot it directly using Plot:

 In[6]:=
 Out[6]=

You can visualize the data points with the fitted function by using Show to combine a ListPlot of the data points with the previous plot:

 In[7]:=
 Out[7]=

FittedModel objects also contain many results and diagnostics that are relevant to the type of model they represent (in this case a linear model). You can evaluate the FittedModel with "Properties" to get a full list of the available properties for that model.

Here Length is used to give the number of properties known for this model:

 In[8]:=
 Out[8]=

It is often important to ask whether or not the parameter estimates are statistically significant, that is, whether or not the parameter values are significantly different from 0. For instance, with a linear model you might look at the value for a -statistic associated with that parameter. The value is the probability of observing a -statistic at least as far from 0 as the one obtained.

Use "ParameterTable" with the FittedModel to display a table that summarizes the parameter estimates, -statistics, and values:

 In[9]:=
 Out[9]=

You can use other properties to get the -statistics and values individually. This is particularly useful if you want to compute other results based on those properties. Use "ParameterPValues" with the FittedModel to view just the -values:

 In[10]:=
 Out[10]=

View multiple properties at once by entering a list of properties. View the -statistics and values together:

 In[11]:=
 Out[11]=

You can also get confidence intervals for the parameters:

 In[12]:=
 Out[12]=

By default, 95% confidence intervals are returned. You can get other intervals with other levels of confidence by using the ConfidenceLevel option.

View the 99% confidence intervals for the parameters:

 In[13]:=
 Out[13]=

Additional pointwise diagnostics are also included, such as residuals.

Here, the residuals for the fitted model are computed and assigned to resids:

 In[14]:=
 Out[14]=

Visualize the residuals using ListPlot:

 In[15]:=
 Out[15]=

Though the available properties differ somewhat, results and diagnostics for nonlinear and generalized linear models can be obtained in the same way. You can fit models of these types by using NonlinearModelFit, GeneralizedLinearModelFit, LogitModelFit, or ProbitModelFit.

Define another dataset to work with:

 In[1]:=

Use NonlinearModelFit to fit the data to an exponential model:

 In[2]:=
 Out[2]=

Just as in the linear model case, use Show to combine the plots of the data points and the model:

 In[3]:=
 Out[3]=

You can also view tabular results for estimates at individual points. Use "SinglePredictionConfidenceIntervalTable" with the FittedModel to view such a table of predicted values with their error estimates and confidence intervals:

 In[4]:=
 Out[4]=

You can also visualize the associated prediction bands.

First, define functions for the 80%, 90%, 95%, and 99% prediction bands of the fitted function:

 In[5]:=

Visualize the regions bounded by the bands along with the fitted function and use Filling to more easily see the regions of each confidence level:

 In[6]:=
 Out[6]=