Note: This version has never been officially released. Several models have been refactored, improved or bugfixed in 0.8.
The following major new features appear in this version.
Author: Kevin Sheppard
A new class-based Principal Component Analysis has been added. This class replaces the function-based PCA that previously existed in the sandbox. This change bring a number of new features, including:
import statsmodels.api as sm
from statsmodels.tools.pca import PCA
data = sm.datasets.fertility.load_pandas().data
columns = map(str, range(1960, 2012))
data.set_index('Country Name', inplace=True)
dta = data[columns]
dta = dta.dropna()
pca_model = PCA(dta.T, standardize=False, demean=True)
pca_model.plot_scree()
Note : A function version is also available which is compatible with the call in the sandbox. The function version is just a thin wrapper around the class-based PCA implementation.
Author: Kerby Shedden
Added variable plots, partial residual plots, and CERES residual plots are available for GLM and GEE models by calling the methods plot_added_variable, plot_partial_residuals, and plot_ceres_residuals that are attached to the results classes.
Author: Chad Fulton
State space methods provide a flexible structure for the estimation and analysis of a wide class of time series models. The Statsmodels implementation allows specification of state models, fast Kalman filtering, and built-in methods to facilitate maximum likelihood estimation of arbitrary models. One of the primary goals of this module is to allow end users to create and estimate their own models. Below is a short example demonstrating the ease with which a local level model can be specified and estimated:
import numpy as np
import statsmodels.api as sm
import pandas as pd
data = sm.datasets.nile.load_pandas().data
data.index = pd.DatetimeIndex(data.year.astype(int).astype(str), freq='AS')
# Setup the state space representation
class LocalLevel(sm.tsa.statespace.MLEModel):
def __init__(self, endog):
# Initialize the state space model
super(LocalLevel, self).__init__(
endog, k_states=1, initialization='approximate_diffuse')
# Setup known components of state space representation matrices
self.ssm['design', :] = 1.
self.ssm['transition', :] = 1.
self.ssm['selection', :] = 1.
# Describe how parameters enter the model
def update(self, params, transformed=True):
params = super(LocalLevel, self).update(params, transformed)
self.ssm['obs_cov', 0, 0] = params[0]
self.ssm['state_cov', 0, 0] = params[1]
def transform_params(self, params):
return params**2 # force variance parameters to be positive
# Specify start parameters and parameter names
@property
def start_params(self):
return [np.std(self.endog)]*2
@property
def param_names(self):
return ['sigma2.measurement', 'sigma2.level']
# Fit the model with maximum likelihood estimation
mod = LocalLevel(data['volume'])
res = mod.fit()
print res.summary()
The documentation and example notebooks provide further examples of how to form state space models. Included in this release is a full-fledged model making use of the state space infrastructure to estimate SARIMAX models. See below for more details.
Author: Chad Fulton
A model for estimating seasonal autoregressive integrated moving average models with exogenous regressors (SARIMAX) has been added by taking advantage of the new state space functionality. It can be used very similarly to the existing ARIMA model, but works on a wider range of specifications, including:
Below is a short example fitting a model with a number of these components, including exogenous data, a linear trend, and annual multiplicative seasonal effects.
import statsmodels.api as sm
import pandas as pd
data = sm.datasets.macrodata.load_pandas().data
data.index = pd.DatetimeIndex(start='1959-01-01', end='2009-09-01',
freq='QS')
endog = data['realcons']
exog = data['m1']
mod = sm.tsa.SARIMAX(endog, exog=exog, order=(1,1,1),
trend='t', seasonal_order=(0,0,1,4))
res = mod.fit()
print res.summary()
Author: Kerby Shedden
Enhancements and performance improvements for GEE:
Author: Kerby Shedden with Saket Choudhary
Enhancements to MixedLM (#2363): added variance components support for MixedLM allowing a wider range of random effects structures to be specified; also performance improvements from use of sparse matrices internally for random effects design matrices.
Thanks to all of the contributors for the 0.7 release:
Note
These lists of names are automatically generated based on git log, and may not be complete.