This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

GeneralizedLinearModelFit

GeneralizedLinearModelFit
constructs a generalized linear model of the form that fits the for successive x values 1, 2, ....
GeneralizedLinearModelFit
constructs a generalized linear model of the form where the depend on the variables .
GeneralizedLinearModelFit
constructs a generalized linear model from the design matrix m and response vector v.
  • GeneralizedLinearModelFit returns a symbolic FittedModel object to represent the generalized linear model it constructs. The properties and diagnostics of the model can be obtained from model["property"].
  • With data in the form , the number of coordinates , , ... should correspond to the number of variables .
  • Data in the form is equivalent to data in the form .
  • GeneralizedLinearModelFit produces a generalized linear model of the form under the assumption that the original are independent observations following an exponential family distribution with mean and the function being an invertible link function.
AccuracyGoalAutomaticthe accuracy sought
ConfidenceLevel95/100confidence level for parameters and predictions
CovarianceEstimatorFunction"ExpectedInformation"estimation method for the parameter covariance matrix
DispersionEstimatorFunctionAutomaticfunction for estimating the dispersion parameter
ExponentialFamilyAutomaticexponential family distribution for y
IncludeConstantBasisTruewhether to include a constant basis function
LinearOffsetFunctionNoneknown offset in the linear predictor
LinkFunctionAutomaticlink function for the model
MaxIterationsAutomaticmaximum number of iterations to use
NominalVariablesNonevariables considered as nominal
PrecisionGoalAutomaticthe precision sought
WeightsAutomaticweights for data elements
WorkingPrecisionAutomaticthe precision for internal computations
  • With ConfidenceLevel->p, then probability-p confidence intervals are computed for parameter and prediction intervals.
  • With the setting DispersionEstimatorFunction->f, the common dispersion is estimated by where is the list of observations, is the list of predicted values, and is the list of weights for the measurements .
  • Properties related to data and the fitted function obtained using model["property"] include:
"BasisFunctions"list of basis functions
"BestFit"fitted function
"BestFitParameters"parameter estimates
"Data"the input data or design matrix and response vector
"DesignMatrix"design matrix for the model
"Function"best fit pure function
"LinearPredictor"fitted linear combination
"Response"response values in the input data
  • Properties related to dispersion and model deviances include:
"Deviances"deviances
"DevianceTable"deviance table
"DevianceTableDegreesOfFreedom"degrees of freedom differences from the table
"DevianceTableDeviances"deviance differences from the table
"DevianceTableEntries"unformatted array of values from the table
"DevianceTableResidualDegreesOfFreedom"residual degrees of freedom from the table
"DevianceTableResidualDeviances"residual deviances from the table
"EstimatedDispersion"estimated dispersion parameter
"NullDeviance"deviance for the null model
"NullDegreesOfFreedom"degrees of freedom for the null model
"ResidualDeviance"difference between the model deviance and null deviance
"ResidualDegreesOfFreedom"difference between the model degrees of freedom and null degrees of freedom
  • Types of residuals include:
"AnscombeResiduals"Anscombe residuals
"DevianceResiduals"deviance residuals
"FitResiduals"difference between actual and predicted responses
"LikelihoodResiduals"likelihood residuals
"PearsonResiduals"Pearson residuals
"StandardizedDevianceResiduals"standardized deviance residuals
"StandardizedPearsonResiduals"standardized Pearson residuals
"WorkingResiduals"working residuals
  • Properties and diagnostics for parameter estimates include:
"CorrelationMatrix"asymptotic parameter correlation matrix
"CovarianceMatrix"asymptotic parameter covariance matrix
"ParameterConfidenceIntervals"parameter confidence intervals
"ParameterConfidenceIntervalTable"table of confidence interval information for the fitted parameters
"ParameterConfidenceIntervalTableEntries"unformatted array of values from the table
"ParameterConfidenceRegion"ellipsoidal parameter confidence region
"ParameterTableEntries"unformatted array of values from the table
"ParameterErrors"standard errors for parameter estimates
"ParameterPValues"p-values for parameter z-statistics
"ParameterTable"table of fitted parameter information
"ParameterZStatistics"z-statistics for parameter estimates
  • Properties related to influence measures include:
"CookDistances"list of Cook distances
"HatDiagonal"diagonal elements of the hat matrix
  • Properties of predicted values include:
"PredictedResponse"fitted values for the data
  • Properties that measure goodness of fit include:
