ANOVA

Analysis of Variance models

Examples

In [1]: import statsmodels.api as sm
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-6030a6549dc0> in <module>()
----> 1 import statsmodels.api as sm

/builddir/build/BUILD/statsmodels-0.6.1/statsmodels/api.py in <module>()
     13 from .discrete.discrete_model import (Poisson, Logit, Probit,
     14                                       MNLogit, NegativeBinomial)
---> 15 from .tsa import api as tsa
     16 from .duration.hazard_regression import PHReg
     17 from .nonparametric import api as nonparametric

/builddir/build/BUILD/statsmodels-0.6.1/statsmodels/tsa/api.py in <module>()
----> 1 from .ar_model import AR
      2 from .arima_model import ARMA, ARIMA
      3 from . import vector_ar as var
      4 from .arima_process import arma_generate_sample, ArmaProcess
      5 from .vector_ar.var_model import VAR

/builddir/build/BUILD/statsmodels-0.6.1/statsmodels/tsa/ar_model.py in <module>()
     14                                           cache_readonly, cache_writable)
     15 from statsmodels.tools.numdiff import approx_fprime, approx_hess
---> 16 from statsmodels.tsa.kalmanf.kalmanfilter import KalmanFilter
     17 import statsmodels.base.wrapper as wrap
     18 from statsmodels.tsa.vector_ar import util

/builddir/build/BUILD/statsmodels-0.6.1/statsmodels/tsa/kalmanf/__init__.py in <module>()
----> 1 from .kalmanfilter import KalmanFilter

/builddir/build/BUILD/statsmodels-0.6.1/statsmodels/tsa/kalmanf/kalmanfilter.py in <module>()
     31 from numpy.linalg import inv, pinv
     32 from statsmodels.tools.tools import chain_dot
---> 33 from . import kalman_loglike
     34 
     35 #Fast filtering and smoothing for multivariate state space models

ImportError: cannot import name kalman_loglike

In [2]: from statsmodels.formula.api import ols

In [3]: moore = sm.datasets.get_rdataset("Moore", "car",
   ...:                                  cache=True) # load data
   ...: 
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-3-924d52d36060> in <module>()
----> 1 moore = sm.datasets.get_rdataset("Moore", "car",
      2                                  cache=True) # load data

NameError: name 'sm' is not defined

In [4]: data = moore.data
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-4-07b15baaa84d> in <module>()
----> 1 data = moore.data

NameError: name 'moore' is not defined

In [5]: data = data.rename(columns={"partner.status" :
   ...:                             "partner_status"}) # make name pythonic
   ...: 
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-5-aaf036e8c484> in <module>()
----> 1 data = data.rename(columns={"partner.status" :
      2                             "partner_status"}) # make name pythonic
      3 

NameError: name 'data' is not defined

In [6]: moore_lm = ols('conformity ~ C(fcategory, Sum)*C(partner_status, Sum)',
   ...:                 data=data).fit()
   ...: 
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-6-0a291eef3047> in <module>()
      1 moore_lm = ols('conformity ~ C(fcategory, Sum)*C(partner_status, Sum)',
----> 2                 data=data).fit()

NameError: name 'data' is not defined

In [7]: table = sm.stats.anova_lm(moore_lm, typ=2) # Type 2 ANOVA DataFrame
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-7-4e32df33effd> in <module>()
----> 1 table = sm.stats.anova_lm(moore_lm, typ=2) # Type 2 ANOVA DataFrame

NameError: name 'sm' is not defined

In [8]: print table
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-8-97e179e9235e> in <module>()
----> 1 print table

NameError: name 'table' is not defined

A more detailed example can be found here:

Module Reference

anova_lm(\*args, \*\*kwargs) ANOVA table for one or more fitted linear models.