Logo

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.5.0/statsmodels/api.py in <module>()
     10 from .discrete.discrete_model import (Poisson, Logit, Probit, MNLogit,
     11                                       NegativeBinomial)
---> 12 from .tsa import api as tsa
     13 from .nonparametric import api as nonparametric
     14 import distributions

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

/builddir/build/BUILD/statsmodels-0.5.0/statsmodels/tsa/ar_model.py in <module>()
     16 from statsmodels.tools.numdiff import (approx_fprime, approx_hess,
     17         approx_hess_cs)
---> 18 from statsmodels.tsa.kalmanf.kalmanfilter import KalmanFilter
     19 import statsmodels.base.wrapper as wrap
     20 from statsmodels.tsa.vector_ar import util

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

/builddir/build/BUILD/statsmodels-0.5.0/statsmodels/tsa/kalmanf/kalmanfilter.py in <module>()
     30 from numpy.linalg import inv, pinv
     31 from statsmodels.tools.tools import chain_dot
---> 32 from . import kalman_loglike
     33 
     34 #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-6d0888eba6f2> 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-9b8843496196> in <module>()
----> 1 data = data.rename(columns={"partner.status" :
      2                              "partner_status"}) # make name pythonic

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-0dd290a7e946> 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.

Table Of Contents

Previous topic

statsmodels.discrete.discrete_model.MultinomialModel.score

Next topic

statsmodels.stats.anova.anova_lm

This Page