|
SOLUTIONS
|
Mathematica
>
Data Manipulation
>
Numerical Data
>
Statistical Model Analysis
>
GeneralizedLinearModelFit
BUILT-IN MATHEMATICA SYMBOL
GeneralizedLinearModelFit
GeneralizedLinearModelFit[{y1, y2, ...}, {f1, f2, ...}, x]
constructs a generalized linear model of the form
that fits the
for successive x values 1, 2, ....
GeneralizedLinearModelFit[{{x11, x12, ..., y1}, {x21, x22, ..., y2}, ...}, {f1, f2, ...}, {x1, x2, ...}]
constructs a generalized linear model of the form
where the
depend on the variables
.
GeneralizedLinearModelFit[{m, v}]
constructs a generalized linear model from the design matrix m and response vector v.
Details and OptionsDetails and Options
- 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"].
- The value of the best-fit function from GeneralizedLinearModelFit at a particular point
, ... can be found from
. - 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. - GeneralizedLinearModelFit takes the following options:
-
AccuracyGoal Automatic the accuracy sought ConfidenceLevel 95/100 confidence level for parameters and predictions CovarianceEstimatorFunction "ExpectedInformation" estimation method for the parameter covariance matrix DispersionEstimatorFunction Automatic function for estimating the dispersion parameter ExponentialFamily Automatic exponential family distribution for y IncludeConstantBasis True whether to include a constant basis function LinearOffsetFunction None known offset in the linear predictor LinkFunction Automatic link function for the model MaxIterations Automatic maximum number of iterations to use NominalVariables None variables considered as nominal PrecisionGoal Automatic the precision sought Weights Automatic weights for data elements WorkingPrecision Automatic the precision for internal computations - With the setting IncludeConstantBasis->False, a model of the form
is fitted. - With the setting LinearOffsetFunction->h, a model of the form
is fitted. - With ConfidenceLevel->p, 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
. - Possible settings for ExponentialFamily include:
,
,
,
,
, or
. - 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 deviance for the fitted model and the deviance for the full model "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[m, v], 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. - When a design matrix is used, the basis functions
can be specified using the form GeneralizedLinearModelFit[{m, v}, {f1, f2, ...}].
ExamplesExamplesopen allclose all
Basic Examples (1)Basic Examples (1)
| In[1]:= |
Fit a log-linear Poisson model to the data:
| In[2]:= |
| Out[2]= |
See the functional forms of the model:
| In[3]:= |
| Out[3]= |
Evaluate the model at a point:
| In[4]:= |
| Out[4]= |
Plot the data points and the models:
| In[5]:= |
| Out[5]= | ![]() |
Compute and plot the deviance residuals for the model:
| In[6]:= |
| Out[6]= |
| In[7]:= |
| Out[7]= | ![]() |
New in 7
Mathematica 9 is now available!
New to Mathematica?
Find your learning path »
Have a question?
Ask support »


