statsmodels.gam.generalized_additive_model.GLMGam

class statsmodels.gam.generalized_additive_model.GLMGam(endog, exog=None, smoother=None, alpha=0, family=None, offset=None, exposure=None, missing='none', **kwargs)[source]

Generalized Additive Models (GAM)

This inherits from GLM.

Warning: Not all inherited methods might take correctly account of the penalization. Not all options including offset and exposure have been verified yet.

Parameters:
endogarray_like

The response variable.

exogarray_like or None

This explanatory variables are treated as linear. The model in this case is a partial linear model.

smootherinstance of additive smoother class

Examples of smoother instances include Bsplines or CyclicCubicSplines.

alphafloat or list of floats

Penalization weights for smooth terms. The length of the list needs to be the same as the number of smooth terms in the smoother.

familyinstance of GLM family

See GLM.

offsetNone or array_like

See GLM.

exposureNone or array_like

See GLM.

missing‘none’

Missing value handling is not supported in this class.

**kwargs

Extra keywords are used in call to the super classes.

Attributes:
endog_names

Names of endogenous variables.

exog_names

Names of exogenous variables.

Notes

Status: experimental. This has full unit test coverage for the core results with Gaussian and Poisson (without offset and exposure). Other options and additional results might not be correctly supported yet. (Binomial with counts, i.e. with n_trials, is most likely wrong in pirls. User specified var or freq weights are most likely also not correct for all results.)

Methods

estimate_scale(mu)

Estimate the dispersion/scale.

estimate_tweedie_power(mu[, method, low, high])

Tweedie specific function to estimate scale and the variance parameter.

fit([start_params, maxiter, method, tol, ...])

estimate parameters and create instance of GLMGamResults class

fit_constrained(constraints[, start_params])

fit the model subject to linear equality constraints

fit_regularized([method, alpha, ...])

Return a regularized fit to a linear regression model.

from_formula(formula, data[, subset, drop_cols])

Create a Model from a formula and dataframe.

get_distribution(params[, scale, exog, ...])

Return a instance of the predictive distribution.

hessian(params[, pen_weight])

Hessian of model at params

hessian_factor(params[, scale, observed])

Weights for calculating Hessian

hessian_numdiff(params[, pen_weight])

hessian based on finite difference derivative

information(params[, scale])

Fisher information matrix.

initialize()

Initialize a generalized linear model.

loglike(params[, pen_weight])

Log-likelihood of model at params

loglike_mu(mu[, scale])

Evaluate the log-likelihood for a generalized linear model.

loglikeobs(params[, pen_weight])

Log-likelihood of model observations at params

predict(params[, exog, exposure, offset, ...])

Return predicted values for a design matrix

score(params[, pen_weight])

Gradient of model at params

score_factor(params[, scale])

weights for score for each observation

score_numdiff(params[, pen_weight, method])

score based on finite difference derivative

score_obs(params[, pen_weight])

Gradient of model observations at params

score_test(params_constrained[, ...])

score test for restrictions or for omitted variables

select_penweight([criterion, start_params, ...])

find alpha by minimizing results criterion

select_penweight_kfold([alphas, ...])

find alphas by k-fold cross-validation

Properties

endog_names

Names of endogenous variables.

exog_names

Names of exogenous variables.


Last update: Oct 03, 2024