glmfit
Perform generalized linear model fitting.
b = glmfit (X, y, distribution)
returns a
coefficient estimates vector, b for a
generalized linear regression model of responses in y and
predictors in X, using the distribution.
b = glmfit (…, Name, Value)
specifies additional options using Name-Value
pair arguments.
Name | Value | |
---|---|---|
"link" | A character vector specifying a link function. | |
"constant" | Specifies whether to include a constant term in the model. Options are "on" (default) or "off". |
[b, dev] = glmfit (…)
returns the estimated coefficient vector, b, as well as
the deviance, dev, of the fit.
Supported distributions include ’poisson’, ’binomial’, and ’normal’. Supported link functions include ’identity’, ’log’, ’logit’, ’probit’, ’loglog’, ’comploglog’, ’reciprocal’ and a custom link. Custom link function provided as a structure with three fields: Link Function, Derivative Function, Inverse Function.
Source Code: glmfit
rand ("seed", 1); X = rand (100, 1); b_true = [0.5; -1.2]; mu = exp (b_true(1) + b_true(2) * X); randp ("seed", 1); y = poissrnd (mu); ## Fit a GLM model using the poisson distribution [b,dev] = glmfit (X, y, 'poisson'); |
x = [2100 2300 2500 2700 2900 3100 3300 3500 3700 3900 4100 4300]'; n = [48 42 31 34 31 21 23 23 21 16 17 21]'; y = [1 2 0 3 8 8 14 17 19 15 17 21]'; [b,dev] = glmfit (x,[y n],'binomial','Link','probit'); |