GLM.from_formula()

statsmodels.genmod.generalized_linear_model.GLM.from_formula classmethod GLM.from_formula(formula, data, subset=None, *args, **kwargs) Create a Model from a formula and dataframe. Parameters: formula : str or generic Formula object The formula specifying the model data : array-like The data for the model. See Notes. subset : array-like An array-like object of booleans, integers, or index values that indicate the subset of df to use in the model. Assumes df is a pandas.DataFrame args :

GLM.fit_constrained()

statsmodels.genmod.generalized_linear_model.GLM.fit_constrained GLM.fit_constrained(constraints, start_params=None, **fit_kwds) [source] fit the model subject to linear equality constraints The constraints are of the form R params = q where R is the constraint_matrix and q is the vector of constraint_values. The estimation creates a new model with transformed design matrix, exog, and converts the results back to the original parameterization. Parameters: constraints : formula expression or

GLM.fit()

statsmodels.genmod.generalized_linear_model.GLM.fit GLM.fit(start_params=None, maxiter=100, method='IRLS', tol=1e-08, scale=None, cov_type='nonrobust', cov_kwds=None, use_t=None, **kwargs) [source] Fits a generalized linear model for a given family. Parameters: maxiter : int, optional Default is 100. method : string Default is ?IRLS? for iteratively reweighted least squares. This is currently the only method available for GLM fit. scale : string or float, optional scale can be ?X2?, ?d

GLM.estimate_scale()

statsmodels.genmod.generalized_linear_model.GLM.estimate_scale GLM.estimate_scale(mu) [source] Estimates the dispersion/scale. Type of scale can be chose in the fit method. Parameters: mu : array mu is the mean response estimate Returns: Estimate of scale : See also statsmodels.glm.fit Notes The default scale for Binomial and Poisson families is 1. The default for the other families is Pearson?s Chi-Square estimate.

Getting started

Getting started This very simple case-study is designed to get you up-and-running quickly with statsmodels. Starting from raw data, we will show the steps needed to estimate a statistical model and to draw a diagnostic plot. We will only use functions provided by statsmodels or its pandas and patsy dependencies. Loading modules and functions After installing statsmodels and its dependencies, we load a few modules and functions: In [1]: import statsmodels.api as sm In [2]: import pandas In [3

genmod.generalized_linear_model.GLMResults()

statsmodels.genmod.generalized_linear_model.GLMResults class statsmodels.genmod.generalized_linear_model.GLMResults(model, params, normalized_cov_params, scale, cov_type='nonrobust', cov_kwds=None, use_t=None) [source] Class to contain GLM results. GLMResults inherits from statsmodels.LikelihoodModelResults Parameters: See statsmodels.LikelihoodModelReesults : Returns: **Attributes** : aic : float Akaike Information Criterion -2 * llf + 2*(df_model + 1) bic : float Bayes Information Cr

genmod.generalized_linear_model.GLM()

statsmodels.genmod.generalized_linear_model.GLM class statsmodels.genmod.generalized_linear_model.GLM(endog, exog, family=None, offset=None, exposure=None, missing='none', **kwargs) [source] Generalized Linear Models class GLM inherits from statsmodels.base.model.LikelihoodModel Parameters: endog : array-like 1d array of endogenous response variable. This array can be 1d or 2d. Binomial family models accept a 2d array with two columns. If supplied, each observation is expected to be [succe

genmod.generalized_estimating_equations.GEEResults()

statsmodels.genmod.generalized_estimating_equations.GEEResults class statsmodels.genmod.generalized_estimating_equations.GEEResults(model, params, cov_params, scale, cov_type='robust', use_t=False, **kwds) [source] This class summarizes the fit of a marginal regression model using GEE. Returns: **Attributes** : cov_params_default : ndarray default covariance of the parameter estimates. Is chosen among one of the following three based on cov_type cov_robust : ndarray covariance of the par

genmod.generalized_estimating_equations.GEEMargins()

statsmodels.genmod.generalized_estimating_equations.GEEMargins class statsmodels.genmod.generalized_estimating_equations.GEEMargins(results, args, kwargs={}) [source] Estimate the marginal effects of a model fit using generalized estimating equations. Parameters: results : GEEResults instance The results instance of a fitted discrete choice model args : tuple Args are passed to get_margeff. This is the same as results.get_margeff. See there for more information. kwargs : dict Keyword a

genmod.generalized_estimating_equations.GEE()

statsmodels.genmod.generalized_estimating_equations.GEE class statsmodels.genmod.generalized_estimating_equations.GEE(endog, exog, groups, time=None, family=None, cov_struct=None, missing='none', offset=None, exposure=None, dep_data=None, constraint=None, update_dep=True, **kwargs) [source] Estimation of marginal regression models using Generalized Estimating Equations (GEE). GEE can be used to fit Generalized Linear Models (GLMs) when the data have a grouped structure, and the observations