Skip to content

VAR fitting problems #234

Closed
Closed

Description

@jseabold

Not sure what's broken yet, but I was just messing around and noticed that this doesn't work. Why not?

import datetime

import statsmodels.api as sm
import pandas

def date_parser(date):
    date = date.split('/')
    date.insert(0,'1')
    date = map(int, date)
    return datetime.datetime(*tuple(date[::-1]))


# requires recent pandas
url = 'http://eagle1.american.edu/~js2796a/Monthly_Food_Indices.csv'
dta = pandas.read_csv(url, skiprows=2,
                        parse_dates=True, index_col=0,
                        date_parser=date_parser)

mod = sm.tsa.VAR(dta, freq='M')
res = mod.fit(maxlags=1)
res.llf
res.cov_params()

mod2 = sm.tsa.VAR(dta.values, freq='M')
res2 = mod.fit(maxlags=1)
res2.llf
res2.cov_params()

Activity

  1. wesm commented on May 2, 2012

    @wesm
    Member

    in the latter case, cov_params is 42 x 42 which is the size of the flattened parameter matrix:

    ipdb> self.params.ix[:, :3]
                            Food Price Index  Meat Price Index  Dairy Price Index
    const                           4.664169          4.859755           6.459293
    L1.Food Price Index             0.179164          0.260506           0.107292
    L1.Meat Price Index             0.207322          0.820901          -0.116975
    L1.Dairy Price Index            0.164661         -0.044343           0.983993
    L1.Cereals Price Index          0.206017         -0.047807          -0.088104
    L1.Oils Price Index             0.129423         -0.025877           0.038800
    L1.Sugar Price Index            0.073901         -0.006592           0.018841
    

    so the lag-1 model has 42 coefficients. Whereas the results wrapper is trying to use this as the column and row labels:

    ipdb> items
    Index([const, L1.Food Price Index, L1.Meat Price Index,
           L1.Dairy Price Index, L1.Cereals Price Index, L1.Oils Price Index,
           L1.Sugar Price Index], dtype=object)
    
  2. josef-pkt commented on Feb 17, 2013

    @josef-pkt
    Member

    We also still have the same problem with MNLogit.

  3. added this to the 0.13 milestone on Sep 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions