Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting p-values for ARIMA results for Panel Data

    I have panel data and I am using an ARIMA(1,1,1) model. I can get all the parameter estimates from the model using runby but I am struggling to store p-values associated with the z-scores given for the AR(1) and MA(1) terms. Please can anyone help me?

  • #2
    Code:
    . webuse wpi1
    . arima wpi, arima(1,1,1)
    
    (setting optimization to BHHH)
    Iteration 0:   log likelihood = -139.80133  
    Iteration 1:   log likelihood =  -135.6278  
    Iteration 2:   log likelihood = -135.41838  
    Iteration 3:   log likelihood = -135.36691  
    Iteration 4:   log likelihood = -135.35892  
    (switching optimization to BFGS)
    Iteration 5:   log likelihood = -135.35471  
    Iteration 6:   log likelihood = -135.35135  
    Iteration 7:   log likelihood = -135.35132  
    Iteration 8:   log likelihood = -135.35131  
    
    ARIMA regression
    
    Sample:  1960q2 - 1990q4                        Number of obs     =        123
                                                    Wald chi2(2)      =     310.64
    Log likelihood = -135.3513                      Prob > chi2       =     0.0000
    
    ------------------------------------------------------------------------------
                 |                 OPG
           D.wpi |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    wpi          |
           _cons |   .7498197   .3340968     2.24   0.025     .0950019    1.404637
    -------------+----------------------------------------------------------------
    ARMA         |
              ar |
             L1. |   .8742288   .0545435    16.03   0.000     .7673256     .981132
                 |
              ma |
             L1. |  -.4120458   .1000284    -4.12   0.000    -.6080979   -.2159938
    -------------+----------------------------------------------------------------
          /sigma |   .7250436   .0368065    19.70   0.000     .6529042    .7971829
    ------------------------------------------------------------------------------
    Note: The test of the variance against zero is one sided, and the two-sided
          confidence interval is truncated at zero.
    Assume that we want the p-value in red, we need to know how to refer to the coefficient and standard error in blue. A quick way is to look at the coefficients matrix

    Code:
    . mat list e(b)
    
    e(b)[1,4]
               wpi:       ARMA:       ARMA:      sigma:
                             L.          L.            
             _cons          ar          ma       _cons
    y1   .74981969   .87422879  -.41204585   .72504356
    suggesting that the coefficient is

    Code:
    . di _b[ARMA:L.ar]
    .87422879
    With this, you can compute the p-value as below

    Code:
    .  di 2*(normal(-(_b[ARMA:L.ar]/_se[ARMA:L.ar])))
    8.131e-58
    The p-values are also stored in r(table)

    Code:
    . mat list r(table)
    
    r(table)[9,4]
                   wpi:       ARMA:       ARMA:      sigma:
                                 L.          L.            
                 _cons          ar          ma       _cons
         b   .74981969   .87422879  -.41204585   .72504356
        se   .33409683   .05454346   .10002839   .03680645
         z   2.2443185   16.028113  -4.1192891   19.698818
    pvalue   .02481192   8.131e-58     .000038   1.104e-86
        ll   .09500193   .76732557  -.60809788   .65290424
        ul   1.4046375   .98113202  -.21599381   .79718288
        df           .           .           .           .
      crit    1.959964    1.959964    1.959964    1.959964
     eform           0           0           0           0
    It is faster to compute the p-value as above compared to extracting it from here, but you would need something like

    Code:
    . mat R= r(table)
    
    . mat p1= R["pvalue", "ARMA:L.ar"]
    
    . di p1[1,1]
    8.131e-58
    Last edited by Andrew Musau; 19 Sep 2018, 08:15.

    Comment


    • #3
      Thank you for the prompt response.

      The code you gave works really well on simple data and I can use esstab to extract the r(table) in a CSV file. However, it does not work on the runby command I am running on my panel data. My original code is shown below.

      *--------- begin code ---------

      program my_arima1

      . tsset ID date
      2.
      . arima xvar , ar(1) ma(1)
      3.
      . gen b_xvar = _b[xvar:_cons]
      4.
      . gen b_ar = _b[ARMA:L1.ar]
      5.
      . gen b_sigma = _b[sigma:_cons]
      6.
      . gen se_xvar = _se[xvar:_cons]
      7.
      . gen se_ar = _se[ARMA:L1.ar]
      8.
      . gen se_sigma = _se[sigma:_cons]
      9.
      . gen se_ma = _se[ARMA:L1.ma]
      10.
      . gen b_ma = _b[ARMA:L1.ma]
      11.
      keep ID b_* se_*e
      12.
      end

      runby my_arima1, by(ID) status
      *-------- end code ----------


      Is there a way to pull out the p-values for multiple panels using the runby function I am using?

      Comment


      • #4
        Nevermind.

        I figured it out using your code. I used generate p1 = 2*(normal(-(_b[ARMA:L.ar]/_se[ARMA:L.ar]))), generate p2 = 2*(normal(-(_b[ARMA:L.ma]/_se[ARMA:L.ma]))), etc. within the my_arima1 program.

        Initially, when I did that, I was getting most of the AR and MA terms insignificant and I thought it was due to an error. But, I double checked by taking the panels out and it seems that their AR and MA terms were actually not signficant and it was not an error.

        Thank you once again for the help!
        Last edited by Mohammed Anas Irfan; 19 Sep 2018, 14:46.

        Comment

        Working...
        X