WOLFRAM

Enable JavaScript to interact with content and submit forms on Wolfram websites. Learn how
Wolfram Language & System Documentation Center

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.

GeneralizedLinearModelFit [{m,v}]

constructs a generalized linear model from the design matrix m and response vector v.

Details and Options
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Data  
Properties  
Data & Fitted Functions  
Residuals  
Dispersion and Deviances  
Parameter Estimation Diagnostics  
Influence Measures  
Prediction Values  
Goodness-of-Fit Measures  
Generalizations & Extensions  
Options  
ConfidenceLevel  
CovarianceEstimatorFunction  
DispersionEstimatorFunction  
Show More Show More
ExponentialFamily  
IncludeConstantBasis  
LinearOffsetFunction  
LinkFunction  
NominalVariables  
Weights  
WorkingPrecision  
Applications  
Properties & Relations  
See Also
Tech Notes
Related Guides
History
Cite this Page

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.

GeneralizedLinearModelFit [{m,v}]

constructs a generalized linear model from the design matrix m and response vector v.

Details and Options

  • GeneralizedLinearModelFit attempts to model the input data using a linear combination of functions transformed by a generic invertible function (link function).
  • 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.
  • The ExponentialFamily option controls the distribution while the LinkFunction option controls the form of .
  • 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 x1, can be found from model[x1,].
  • Data
  • Possible forms of data are:
  • {y1,y2,} equivalent to the form {{1,y1},{2,y2},}
    {{x11,x12,,y1},} a list of independent values xij and the responses yi
    {{x11,x12,}y1,} a list of rules between input values and response
    {{x11,x12,},}{y1,y2,} a rule between a list of input values and responses
    {{x11,,y1,},}n fit the n^(th) column of a matrix
    Tabular []name fit the column name in a tabular object
  • With multivariate data such as {{x_(11),x_(12),... ,y_(1)},{x_(21),x_(22),... ,y_(2)},...}, the number of coordinates xi1, xi2, should equal the number of variables xi.
  • Additionally, data can be specified using a design matrix without specifying functions and variables:
  • {m,v} a design matrix m and response vector v
  • In GeneralizedLinearModelFit [m,v], the design matrix m is formed from the values of basis functions fi at data points in the form {{f1,f2,},{f1,f2,},}. The response vector v is the list of responses {y1,y2,}.
  • 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 fi can be specified using the form GeneralizedLinearModelFit [{m,v},{f1,f2,}].
  • Options
  • 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 f[y,,w] where y={y1,y2,} is the list of observations, ={,,} is the list of predicted values, and w={w1,w2,} is the list of weights for the measurements yi.
  • Possible settings for ExponentialFamily include: "Gaussian", "Binomial", "Poisson", "Gamma", "InverseGaussian", or "QuasiLikelihood".
  • Properties
  • 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
    "Weights" weights used to fit the data
  • Properties related to dispersion and model deviances include:
  • "Deviances" deviances
    "DevianceData" deviance table dataset
    "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
    "ParameterEstimates" table of fitted parameter information
  • 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" BenAkiva 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
  • The property "BestFit" can also be called as {"prop",x} or {"prop",{x1,x2,}} to evaluate it at specific independent values.

Examples

open all close all

Basic Examples  (1)

Fit a log-linear Poisson model to data:

Wolfram Language code: glm = GeneralizedLinearModelFit[{...}, x, x, ExponentialFamily -> "Poisson"]

See the functional form of the model as an expression:

Wolfram Language code: Normal[glm]

Evaluate the model at a point:

Wolfram Language code: glm[1.5]

Plot the data points and the models:

Wolfram Language code: Show[ListPlot[glm["Data"]], Plot[glm[x], {x, 0, 8}]]

Scope  (15)

Data  (8)

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

Wolfram Language code: GeneralizedLinearModelFit[{0, 1, 2, 3, 5, 5}, x, x]

This is equivalent to:

Wolfram Language code: GeneralizedLinearModelFit[{{1, 0}, {2, 1}, {3, 2}, {4, 3}, {5, 5}, {6, 5}}, x, x]