"AdjustedLikelihoodRatioIndex"Ben-Akiva and Lerman's adjusted likelihood ratio index
"AIC"Akaike Information Criterion
"BIC"Bayesian Information Criterion
"CoxSnellPseudoRSquared"Cox and Snell's pseudo
"CraggUhlerPseudoRSquared"Cragg and Uhler's pseudo
"EfronPseudoRSquared"Efron's pseudo
"LikelihoodRatioIndex"McFadden's likelihood ratio index
"LikelihoodRatioStatistic"likelihood ratio
"LogLikelihood"log likelihood for the fitted model
"PearsonChiSquare"Pearson's statistic
  • In GeneralizedLinearModelFit, the design matrix m is formed from the values of basis functions at data points in the form . The response vector v is the list of responses .
  • For a design matrix m and response vector v, the model is where is the vector of parameters to be estimated.
Define a dataset:
Fit a log-linear Poisson model to the data:
See the functional forms of the model:
Evaluate the model at a point:
Plot the data points and the models:
Compute and plot the deviance residuals for the model:
Define a dataset:
In[1]:=
Click for copyable input
Fit a log-linear Poisson model to the data:
In[2]:=
Click for copyable input
Out[2]=
See the functional forms of the model:
In[3]:=
Click for copyable input
Out[3]=
Evaluate the model at a point:
In[4]:=
Click for copyable input
Out[4]=
Plot the data points and the models:
In[5]:=
Click for copyable input
Out[5]=
Compute and plot the deviance residuals for the model:
In[6]:=
Click for copyable input
Out[6]=
In[7]:=
Click for copyable input
Out[7]=
Fit a model of more than one variable:
Fit data to a linear combination of functions of predictor variables:
Fit a model with categorical predictor variables:
Obtain a deviance table for the model:
Fit a model given a design matrix and response vector:
See the functional form:
Fit the model referring to the basis functions as x and y:
Obtain a list of available properties for a generalized linear model:
Fit a generalized linear model:
Extract the original data:
Obtain and plot the best fit:
Obtain the fitted function as a pure function:
Get the design matrix and response vector for the fitting:
Examine residuals for a fit:
Visualize the raw residuals:
Visualize Anscombe residuals and standardized Pearson residuals in stem plots:
Fit a gamma regression model to some data:
Obtain the estimated dispersion:
Plot the deviances for each point:
Obtain the analysis of deviance table:
Get the residual deviances from the table:
Extract the numeric entries from the table:
Use Grid to add formatting:
Obtain a formatted table of parameter information:
Extract the column of -statistic values:
Get the unformatted array of values from the table:
Add formatting using Grid:
Add formatting via TableForm:
Fit some data containing extreme values to a logit model:
Check Cook distances to identify highly influential points:
Check the diagonal elements of the hat matrix to assess influence of points on the fitting:
Fit an inverse Gaussian model:
Plot the predicted values against the observed values:
Obtain a table of goodness-of-fit measures for a log-linear Poisson model:
Compute goodness-of-fit measures for all subsets of predictor variables:
Rank the models by AIC:
Perform other mathematical operations on the functional form of the model:
Integrate symbolically and numerically:
Find a predictor value that gives a particular value for the model:
The default gives 95% confidence intervals:
Use 99% intervals instead:
Set the level to 90% within FittedModel:
Fit a generalized linear model:
Compute the covariance matrix using the expected information matrix:
Use the observed information matrix instead:
Fit a binomial model:
Compute the covariance matrix:
Compute the covariance matrix estimating the dispersion by Pearson's :
Fit data to a simple linear regression model:
Fit to a canonical gamma regression model:
Fit to a canonical inverse Gaussian regression model:
Fit a simple linear regression model:
Fit the linear model with intercept zero:
Fit data to a canonical gamma regression model:
Fit data to a gamma regression model with a known Sqrt[x] term:
Fit a Poisson model with canonical Log link:
Use a named link:
Use a pure function for a shifted Sqrt link:
Fit the data treating the first variable as a nominal variable:
Treat both variables as nominal:
Fit a model using equal weights:
Give explicit weights for the data points:
Use WorkingPrecision to get higher precision in parameter estimates:
Obtain the fitted function:
Reduce the precision in property computations after the fitting:
Simulate some probability data:
Fit and visually compare binomial generalized linear models with a variety of link functions:
Fit count data from a contingency table to a Poisson log-linear model:
Display counts, predicted values, and standardized residuals in a tabular form:
DesignMatrix constructs the design matrix used by GeneralizedLinearModelFit:
By default, GeneralizedLinearModelFit and LinearModelFit fit equivalent models:
A default model is equivalent to the model for LogitModelFit:
ProbitModelFit is equivalent to a model with :
New in 7