GeneralizedLinearModelFit: GLM—Wolfram Documentation (original) (raw)

BUILT-IN SYMBOL

GeneralizedLinearModelFit

GeneralizedLinearModelFit[{{x1,y1},{x2,y2},…},{f1,f2,…},x]

constructs a generalized linear model of the form that fits the yi for each xi.

GeneralizedLinearModelFit[data,{f1,f2,…},{x1,x2,…}]

constructs a generalized linear model of the form where the fi depend on the variables xk.

Details and Options

Properties

Examples

open allclose all

Basic Examples (1)

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:

Scope (15)

Data (8)

Fit data with success probability responses, assuming increasing integer-independent values:

This is equivalent to:

Fit a model of more than one variable:

Fit data to a linear combination of functions of predictor variables:

Fit a list of rules:

Fit a rule of input values and responses:

Specify a column as the response:

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:

Properties (7)

Data & Fitted Functions (1)

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:

Residuals (1)

Examine residuals for a fit:

Visualize the raw residuals:

Visualize Anscombe residuals and standardized Pearson residuals in stem plots:

Dispersion and Deviances (1)

Fit a gamma regression model to some data:

Obtain the estimated dispersion:

Plot the deviances for each point:

Get a dataset of the deviance table:

Get the residual deviances from the table:

Parameter Estimation Diagnostics (1)

Obtain a formatted table of parameter information:

Extract the column of z-statistic values:

Influence Measures (1)

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:

Prediction Values (1)

Fit an inverse Gaussian model:

Plot the predicted values against the observed values:

Goodness-of-Fit Measures (1)

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:

Generalizations & Extensions (1)

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:

Options (10)

ConfidenceLevel (1)

The default gives 95% confidence intervals:

Use 99% intervals instead:

Set the level to 90% within FittedModel:

CovarianceEstimatorFunction (1)

Fit a generalized linear model:

Compute the covariance matrix using the expected information matrix:

Use the observed information matrix instead:

DispersionEstimatorFunction (1)

Fit a binomial model:

Compute the covariance matrix:

Compute the covariance matrix estimating the dispersion by Pearson's :

ExponentialFamily (1)

Fit data to a simple linear regression model:

Fit to a canonical gamma regression model:

Fit to a canonical inverse Gaussian regression model:

IncludeConstantBasis (1)

Fit a simple linear regression model:

Fit the linear model with intercept zero:

LinearOffsetFunction (1)

Fit data to a canonical gamma regression model:

Fit data to a gamma regression model with a known Sqrt[x] term:

LinkFunction (1)

Fit a Poisson model with canonical Log link:

Use a named link:

Use a pure function for a shifted Sqrt link:

NominalVariables (1)

Fit the data treating the first variable as a nominal variable:

Treat both variables as nominal:

Weights (1)

Fit a model using equal weights:

Give explicit weights for the data points:

WorkingPrecision (1)

Use WorkingPrecision to get higher precision in parameter estimates:

Obtain the fitted function:

Reduce the precision in property computations after the fitting:

Applications (2)

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:

Properties & Relations (5)

Wolfram Research (2008), GeneralizedLinearModelFit, Wolfram Language function, https://reference.wolfram.com/language/ref/GeneralizedLinearModelFit.html (updated 2025).

Text

Wolfram Research (2008), GeneralizedLinearModelFit, Wolfram Language function, https://reference.wolfram.com/language/ref/GeneralizedLinearModelFit.html (updated 2025).

CMS

Wolfram Language. 2008. "GeneralizedLinearModelFit." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. https://reference.wolfram.com/language/ref/GeneralizedLinearModelFit.html.

APA

Wolfram Language. (2008). GeneralizedLinearModelFit. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GeneralizedLinearModelFit.html

BibTeX

@misc{reference.wolfram_2025_generalizedlinearmodelfit, author="Wolfram Research", title="{GeneralizedLinearModelFit}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/GeneralizedLinearModelFit.html}", note=[Accessed: 05-May-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_generalizedlinearmodelfit, organization={Wolfram Research}, title={GeneralizedLinearModelFit}, year={2025}, url={https://reference.wolfram.com/language/ref/GeneralizedLinearModelFit.html}, note=[Accessed: 05-May-2025 ]}