LP test for unit root with break

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

ngantran
Posts: 4
Joined: Fri Oct 07, 2016 8:04 pm

LP test for unit root with break

Postby ngantran » Tue Mar 28, 2017 11:29 pm

Hi all,

I just modified a code for Lumsdaine-Papell test, based on codes provided by the Eviews experts (tcfoon and trubador). However, I think my code has bugs since the result is different from that of the expert's code. Could someone show me where I did wrong, please?

And how to obtain the t-critical value in context of LP test?
Many thanks

Code: Select all

call lpa(y,"C",12)
subroutine lpa(series y,string %Model,scalar maxlag)
!trim = 0.15 'Trimming parameter
series DY = D(Y)

!nobs = @obs(y)-maxlag-1

smpl @first+maxlag+1 @last
equation temp.ls dy c @trend y(-1)
!aic0 = log(temp.@ssr/!nobs)+2*(temp.@ncoef/!nobs)
!bic0 = log(temp.@ssr/!nobs)+ log(!nobs)*(temp.@ncoef/!nobs)
!min_aic = !aic0

for !lag=maxlag to 1 step -1
  equation temp.ls dy y(-1) c @trend dy(-1 to -!lag)
  !aic = log(temp.@ssr/!nobs)+2*(temp.@ncoef/!nobs)
  !bic = log(temp.@ssr/!nobs)+log(!nobs)*(temp.@ncoef/!nobs)
      if !aic < !min_aic then
       !min_aic = !aic
       !best_lag = !lag
        else if !min_aic = !aic0 then
        !best_lag =0
        endif
     endif
next

smpl @all
!znobs = @obs(y) - !best_lag
!lower = 1+!best_lag+@round(!znobs*!trim)
!upper =  @obs(y)-@round(!znobs*!trim)

vector(!upper-!lower+1) results

smpl @first + !best_lag @last
!t_min=1000
vector(2) breaks
for !i = !lower to !upper
for !k=!i +2 to !upper-2
series DY=D(Y)
  if !best_lag=0 and %Model = "A" then
     equation temp.ls DY Y(-1) C @trend (@trend>!i-2) (@trend>!k-2)
     else if !best_lag=0 and %Model = "B" then
        equation temp.ls DY Y(-1) C @trend (@trend>!i-2)*(@trend-!i+2) (@trend>!k-2)*(@trend-!k+2)
       else if !best_lag=0 and %Model = "C" then
          equation temp.ls DY Y(-1) C @trend (@trend>!i-2) (@trend>!i-2)*(@trend-!i+2) (@trend>!k-2) (@trend>!k-2)*(@trend-!k+2)
         else if !best_lag>0 and %Model = "A" then
            equation temp.ls DY Y(-1) C @trend (@trend>!i-2)  (@trend>!k-2) DY(-1 to -!best_lag)
           else if !best_lag>0 and %Model = "B" then
              equation temp.ls DY Y(-1) C @trend (@trend>!i-2)*(@trend-!i+2) @trend>!k-2)*(@trend-!k+2) DY(-1 to -!best_lag)
              else if !best_lag>0 and %Model = "C" then
                 equation temp.ls DY Y(-1) C @trend (@trend>!i-2) (@trend>!i-2)*(@trend-!i+2) (@trend>!k-2) (@trend>!k-2)*(@trend-!k+2) DY(-1 to -!best_lag)
              endif
           endif
         endif
       endif
     endif
  endif
 if temp.@tstats(2)<!t_min then
!t_min=temp.@tstats(2)
breaks(1) = !i 'Identified first break point.
breaks(2) = !k 'Identified second break point.
        series DU1 = @trend> !i-2
        series DT1 = DU1*(@trend-!i+2)
        series DU2 = @trend>!k-2
        series DT2 = DU2*(@trend-!k+2)
if !best_lag=0 and %Model="A" then
           equation lpa.ls DY Y(-1) C @trend DU 'Selected equation
            else if !best_lag=0 and %Model="B" then
              equation lpa.ls DY Y(-1) C @trend DT 'Selected equation
                else if !best_lag=0 and %Model="C" then
                  equation lpa.ls DY Y(-1) C @trend DU DT 'Selected equation
                    else if !best_lag>0 and %Model = "A" then
                       equation lpa.ls DY Y(-1) C @trend DU1 DU2 DY(-1 to -!best_lag) 'Selected equation
                       else if !best_lag>0 and %Model = "B" then
                          equation lpa.ls DY Y(-1) C @trend DT1 DT2 DY(-1 to -!best_lag) 'Selected equation
                            else if !best_lag>0 and %Model = "C" then
                               equation lpa.ls DY Y(-1) C @trend DU1 DT1 DU2 DT2 DY(-1 to -!best_lag) 'Selected equation
                            endif             
                       endif
                    endif
                 endif
            endif
         endif
   endif
   next
next
delete temp
endsub

Return to “Programming”

Who is online

Users browsing this forum: No registered users and 62 guests