Fit a model of more than one variable:

Wolfram Language code: data = Flatten[Table[{x, y, 1 / (x + y + RandomReal[])}, {x, 5}, {y, 5}], 1];
Wolfram Language code: GeneralizedLinearModelFit[data, {x, y}, {x, y}, ExponentialFamily -> "Gamma"]
Wolfram Language code: Normal[%]

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

Wolfram Language code: GeneralizedLinearModelFit[data, {Sin[x], Cos[y]}, {x, y}, ExponentialFamily -> "Gamma"]//Normal

Fit a list of rules:

Wolfram Language code: GeneralizedLinearModelFit[{.5 -> 1, 1 -> 0, 3 -> 2, 5 -> 3, 8 -> 20}, x, x]

Fit a rule of input values and responses:

Wolfram Language code: GeneralizedLinearModelFit[{.5, 1, 3, 5, 8} -> {1, 0, 2, 3, 20}, x, x]

Specify a column as the response:

Wolfram Language code: GeneralizedLinearModelFit[(⁠| | | | -- | --- | | 1 | 0.5 | | 0 | 1 | | 2 | 3 | | 3 | 5 | | 20 | 8 |⁠) -> 1, x, x]

Fit a model with categorical predictor variables:

Wolfram Language code: data = {{a, 1}, {b, 2}, {a, 1.8}, {b, 2.5}};
Wolfram Language code: nom = GeneralizedLinearModelFit[data, x, x, NominalVariables -> x, ExponentialFamily -> "InverseGaussian"]

Obtain a deviance table for the model:

Wolfram Language code: nom["DevianceData"]

Fit a model given a design matrix and response vector:

Wolfram Language code: dm = {{1, 1}, {1, 2}, {1, 3}, {1, 4}}; resp = {1, 3, 6, 10};
Wolfram Language code: GeneralizedLinearModelFit[{dm, resp}, ExponentialFamily -> "Poisson"]

See the functional form:

Wolfram Language code: Normal[%]

Fit the model referring to the basis functions as x and y:

Wolfram Language code: GeneralizedLinearModelFit[{dm, resp}, {x, y}, ExponentialFamily -> "Poisson"]//Normal

Obtain a list of available properties for a generalized linear model:

Wolfram Language code: glm = GeneralizedLinearModelFit[Range[10], x ^ 2, x, ExponentialFamily -> "Gamma"]
Wolfram Language code: glm["Properties"]

Properties  (7)

Data & Fitted Functions  (1)

Fit a generalized linear model:

Wolfram Language code: data = Block[{i, j}, Table[{i = RandomReal[{1, 5}], j = RandomReal[{1, 5}], RandomReal[InverseGaussianDistribution[1 / Sqrt[5i + 2j], 10]]}, {10}]];
Wolfram Language code: glm = GeneralizedLinearModelFit[data, {x, y}, {x, y}, ExponentialFamily -> "InverseGaussian"]

Extract the original data:

Wolfram Language code: glm["Data"]

Obtain and plot the best fit:

Wolfram Language code: {fit = glm["BestFit"], Show[Plot3D[fit, {x, 1, 5}, {y, 1, 5}], Graphics3D[{PointSize[0.025], Point[glm["Data"]]}]]}

Obtain the fitted function as a pure function:

Wolfram Language code: glm["Function"]

Get the design matrix and response vector for the fitting:

Wolfram Language code: MatrixForm /@ glm[{"DesignMatrix", "Response"}]

Residuals  (1)

Examine residuals for a fit:

Wolfram Language code: SeedRandom[1]; glm = GeneralizedLinearModelFit[RandomReal[10, {100, 3}], {x, y}, {x, y}, ExponentialFamily -> "Gamma"]
Wolfram Language code: {fr, ar, spr} = glm[{"FitResiduals", "StandardizedPearsonResiduals", "AnscombeResiduals"}];

Visualize the raw residuals:

Wolfram Language code: ListPlot[fr]

Visualize Anscombe residuals and standardized Pearson residuals in stem plots:

