Skip to content

BUG/DOC DynamicVAR in vector_ar example is broken #2272

Closed

Activity

  1. added this to the 0.8 milestone on Feb 16, 2015
  2. kiyoto commented on Jul 26, 2015

    @kiyoto
    Contributor

    @josef-pkt Do you have any idea where the 500-row data DataFrame in the DynamicVAR example came from?

    Asking because that's what is causing the example to fail (apart from MultiPanel/Panel): the example assumes that there are columns called "A" through "D", but your example comes from the earlier section of the same page where data consists of "realgdp", etc.

  3. josef-pkt commented on Jul 27, 2015

    @josef-pkt
    MemberAuthor

    My guess is that I didn't look carefully enough to realize that the data for DynamicVAR is different from the previous example.

    After a bit of search, I guess it's simulated data, see the __main__ of statsmodels.tsa.vector_ar.dynamic

    I'm using pandas.version '0.12.0' right now.

    The following works for me

    import pandas.util.testing as ptest
    from statsmodels.tsa.vector_ar.dynamic import DynamicVAR
    
    # the following lines are copied from statsmodels.tsa.vector_ar.dynamic __main__
    ptest.N = 500
    data = ptest.makeTimeDataFrame().cumsum(0)
    
    var = DynamicVAR(data, lag_order=2, window_type='expanding')
    var2 = DynamicVAR(data, lag_order=2, window=10,
                      window_type='rolling')
    

    which generates:

    >>> data
    <class 'pandas.core.frame.DataFrame'>
    DatetimeIndex: 500 entries, 2000-01-03 00:00:00 to 2001-11-30 00:00:00
    Freq: B
    Data columns (total 4 columns):
    A    500  non-null values
    B    500  non-null values
    C    500  non-null values
    D    500  non-null values
    dtypes: float64(4)
    

    and this seems to be working

    >>> var
    <statsmodels.tsa.vector_ar.dynamic.DynamicVAR object at 0x0451F1F0>
    >>> var.coefs
    <class 'pandas.core.panel.Panel'>
    Dimensions: 9 (items) x 489 (major_axis) x 4 (minor_axis)
    Items axis: L1.A to intercept
    Major_axis axis: 2000-01-18 00:00:00 to 2001-11-30 00:00:00
    Minor_axis axis: A to D
    
    >>> var.forecast(2)
    <class 'pandas.core.frame.DataFrame'>
    DatetimeIndex: 487 entries, 2000-01-20 00:00:00 to 2001-11-30 00:00:00
    Freq: B
    Data columns (total 4 columns):
    A    487  non-null values
    B    487  non-null values
    C    487  non-null values
    D    487  non-null values
    dtypes: float64(4)
    
  4. kiyoto commented on Jul 27, 2015

    @kiyoto
    Contributor

    @josef-pkt let me add that context for the data and also update it. Multipanel is deprecated, I think.

  5. kiyoto commented on Jul 28, 2015

    @kiyoto
    Contributor

    @josef-pkt thanks for the comment. squashed into a single commit.

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