Wolfram Language code: Map[ListPlot[#, Filling -> 0]&, {ar, spr}]//Row

Dispersion and Deviances  (1)

Fit a gamma regression model to some data:

Wolfram Language code: SeedRandom[1]; data = Flatten[Table[{x, y, 1 / (1.2 + 3.7x + 4.1y + RandomReal[{-2, 2}])}, {x, RandomReal[{1, 5}, 10]}, {y, RandomReal[{1, 5}, 10]}], 1];glm = GeneralizedLinearModelFit[data, {x, y}, {x, y}, ExponentialFamily -> "Gamma"]

Obtain the estimated dispersion:

Wolfram Language code: glm["EstimatedDispersion"]

Plot the deviances for each point:

Wolfram Language code: ListPlot[glm["Deviances"], Filling -> 0]

Get a dataset of the deviance table:

Wolfram Language code: glm["DevianceData"]

Get the residual deviances from the table:

Wolfram Language code: glm["DevianceData"][All, "ResidualDeviance"]//Normal

Parameter Estimation Diagnostics  (1)

Obtain a formatted table of parameter information:

Wolfram Language code: SeedRandom[1]; data = Table[{i, RandomInteger[BinomialDistribution[20, .05 + i / 30 + Sin[i] / 10]] / 20}, {i, 1, 20, .2}]; glm = GeneralizedLinearModelFit[data, {x, Sin[x], Cos[x]}, x, ExponentialFamily -> "Binomial"];
Wolfram Language code: glm["ParameterEstimates"]

Extract the column of z-statistic values:

Wolfram Language code: glm["ParameterEstimates"][All, "ZStatistic"]//Normal

Influence Measures  (1)

Fit some data containing extreme values to a logit model:

Wolfram Language code: data = Table[{i, 1 / (1 + Exp[2 + 4i - Log[i] + RandomReal[]])}, {i, RandomReal[{1, 10}, 20]}]; data[[{3, 8}, -1]] = 1 - data[[{3, 8}, -1]]; glm = GeneralizedLinearModelFit[data, {x, Log[x]}, x, ExponentialFamily -> "Binomial"]

Check Cook distances to identify highly influential points:

Wolfram Language code: ListPlot[glm["CookDistances"], PlotRange -> {0, All}, Filling -> 0]

Check the diagonal elements of the hat matrix to assess influence of points on the fitting:

Wolfram Language code: ListPlot[glm["HatDiagonal"], PlotRange -> {0, All}, Filling -> 0]

Prediction Values  (1)

Fit an inverse Gaussian model:

Wolfram Language code: data = Flatten[Table[{x, y, 1 / Sqrt[1 + .3x + .5y + RandomReal[]]}, {x, RandomReal[5, 3]}, {y, RandomReal[5, 3]}], 1];glm = GeneralizedLinearModelFit[data, {x, y}, {x, y}, ExponentialFamily -> "InverseGaussian"]

Plot the predicted values against the observed values:

Wolfram Language code: ListPlot[Transpose[glm[{"Response", "PredictedResponse"}]], FrameLabel -> {"observed", "predicted"}, Frame -> True, Axes -> False]

Goodness-of-Fit Measures  (1)

Obtain a table of goodness-of-fit measures for a log-linear Poisson model:

Wolfram Language code: data = Flatten[Table[{i, j, RandomReal[5], RandomInteger[PoissonDistribution[Exp[-.3i - 2j]]]}, {i, RandomReal[5, 5]}, {j, RandomReal[5, 5]}], 1];
Wolfram Language code: glm = GeneralizedLinearModelFit[data, {x, y, z}, {x, y, z}, ExponentialFamily -> "Poisson"]
Wolfram Language code: Grid[Transpose[{#, glm[#]}&[{"AIC", "BIC", "LikelihoodRatioIndex", "PearsonChiSquare"}]], Alignment -> Left]

Compute goodness-of-fit measures for all subsets of predictor variables:

Wolfram Language code: sub = Table[Join[{i}, GeneralizedLinearModelFit[data, i, {x, y, z}, ExponentialFamily -> "Poisson"][{"AIC", "BIC", "LikelihoodRatioIndex", "PearsonChiSquare"}]], {i, Subsets[{x, y, z}]}]

Rank the models by AIC:

Wolfram Language code: Grid[Join[{{"Model", "AIC", "BIC", "LikelihoodRatioIndex", "PearsonChiSquare"}}, SortBy[sub, -#[[2]]&]]]

Generalizations & Extensions  (1)

Perform other mathematical operations on the functional form of the model:

Wolfram Language code: data = Table[{i, 1 / Sqrt[RandomReal[{i - 1, i}]]}, {i, 10}]; glm = GeneralizedLinearModelFit[data, x, x, ExponentialFamily -> "InverseGaussian"]

Integrate symbolically and numerically:

Wolfram Language code: Integrate[glm[x], x]
Wolfram Language code: NIntegrate[glm[x], {x, 1, 5}]

Find a predictor value that gives a particular value for the model:

Wolfram Language code: FindRoot[glm[x] == .5, {x, 5}]

Options  (10)

ConfidenceLevel  (1)

The default gives 95% confidence intervals:

Wolfram Language code: data = {{0, 1}, {1, 1.5}, {3, 2}, {5, 4}};
Wolfram Language code: glm = GeneralizedLinearModelFit[data, x, x, ExponentialFamily -> "InverseGaussian"]
Wolfram Language code: glm["ParameterEstimates"][All, "ConfidenceInterval"]//Normal

Use 99% intervals instead:

Wolfram Language code: glm = GeneralizedLinearModelFit[data, x, x, ExponentialFamily -> "InverseGaussian", ConfidenceLevel -> .99]
Wolfram Language code: glm["ParameterEstimates"][All, "ConfidenceInterval"]//Normal

Set the level to 90% within FittedModel :

Wolfram Language code: glm["ParameterEstimates", ConfidenceLevel -> .9][All, "ConfidenceInterval"]//Normal

CovarianceEstimatorFunction  (1)

Fit a generalized linear model:

Wolfram Language code: data = {{0, 1}, {1, 1.5}, {3, 2}, {5, 4}};
Wolfram Language code: glm = GeneralizedLinearModelFit[data, x, x, ExponentialFamily -> "InverseGaussian"]

Compute the covariance matrix using the expected information matrix:

Wolfram Language code: glm["CovarianceMatrix"]

Use the observed information matrix instead:

Wolfram Language code: glm["CovarianceMatrix", CovarianceEstimatorFunction -> "ObservedInformation"]

DispersionEstimatorFunction  (1)

Fit a binomial model:

Wolfram Language code: data = {{1, 0}, {1, 1}, {1, 1}, {2, 0}, {2, 0}, {2, 1}, {2, 1}, {2, 1}, {2, 1}};
Wolfram Language code: logit = GeneralizedLinearModelFit[data, x, x, ExponentialFamily -> "Binomial"]

Compute the covariance matrix:

Wolfram Language code: logit["CovarianceMatrix"]

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

Wolfram Language code: logit["CovarianceMatrix", DispersionEstimatorFunction -> "PearsonChiSquare"]

ExponentialFamily  (1)

Wolfram Language code: data = {{0, 1}, {1, 1.5}, {3, 2}, {5, 4}};

Fit data to a simple linear regression model:

Wolfram Language code: GeneralizedLinearModelFit[data, x, x]//Normal

Fit to a canonical gamma regression model:

Wolfram Language code: GeneralizedLinearModelFit[data, x, x, ExponentialFamily -> "Gamma"]//Normal

Fit to a canonical inverse Gaussian regression model:

Wolfram Language code: GeneralizedLinearModelFit[data, x, x, ExponentialFamily -> "InverseGaussian"]//Normal

IncludeConstantBasis  (1)

Fit a simple linear regression model:

Wolfram Language code: data = {{0, 1}, {1, 0}, {3, 2}, {5, 4}};
Wolfram Language code: GeneralizedLinearModelFit[data, x, x]

Fit the linear model with intercept zero:

Wolfram Language code: GeneralizedLinearModelFit[data, x, x, IncludeConstantBasis -> False]

LinearOffsetFunction  (1)

Fit data to a canonical gamma regression model:

Wolfram Language code: data = {{0, 1}, {1, 1.5}, {3, 2}, {5, 4}};
Wolfram Language code: GeneralizedLinearModelFit[data, x, x, ExponentialFamily -> "Gamma"]//Normal

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

Wolfram Language code: GeneralizedLinearModelFit[data, x, x, ExponentialFamily -> "Gamma", LinearOffsetFunction -> (Sqrt[#]&)]//Normal

LinkFunction  (1)

Wolfram Language code: data = {{0, 1}, {1, 0}, {3, 2}, {5, 4}};

Fit a Poisson model with canonical Log link:

Wolfram Language code: GeneralizedLinearModelFit[data, x, x, ExponentialFamily -> "Poisson"]//Normal

Use a named link:

Wolfram Language code: GeneralizedLinearModelFit[data, x, x, ExponentialFamily -> "Poisson", LinkFunction -> "IdentityLink"]//Normal

Use a pure function for a shifted Sqrt link:

Wolfram Language code: GeneralizedLinearModelFit[data, x, x, ExponentialFamily -> "Poisson", LinkFunction -> (Sqrt[#1 + 1]&)]//Normal

NominalVariables  (1)

Wolfram Language code: data = {{a, 0, 1}, {b, 2, 2}, {a, 2, 1.8}, {b, 0, 2.5}};

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

Wolfram Language code: nom = GeneralizedLinearModelFit[data, {x, y}, {x, y}, NominalVariables -> x, ExponentialFamily -> "Gamma"]
Wolfram Language code: Normal[nom]

Treat both variables as nominal:

Wolfram Language code: GeneralizedLinearModelFit[data, {x, y}, {x, y}, NominalVariables -> All, ExponentialFamily -> "Gamma"]//Normal

Weights  (1)

Fit a model using equal weights:

Wolfram Language code: GeneralizedLinearModelFit[Range[10] ^ 2, x, x]//Normal

Give explicit weights for the data points:

Wolfram Language code: GeneralizedLinearModelFit[Range[10] ^ 2, x, x, Weights -> 1 / Range[10]]//Normal

WorkingPrecision  (1)

Use WorkingPrecision to get higher precision in parameter estimates:

Wolfram Language code: data = Table[{x, 1 / (x + x ^ 2)}, {x, 10}]
Wolfram Language code: glm = GeneralizedLinearModelFit[data, x, x, ExponentialFamily -> "Gamma", WorkingPrecision -> 25]

Obtain the fitted function:

Wolfram Language code: glm["BestFit"]

Reduce the precision in property computations after the fitting:

Wolfram Language code: glm["BestFit", WorkingPrecision -> MachinePrecision]

Applications  (2)

Simulate some probability data:

Wolfram Language code: data = BlockRandom[SeedRandom[1];RandomReal[{.8, 1}, 20]Table[(x - 1) / (1 + x), {x, 20}]];

Fit and visually compare binomial generalized linear models with a variety of link functions:

Wolfram Language code: models = Map[Tooltip[Normal[GeneralizedLinearModelFit[data, {x, x ^ 2}, x, ExponentialFamily -> "Binomial", LinkFunction -> #]]]&, {"LogitLink", "ProbitLink", "LogLogLink", "LogComplementLink", "ComplementaryLogLogLink", "OddsPowerLink"}];
Wolfram Language code: Show[ListPlot[data, PlotRange -> All], Plot[models, {x, 1, 20}]]

Fit count data from a contingency table to a Poisson log-linear model:

Wolfram Language code: data = {{groupA, agree, 15}, {groupA, disagree, 66}, {groupB, agree, 63}, {groupB, disagree, 90}, {groupC, agree, 92}, {groupC, disagree, 46}};
Wolfram Language code: model = GeneralizedLinearModelFit[data, {var1, var2}, {var1, var2}, NominalVariables -> All, ExponentialFamily -> "Poisson"];

Display counts, predicted values, and standardized residuals in a tabular form:

Wolfram Language code: Style[Grid[Join[{{"", "Agree", "Disagree"}}, Join[{{"Group A"}, {"Group B"}, {"Group C"}}, Partition[Map[Column[#, Alignment -> "."]&, Transpose[model[{"Response", "PredictedResponse", "StandardizedPearsonResiduals"}]]], 2], 2]], Dividers -> All], "DialogStyle"]

Properties & Relations  (5)

DesignMatrix constructs the design matrix used by GeneralizedLinearModelFit :

Wolfram Language code: data = Table[{i, RandomReal[]}, {i, 5}]
Wolfram Language code: DesignMatrix[data, x, x]//MatrixForm
Wolfram Language code: glm = GeneralizedLinearModelFit[data, x, x];
Wolfram Language code: glm["DesignMatrix"]//MatrixForm

By default, GeneralizedLinearModelFit and LinearModelFit fit equivalent models:

Wolfram Language code: data = Table[{i, RandomReal[{i - 1, i}]}, {i, 10}];
Wolfram Language code: GeneralizedLinearModelFit[data, x, x]
Wolfram Language code: LinearModelFit[data, x, x]

A default "Binomial" model is equivalent to the model for LogitModelFit :

Wolfram Language code: data = Table[{i, RandomReal[{i - 1, i}] / 10}, {i, 10}];
Wolfram Language code: GeneralizedLinearModelFit[data, x, x, ExponentialFamily -> "Binomial"]//Normal
Wolfram Language code: LogitModelFit[data, x, x]//Normal

ProbitModelFit is equivalent to a "Binomial" model with "ProbitLink":

Wolfram Language code: GeneralizedLinearModelFit[data, x, x, ExponentialFamily -> "Binomial", LinkFunction -> "ProbitLink"]//Normal
Wolfram Language code: ProbitModelFit[data, x, x]//Normal

GeneralizedLinearModelFit will use the time stamps of a TimeSeries as variables:

Wolfram Language code: ts1 = TemporalData[TimeSeries, {{{1.102448341846048, 6.331833897009389, 7.5843632999043455, 44.59969789743589, 98.76273258351092, 150.00729051003992, 644.7367359379259, 1724.3968817536402, 5903.697723461762, 19468.09340765025}}, {{0, 9, 1}}, 1, {"Continuous", 1}, {"Discrete", 1}, 1, {ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, False, 10.1];
Wolfram Language code: ts1["Times"]
Wolfram Language code: GeneralizedLinearModelFit[ts1, x, x, ExponentialFamily -> "Gamma"]

Rescale the time stamps and fit again:

Wolfram Language code: ts2 = TimeSeriesRescale[ts1, {.1, 2}]
Wolfram Language code: ts2["Times"]
Wolfram Language code: GeneralizedLinearModelFit[ts2, x, x, ExponentialFamily -> "Gamma"]

Find fit for the values:

Wolfram Language code: GeneralizedLinearModelFit[ts1["Values"], x, x, ExponentialFamily -> "Gamma"]

GeneralizedLinearModelFit acts pathwise on a multipath TemporalData :

Wolfram Language code: GeneralizedLinearModelFit[TemporalData[Automatic, {{{1.102448341846048, 6.331833897009389, 7.5843632999043455, 44.59969789743589, 98.76273258351092, 150.00729051003992, 644.7367359379259, 1724.3968817536402, 5903.697723461762, 19468.09340765025}, {1.1024483418 ... 7359379259, 1724.3968817536402, 5903.697723461762, 19468.09340765025}}, {{0, 9, 1}, {0.1, 2., 0.2111111111111111}}, 2, {"Continuous", 2}, {"Discrete", 2}, 1, {ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, False, 10.1], x, x, ExponentialFamily -> "Gamma"]
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_2026_generalizedlinearmodelfit, author="Wolfram Research", title="{GeneralizedLinearModelFit}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/GeneralizedLinearModelFit.html}", note=[Accessed: 13-August-2026]}

BibLaTeX

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

Top [フレーム]

AltStyle によって変換されたページ (->オリジナル) /