******************************************************************************************
*                                                                                        *
* PERRON SERIES START END                                                                *
*                                                                                        *
*  PERRON computes the augmented "PERRON" unit root test allowing under both             *
*   null and alternative hypotheses for the presence of a one-time change                *
*   in the level or in the slope of the trend function using three different             *
*   linear regression models which are constructed by nesting the corresponding          *
*   null and alternative hypothesis:                                                     *
*                                                                                        *
* A. "crash" model:                                                                      *
*                                                                                        *
*    Y(t) = C + theta*DMU(t) + betha*TREND(t) + d*DTB(t) + alpha*Y(t-1)                  *
*                                                  + b1*DY(t-1)+...+bp*Y(T-p) + EPS(t)   *
*                                                                                        *
* B. "changing growth" model:                                                            *
*                                                                                        *
*    Y(t) = C + theta*DMU(t) + betha*TREND(t) + gamma*DTS(t) + alpha*Y(t-1)              *
*                                                   + b1*DY(t-1)+...+bp*DY(t-p) + EPS(t) *
*                                                                                        *
* C. model which allows "both effects" take place:                                       *
*                                                                                        *
*    Y(t) = C + theta*DMU(t) + betha*TREND(t) + delta*DT(t) + d*DTB(t) + alpha*Y(t-1)    *
*                                                   + b1*DY*(t-1)+...+bp*DY(t-p) + EPS(t)*
*  Where:                                                                                *
*    C: constant                                                                         *
*    TREND(t): linear trend                                                              *
*    DTB = 1 if t=TB+1 (TB time break) and DTB = 0 otherwise                             *  *
*    Under model A. DMU(t) = 0 if t<=TB,  and DMU(t) = 1 if t> TB                        *
*    Under model B. DTS(t) = 0 if t<=tb and DTS(t) Trend - TB if t>TB                    *
*    Under model C. DMU(t) = DT if t<= TB and DMU(t) = 1, DT(t) = t if t> TB             *
*    EPS(t) are White noise. Necesary condition for the tests to be valid.               *
*                                                                                        *
*   PERRON determines the appropriate number of lagged differences by any of two methods:*
*    by adding lags until the Ljung-Box test fails to reject no serial correlation at a  *
*    user defined level, or by adding lags until a Lagrange Multiplier fails to reject no*
*    serial correlation at a user defined level.                                         *
*                                                                                        *
*   Critical values for the test and remaning parameters are displayed for the 1%,2.5%,  *
*    5% or 10%level and for each correspondig lambda value (TB/T). The values correspond *
*    to the critical values tabulated by Perron after improved 5.000 replications.       *
*    This test is more appropriated when standard test of unit root hyphothesis against  *
*    trend stationary alternatives cannot reject the unit root if the true data          *
*    generating process is that of stationary fluctuations around a trend function which *
*    contains a one-time break.                                                          *
*                                                                                        *
*                                                                                        *
*    The null hypothesis of a unit root imposes the follwing restrictions on the true    *
*    parameters of each model:                                                           *
*    Model A.                                                                            *
*    alpha = 0, betha = 0, theta = 0, d different to 0                                   *
*    Model B.                                                                            *
*    alpha = 0, gamma = 0, betha = 0, theta different to 0                               *
*    Model C.                                                                            *
*    alpha = 0, gamma = 0, Betha = 0, theta different to 0, d different to 0             *
*                                                                                        *
*    The alternative hypothesis of a unit root imposes the follwing restrictions on the  *
*    true parameters of each model:                                                      *
*    Model A.                                                                            *
*     alpha different to 0, betha different to 0, theta dfferent to 0, d = 0              *
*    Model B.                                                                            *
*     alpha different to 0, gamma different to 0, betha different to 0, theta = 0         *
*    Model C.                                                                            *
*     alpha different to 0, gamma different to 0, betha different to 0, theta different   *
*     to = 0, d = 0                                                                       *
*                                                                                        *
*                                                                                        *
*    References:                                                                         *
*    Perron, Pierre. "THE GREAT CRASH, THE OIL PRICE SHOCK,AND THE UNIT ROOT HYPOTHESIS".*
*    Econometrica, Vol. 57, No 6(November,1989), 1361-1401                               *
*                                                                                        *
*   Writen, June 29, 1997. Santafé de Bogotá Colombia                                    *
*   By Diego Mauricio Vásquez                                                            *
*
*   Revision history:
*     December 1, 1998: Fix "%DEFINED(ARSIGNIF)" section, so that SIGNIF
*        is always initialized (either to ARSIGNIF or to SIGNIF) and
*        so that LAG is always initialized to 0.0. Previously, SIGNF
*        was only initialized if ARSIGNIF was used, and LAG was only set
*        to 0 if ARSIGNIF was NOT used.
*       Also included code to require use of TB option.
*
*     Octer 8, 2008: Problem with SCSIGNIF being a local variable--value wasn't
*        returned from the SCTEST procedure. Modify procedure to pass the value
*        back as a parameter
*
*    Changes made by Estima.
*                                                                                        *
* Procedure PERRON series start end residuals                                            *
*                                                                                        *
*   Parameters:                                                                          *
*                                                                                        *
*       series:     the series to be analysed                                            *
*       start end:  the range of the series to use: defaults to the entire range         *
*                                                                                        *
*   Options:                                                                             *
*                                                                                        *
*       DET: A/[B]/C            The correspondig model.                                  *
*       CRITERION:[LBTEST]/LMTEST                                                        *
*       TB:                     The corresponding time break                             *
*       ARSIGNIF = [0.05]       The significance level for the Ljug-Box and LM tests     *
*       SIGNIF   = [0.05]       The significance level for the PERRON tests              *
*                                                                                        *
******************************************************************************************
PROCEDURE LJUNGBOX depvar start end

TYPE SERIES 		depvar
TYPE INTEGER 		start end

OPTION INTEGER 		lags	4
OPTION INTEGER 	    span    0
OPTION INTEGER 	    dfc     0
LOCAL INTEGER		startl endl qspan

INQUIRE(SERIES=depvar) startl>>start endl>>end
IF (span.eq.0)
   COMPUTE qspan = lags
ELSE
   COMPUTE qspan = span
CORRELATE(number=lags,noprint,qstat,span=qspan,dfc=dfc) depvar startl endl
COMPUTE QSIG = %SIGNIF

END LJUNGBOX
***************************************************************************
PROCEDURE SCTEST DEPVAR START END SCSignif

TYPE SERIES 		DEPVAR
TYPE INTEGER 		START END
TYPE REAL           *SCSignif
OPTION INTEGER 		LAGS 4
OPTION SWITCH 		PRINT 0
OPTION INTEGER  LAGS (end - (start))/4

LOCAL SERIES RESIDS TREND DMU DT DTB DTS
LOCAL INDEX  REGLIST
LOCAL INTEGER 		STARTL ENDL SCLAG
ENTER(VARYNG) REGLIST
INQUIRE(REGRESSORLIST) STARTL>>START ENDL>>END
#REGLIST DEPVAR
LINREG(PRINT=PRINT) DEPVAR STARTL ENDL RESIDS
#REGLIST
DISPLAY ' '
COMPUTE SCSIGNIF=%CHISQR(%TRSQ,LAGS)
DISPLAY 'LM TEST FOR SERIAL CORRELATION OF ORDER ' LAGS ' FOR ' %LABEL(DEPVAR)
DISPLAY ' TEST STATISTIC: ' %TRSQ ' SIGNIFICANCE LEVEL: ' #.##### SCSIGNIF
DISPLAY ' '
END SCTEST
******************************************************************************
PROCEDURE PERRON  series start end
TYPE SERIES SERIES
TYPE INTEGER START END
OPTION CHOICE DET        2 A  B  C
OPTION CHOICE CRITERION  1 LBTEST LMTEST
OPTION REAL  ARSIGNIF    0.05
OPTION REAL  SIGNIF      0.05
OPTION INTEGER TB
OPTION INTEGER SCLAG (END - (START))/4

DECLARE REAL LAMB
LOCAL REAL SIGNIF SIG DSIG
* Can't define QSIG as a LOCAL variable as currently written,
* as it needs to be set by one of the sub-procedures:
*LOCAL REAL lamb signdf signf qsig lambda cval teststata teststatb $
LOCAL REAL lamb signdf signf lambda cval teststata teststatb $
           t_stat1 t_stat2 t_stat3 t_stat4 t_stat5 t_stat6 $
           t_stat7 t_stat8 t_stat9 t_stat10 t_stat11 t_stat12 $
           t_stat13 t_stat14
**  scsignif
LOCAL REAL teststatb
LOCAL INTEGER LAG SCLAG
LOCAL INTEGER startl endl
LOCAL SERIES TREND DMU DT DTB DTS dseries resids

if %defined(tb)<>1
{
  display 'Please specify a value (date or entry number) for '
  display ' the time break using the TB option. The procedure'
  display ' will now quit.'
  return
}

INQUIRE(SERIES=SERIES) STARTL>>START ENDL>>END
COMPUTE LAMB = (((TB-STARTL)+1)*1000)/((ENDL-STARTL)+1)
COMPUTE LAMBDA = LAMB/1000
DISPLAY  '';DISPLAY ''
DISPLAY '**************************************************************'
DISPLAY '* TESTING THE NULL HYPOTESIS OF A UNIT ROOT IN' %LABEL(SERIES) @61 '*'
DISPLAY '* CHOOSING THE OPTIMAL LAG LENGTH FOR THE PERRON REGRESSION ' @61 '*'
IF (CRITERION.EQ.1) {
        DISPLAY '* BY ADDING LAGS UNTIL THE LJUNG-BOX TEST REJECTS ' @61 '*'
        DISPLAY '* RESIDUAL CORRELATION AT LEVEL' @+0 #.### ARSIGNIF @-1 '.' @61 '*'
        }
ELSE {
        DISPLAY '* BY ADDING LAGS UNTIL THE LAGRANGE MULTIPLIER TEST REJECTS ' @61 '*'
        DISPLAY '* RESIDUAL CORRELATION AT LEVEL' @+0 #.### ARSIGNIF @-1 '.' @61 '*'
        }
DISPLAY '**************************************************************'
DISPLAY ' '
DISPLAY 'USING DATA FROM ' %DATELABEL(STARTL) 'TO' %DATELABEL(ENDL)
DISPLAY
COMPUTE SIGNDF = 0.05
IF %DEFINED(SIGNIF) {
   IF (SIGNIF.NE.0.01.AND.SIGNIF.NE.0.025.AND.SIGNIF.NE.0.05.AND.SIGNIF.NE.0.10) {
      DISPLAY 'YOU MUST CHOOSE SIGNIFICANCE LEVEL OF 0.01, 0.025, 0.05, 0.10 FOR PERRON CRITICAL VALUE'
      DISPLAY 'DEFAULTING TO 0.05'
      DISPLAY
   }
   ELSE
      COMPUTE SIGNDF = SIGNIF;
}


************************************************************************************************************
SET DSERIES STARTL ENDL = SERIES - SERIES{1}
SET TREND STARTL ENDL = T
SET DMU STARTL ENDL = T>TB
SMPL STARTL TB
SET DT = 0
SMPL TB+1 ENDL
SET DT = TREND
SMPL STARTL ENDL
SMPL STARTL TB
SET DTB = 0
SMPL TB+1 TB+1
SET DTB = 1
SMPL TB+2 ENDL
SET DTB = 0
SMPL STARTL ENDL
SMPL STARTL TB
SET DTS = 0
SMPL TB+1 ENDL
SET DTS = TREND - TB
SMPL STARTL ENDL
*************************************************************************************************************
IF %DEFINED(ARSIGNIF)
       COMPUTE SIGNF = ARSIGNIF
ELSE
       COMPUTE SIGNF = SIGNDF

COMPUTE LAG = 0
COMPUTE SIG = 0.0

**********
IF (DET.EQ.1) {
  WHILE (SIG.LT.SIGNF) {
     DISPLAY 'ADDING LAG' LAG
     IF(LAG.GT.0)
              LINREG(NOPRINT) SERIES STARTL ENDL RESIDS
              #CONSTANT DMU TREND DTB SERIES{1} DSERIES{1 TO LAG}
       ELSE
       LINREG(NOPRINT) SERIES STARTL ENDL RESIDS
              #CONSTANT DMU TREND DTB SERIES{1}
     IF (CRITERION.EQ.1) {
       @LJUNGBOX(LAGS=SCLAG) RESIDS STARTL ENDL
             COMPUTE  SIG = QSIG
       }
     ELSE IF (CRITERION.EQ.2) {
        IF (LAG.GT.0) {
               @SCTEST(LAGS=SCLAG) RESIDS STARTL ENDL scsignif
               # CONSTANT DMU TREND DTB SERIES{1} DSERIES{1 TO LAG}
               COMPUTE  SIG = SCSIGNIF
          }
        ELSE {
*            @SCTEST(LAGS=SCLAG) SERIES STARTL ENDL RESIDS scsignif
            @SCTEST(LAGS=SCLAG) SERIES STARTL ENDL scsignif
               # CONSTANT DMU TREND DTB SERIES{1}
               COMPUTE  SIG = SCSIGNIF
            }
        }
     IF (SIG.GT.SIGNF)
               IF (LAG.GT.0)
                      LINREG(NOPRINT) SERIES STARTL ENDL RESIDS
               # CONSTANT DMU TREND DTB SERIES{1} DSERIES{1 TO LAG}
        ELSE
                      LINREG(NOPRINT) SERIES STARTL ENDL RESIDS
               # CONSTANT DMU TREND DTB SERIES{1}
         ELSE
         COMPUTE LAG = LAG + 1
     }
}
**********
IF (DET.EQ.2) {
  WHILE (SIG.LT.SIGNF) {
     DISPLAY 'ADDING LAG' LAG
     IF(LAG.GT.0)
              LINREG(NOPRINT) SERIES STARTL ENDL RESIDS
              # CONSTANT DMU TREND DTS SERIES{1} DSERIES{1 TO LAG}
       ELSE
              LINREG(NOPRINT) SERIES STARTL ENDL RESIDS
              # CONSTANT DMU TREND DTS SERIES{1}
     IF (CRITERION.EQ.1) {
       @LJUNGBOX(LAGS=SCLAG) RESIDS STARTL ENDL
             COMPUTE  SIG = QSIG
       }
     ELSE IF (CRITERION.EQ.2) {
        IF (LAG.GT.0) {
               @SCTEST(LAGS=SCLAG) RESIDS STARTL ENDL  scsignif
               # CONSTANT DMU TREND DTS SERIES{1} DSERIES{1 TO LAG}
               COMPUTE  SIG = SCSIGNIF
          }
        ELSE {
*            @SCTEST(LAGS=SCLAG) SERIES STARTL ENDL RESIDS  scsignif
            @SCTEST(LAGS=SCLAG) SERIES STARTL ENDL scsignif
               # CONSTANT DMU TREND DTS SERIES{1}
               COMPUTE  SIG = SCSIGNIF
            }
        }
     IF (SIG.GT.SIGNF)
               IF (LAG.GT.0)
                      LINREG(NOPRINT) SERIES STARTL ENDL RESIDS
               # CONSTANT DMU TREND DTS SERIES{1} DSERIES{1 TO LAG}
        ELSE
                      LINREG(NOPRINT) SERIES STARTL ENDL RESIDS
               # CONSTANT DMU TREND DTS SERIES{1}
         ELSE
         COMPUTE LAG = LAG + 1

     }
}
**********
IF (DET.EQ.3) {
  WHILE (SIG.LT.SIGNF) {
     DISPLAY 'ADDING LAG' LAG
     IF(LAG.GT.0)
              LINREG(NOPRINT) SERIES STARTL ENDL RESIDS
              # CONSTANT DMU TREND DT DTB SERIES{1} DSERIES{1 TO LAG}
       ELSE
       LINREG(NOPRINT) SERIES STARTL ENDL RESIDS
              # CONSTANT DMU TREND DT DTB SERIES{1}
     IF (CRITERION.EQ.1) {
       @LJUNGBOX(LAGS=SCLAG) RESIDS STARTL ENDL
             COMPUTE  SIG = QSIG
       }
     ELSE IF (CRITERION.EQ.2) {
        IF (LAG.GT.0) {
               @SCTEST(LAGS=SCLAG) RESIDS STARTL ENDL  scsignif
               # CONSTANT DMU TREND DT DTB SERIES{1} DSERIES{1 TO LAG}
               COMPUTE  SIG = SCSIGNIF
          }
        ELSE {
*            @SCTEST(LAGS=SCLAG) SERIES STARTL ENDL RESIDS  scsignif
            @SCTEST(LAGS=SCLAG) SERIES STARTL ENDL scsignif
               # CONSTANT DMU TREND DT DTB SERIES{1}
               COMPUTE  SIG = SCSIGNIF
            }
        }
     IF (SIG.GT.SIGNF)
               IF (LAG.GT.0)
                      LINREG(NOPRINT) SERIES STARTL ENDL RESIDS
               # CONSTANT DMU TREND DT DTB SERIES{1} DSERIES{1 TO LAG}
        ELSE
                      LINREG(NOPRINT) SERIES STARTL ENDL RESIDS
               # CONSTANT DMU TREND DT DTB SERIES{1}
         ELSE
         COMPUTE LAG = LAG + 1

     }
}
**********



   DISPLAY ' '
   DISPLAY '**************************************************************'


       IF (DET.EQ.1) {
          IF (SIGNDF.EQ.0.01) {
                  IF (LAMBDA.GT.0.00.AND.LAMBDA.LE.0.15)
                COMPUTE CVAL =-4.30
             ELSE IF (LAMBDA.GT.0.15.AND.LAMBDA.LE.0.25)
                COMPUTE CVAL =-4.39
             ELSE IF (LAMBDA.GT.0.25.AND.LAMBDA.LE.0.35)
                COMPUTE CVAL =-4.39
             ELSE IF (LAMBDA.GT.0.35.AND.LAMBDA.LE.0.45)
                COMPUTE CVAL =-4.34
             ELSE IF (LAMBDA.GT.0.45.AND.LAMBDA.LE.0.55)
                COMPUTE CVAL =-4.32
             ELSE IF (LAMBDA.GT.0.55.AND.LAMBDA.LE.0.65)
                COMPUTE CVAL =-4.45
             ELSE IF (LAMBDA.GT.0.65.AND.LAMBDA.LE.0.75)
                COMPUTE CVAL =-4.42
             ELSE IF (LAMBDA.GT.0.75.AND.LAMBDA.LE.0.85)
                COMPUTE CVAL =-4.33
             ELSE IF (LAMBDA.GT.0.85.AND.LAMBDA.LE.0.95)
                COMPUTE CVAL =-4.37
   }
          IF (SIGNDF.EQ.0.025) {
                  IF (LAMBDA.GT.0.00.AND.LAMBDA.LE.0.15)
                COMPUTE CVAL =-3.93
             ELSE IF (LAMBDA.GT.0.15.AND.LAMBDA.LE.0.25)
                COMPUTE CVAL =-4.08
             ELSE IF (LAMBDA.GT.0.25.AND.LAMBDA.LE.0.35)
                COMPUTE CVAL =-4.03
             ELSE IF (LAMBDA.GT.0.35.AND.LAMBDA.LE.0.45)
                COMPUTE CVAL =-4.01
             ELSE IF (LAMBDA.GT.0.45.AND.LAMBDA.LE.0.55)
                COMPUTE CVAL =-4.01
             ELSE IF (LAMBDA.GT.0.55.AND.LAMBDA.LE.0.65)
                COMPUTE CVAL =-4.09
             ELSE IF (LAMBDA.GT.0.65.AND.LAMBDA.LE.0.75)
                COMPUTE CVAL =-4.07
             ELSE IF (LAMBDA.GT.0.75.AND.LAMBDA.LE.0.85)
                COMPUTE CVAL =-3.99
             ELSE IF (LAMBDA.GT.0.85.AND.LAMBDA.LE.0.95)
                COMPUTE CVAL =-3.97
            }
          IF (SIGNDF.EQ.0.05) {
                  IF (LAMBDA.GT.0.00.AND.LAMBDA.LE.0.15)
                COMPUTE CVAL =-3.68
             ELSE IF (LAMBDA.GT.0.15.AND.LAMBDA.LE.0.25)
                COMPUTE CVAL =-3.77
             ELSE IF (LAMBDA.GT.0.25.AND.LAMBDA.LE.0.35)
                COMPUTE CVAL =-3.76
             ELSE IF (LAMBDA.GT.0.35.AND.LAMBDA.LE.0.45)
                COMPUTE CVAL =-3.72
             ELSE IF (LAMBDA.GT.0.45.AND.LAMBDA.LE.0.55)
                COMPUTE CVAL =-3.76
             ELSE IF (LAMBDA.GT.0.55.AND.LAMBDA.LE.0.65)
                COMPUTE CVAL =-3.76
             ELSE IF (LAMBDA.GT.0.65.AND.LAMBDA.LE.0.75)
                COMPUTE CVAL =-3.80
             ELSE IF (LAMBDA.GT.0.75.AND.LAMBDA.LE.0.85)
                COMPUTE CVAL =-3.75
             ELSE IF (LAMBDA.GT.0.85.AND.LAMBDA.LE.0.95)
                COMPUTE CVAL =-3.69
            }
          IF (SIGNDF.EQ.0.10) {
                  IF (LAMBDA.GT.0.00.AND.LAMBDA.LE.0.15)
                COMPUTE CVAL =-3.40
             ELSE IF (LAMBDA.GT.0.15.AND.LAMBDA.LE.0.25)
                COMPUTE CVAL =-3.47
             ELSE IF (LAMBDA.GT.0.25.AND.LAMBDA.LE.0.35)
                COMPUTE CVAL =-3.46
             ELSE IF (LAMBDA.GT.0.35.AND.LAMBDA.LE.0.45)
                COMPUTE CVAL =-3.44
             ELSE IF (LAMBDA.GT.0.45.AND.LAMBDA.LE.0.55)
                COMPUTE CVAL =-3.46
             ELSE IF (LAMBDA.GT.0.55.AND.LAMBDA.LE.0.65)
                COMPUTE CVAL =-3.47
             ELSE IF (LAMBDA.GT.0.65.AND.LAMBDA.LE.0.75)
                COMPUTE CVAL =-3.51
             ELSE IF (LAMBDA.GT.0.75.AND.LAMBDA.LE.0.85)
                COMPUTE CVAL =-3.46
             ELSE IF (LAMBDA.GT.0.85.AND.LAMBDA.LE.0.95)
                COMPUTE CVAL =-3.38
            }
         COMPUTE T_STAT1=(%BETA(1))/SQRT(%SEESQ*%XX(1,1))
         COMPUTE T_STAT2=(%BETA(2))/SQRT(%SEESQ*%XX(2,2))
         COMPUTE T_STAT3=(%BETA(3))/SQRT(%SEESQ*%XX(3,3))
         COMPUTE T_STAT4=(%BETA(4))/SQRT(%SEESQ*%XX(4,4))

       }
       IF (DET.EQ.2) {
          IF (SIGNDF.EQ.0.01) {
                  IF (LAMBDA.GT.0.00.AND.LAMBDA.LE.0.15)
                COMPUTE CVAL =-4.27
             ELSE IF (LAMBDA.GT.0.15.AND.LAMBDA.LE.0.25)
                COMPUTE CVAL =-4.41
             ELSE IF (LAMBDA.GT.0.25.AND.LAMBDA.LE.0.35)
                COMPUTE CVAL =-4.51
             ELSE IF (LAMBDA.GT.0.35.AND.LAMBDA.LE.0.45)
                COMPUTE CVAL =-4.55
             ELSE IF (LAMBDA.GT.0.45.AND.LAMBDA.LE.0.55)
                COMPUTE CVAL =-4.56
             ELSE IF (LAMBDA.GT.0.55.AND.LAMBDA.LE.0.65)
                COMPUTE CVAL =-4.57
             ELSE IF (LAMBDA.GT.0.65.AND.LAMBDA.LE.0.75)
                COMPUTE CVAL =-4.51
             ELSE IF (LAMBDA.GT.0.75.AND.LAMBDA.LE.0.85)
                COMPUTE CVAL =-4.38
             ELSE IF (LAMBDA.GT.0.85.AND.LAMBDA.LE.0.95)
                COMPUTE CVAL =-4.26
            }
          IF (SIGNDF.EQ.0.025) {
                  IF (LAMBDA.GT.0.00.AND.LAMBDA.LE.0.15)
                COMPUTE CVAL =-3.94
             ELSE IF (LAMBDA.GT.0.15.AND.LAMBDA.LE.0.25)
                COMPUTE CVAL =-4.08
             ELSE IF (LAMBDA.GT.0.25.AND.LAMBDA.LE.0.35)
                COMPUTE CVAL =-4.17
             ELSE IF (LAMBDA.GT.0.35.AND.LAMBDA.LE.0.45)
                COMPUTE CVAL =-4.20
             ELSE IF (LAMBDA.GT.0.45.AND.LAMBDA.LE.0.55)
                COMPUTE CVAL =-4.26
             ELSE IF (LAMBDA.GT.0.55.AND.LAMBDA.LE.0.65)
                COMPUTE CVAL =-4.20
             ELSE IF (LAMBDA.GT.0.65.AND.LAMBDA.LE.0.75)
                COMPUTE CVAL =-4.13
             ELSE IF (LAMBDA.GT.0.75.AND.LAMBDA.LE.0.85)
                COMPUTE CVAL =-4.07
             ELSE IF (LAMBDA.GT.0.85.AND.LAMBDA.LE.0.95)
                COMPUTE CVAL =-3.96
            }
          IF (SIGNDF.EQ.0.05) {
                  IF (LAMBDA.GT.0.00.AND.LAMBDA.LE.0.15)
                COMPUTE CVAL =-3.65
             ELSE IF (LAMBDA.GT.0.15.AND.LAMBDA.LE.0.25)
                COMPUTE CVAL =-3.80
             ELSE IF (LAMBDA.GT.0.25.AND.LAMBDA.LE.0.35)
                COMPUTE CVAL =-3.87
             ELSE IF (LAMBDA.GT.0.35.AND.LAMBDA.LE.0.45)
                COMPUTE CVAL =-3.94
             ELSE IF (LAMBDA.GT.0.45.AND.LAMBDA.LE.0.55)
                COMPUTE CVAL =-3.96
             ELSE IF (LAMBDA.GT.0.55.AND.LAMBDA.LE.0.65)
                COMPUTE CVAL =-3.95
             ELSE IF (LAMBDA.GT.0.65.AND.LAMBDA.LE.0.75)
                COMPUTE CVAL =-3.85
             ELSE IF (LAMBDA.GT.0.75.AND.LAMBDA.LE.0.85)
                COMPUTE CVAL =-3.82
             ELSE IF (LAMBDA.GT.0.85.AND.LAMBDA.LE.0.95)
                COMPUTE CVAL =-3.68
            }
          IF (SIGNDF.EQ.0.10) {
                  IF (LAMBDA.GT.0.00.AND.LAMBDA.LE.0.15)
                COMPUTE CVAL =-3.36
             ELSE IF (LAMBDA.GT.0.15.AND.LAMBDA.LE.0.25)
                COMPUTE CVAL =-3.49
             ELSE IF (LAMBDA.GT.0.25.AND.LAMBDA.LE.0.35)
                COMPUTE CVAL =-3.58
             ELSE IF (LAMBDA.GT.0.35.AND.LAMBDA.LE.0.45)
                COMPUTE CVAL =-3.66
             ELSE IF (LAMBDA.GT.0.45.AND.LAMBDA.LE.0.55)
                COMPUTE CVAL =-3.68
             ELSE IF (LAMBDA.GT.0.55.AND.LAMBDA.LE.0.65)
                COMPUTE CVAL =-3.66
             ELSE IF (LAMBDA.GT.0.65.AND.LAMBDA.LE.0.75)
                COMPUTE CVAL =-3.57
             ELSE IF (LAMBDA.GT.0.75.AND.LAMBDA.LE.0.85)
                COMPUTE CVAL =-3.50
             ELSE IF (LAMBDA.GT.0.85.AND.LAMBDA.LE.0.95)
                COMPUTE CVAL =-3.35
            }
         COMPUTE T_STAT6=(%BETA(1))/SQRT(%SEESQ*%XX(1,1))
         COMPUTE T_STAT7=(%BETA(2))/SQRT(%SEESQ*%XX(2,2))
         COMPUTE T_STAT8=(%BETA(3))/SQRT(%SEESQ*%XX(3,3))
         COMPUTE T_STAT9=(%BETA(4))/SQRT(%SEESQ*%XX(4,4))

       }
       IF (DET.EQ.3) {
          IF (SIGNDF.EQ.0.01) {
                  IF (LAMBDA.GT.0.00.AND.LAMBDA.LE.0.15)
                COMPUTE CVAL =-4.38
             ELSE IF (LAMBDA.GT.0.15.AND.LAMBDA.LE.0.25)
                COMPUTE CVAL =-4.65
             ELSE IF (LAMBDA.GT.0.25.AND.LAMBDA.LE.0.35)
                COMPUTE CVAL =-4.78
             ELSE IF (LAMBDA.GT.0.35.AND.LAMBDA.LE.0.45)
                COMPUTE CVAL =-4.81
             ELSE IF (LAMBDA.GT.0.45.AND.LAMBDA.LE.0.55)
                COMPUTE CVAL =-4.90
             ELSE IF (LAMBDA.GT.0.55.AND.LAMBDA.LE.0.65)
                COMPUTE CVAL =-4.88
             ELSE IF (LAMBDA.GT.0.65.AND.LAMBDA.LE.0.75)
                COMPUTE CVAL =-4.75
             ELSE IF (LAMBDA.GT.0.75.AND.LAMBDA.LE.0.85)
                COMPUTE CVAL =-4.70
             ELSE IF (LAMBDA.GT.0.85.AND.LAMBDA.LE.0.95)
                COMPUTE CVAL =-4.41
            }
          IF (SIGNDF.EQ.0.025) {
                  IF (LAMBDA.GT.0.00.AND.LAMBDA.LE.0.15)
                COMPUTE CVAL =-4.01
             ELSE IF (LAMBDA.GT.0.15.AND.LAMBDA.LE.0.25)
                COMPUTE CVAL =-4.32
             ELSE IF (LAMBDA.GT.0.25.AND.LAMBDA.LE.0.35)
                COMPUTE CVAL =-4.46
             ELSE IF (LAMBDA.GT.0.35.AND.LAMBDA.LE.0.45)
                COMPUTE CVAL =-4.48
             ELSE IF (LAMBDA.GT.0.45.AND.LAMBDA.LE.0.55)
                COMPUTE CVAL =-4.53
             ELSE IF (LAMBDA.GT.0.55.AND.LAMBDA.LE.0.65)
                COMPUTE CVAL =-4.49
             ELSE IF (LAMBDA.GT.0.65.AND.LAMBDA.LE.0.75)
                COMPUTE CVAL =-4.44
             ELSE IF (LAMBDA.GT.0.75.AND.LAMBDA.LE.0.85)
                COMPUTE CVAL =-4.31
             ELSE IF (LAMBDA.GT.0.85.AND.LAMBDA.LE.0.95)
                COMPUTE CVAL =-4.10
            }
          IF (SIGNDF.EQ.0.05) {
                  IF (LAMBDA.GT.0.00.AND.LAMBDA.LE.0.15)
                COMPUTE CVAL =-3.75
             ELSE IF (LAMBDA.GT.0.15.AND.LAMBDA.LE.0.25)
                COMPUTE CVAL =-3.99
             ELSE IF (LAMBDA.GT.0.25.AND.LAMBDA.LE.0.35)
                COMPUTE CVAL =-4.17
             ELSE IF (LAMBDA.GT.0.35.AND.LAMBDA.LE.0.45)
                COMPUTE CVAL =-4.22
             ELSE IF (LAMBDA.GT.0.45.AND.LAMBDA.LE.0.55)
                COMPUTE CVAL =-4.24
             ELSE IF (LAMBDA.GT.0.55.AND.LAMBDA.LE.0.65)
                COMPUTE CVAL =-4.24
             ELSE IF (LAMBDA.GT.0.65.AND.LAMBDA.LE.0.75)
                COMPUTE CVAL =-4.18
             ELSE IF (LAMBDA.GT.0.75.AND.LAMBDA.LE.0.85)
                COMPUTE CVAL =-4.04
             ELSE IF (LAMBDA.GT.0.85.AND.LAMBDA.LE.0.95)
                COMPUTE CVAL =-3.80
            }
          IF (SIGNDF.EQ.0.10) {
                  IF (LAMBDA.GT.0.00.AND.LAMBDA.LE.0.15)
                COMPUTE CVAL =-3.45
             ELSE IF (LAMBDA.GT.0.15.AND.LAMBDA.LE.0.25)
                COMPUTE CVAL =-3.66
             ELSE IF (LAMBDA.GT.0.25.AND.LAMBDA.LE.0.35)
                COMPUTE CVAL =-3.87
             ELSE IF (LAMBDA.GT.0.35.AND.LAMBDA.LE.0.45)
                COMPUTE CVAL =-3.95
             ELSE IF (LAMBDA.GT.0.45.AND.LAMBDA.LE.0.55)
                COMPUTE CVAL =-3.96
             ELSE IF (LAMBDA.GT.0.55.AND.LAMBDA.LE.0.65)
                COMPUTE CVAL =-3.95
             ELSE IF (LAMBDA.GT.0.65.AND.LAMBDA.LE.0.75)
                COMPUTE CVAL =-3.86
             ELSE IF (LAMBDA.GT.0.75.AND.LAMBDA.LE.0.85)
                COMPUTE CVAL =-3.69
             ELSE IF (LAMBDA.GT.0.85.AND.LAMBDA.LE.0.95)
                COMPUTE CVAL =-3.46
            }
         COMPUTE T_STAT10=(%BETA(1))/SQRT(%SEESQ*%XX(1,1))
         COMPUTE T_STAT11=(%BETA(2))/SQRT(%SEESQ*%XX(2,2))
         COMPUTE T_STAT12=(%BETA(3))/SQRT(%SEESQ*%XX(3,3))
         COMPUTE T_STAT13=(%BETA(4))/SQRT(%SEESQ*%XX(4,4))
         COMPUTE T_STAT14=(%BETA(5))/SQRT(%SEESQ*%XX(5,5))


      }


   IF (DET.EQ.1) {
      COMPUTE TESTSTATA=(%BETA(5)-1.)/SQRT(%SEESQ*%XX(5,5))
      DISPLAY '* PERRON TEST FOR A UNIT ROOT FOR' %LABEL(SERIES) 'WITH' LAG 'LAGS:' @55 ##.#### TESTSTATA @61 '*'
      DISPLAY '* AT LEVEL' #.## SIGNDF @20 'AND FOR LAMBDA' #.# LAMBDA @61 '*'
      DISPLAY '* THE TABULATED CRITICAL VALUE:' @55 ##.## CVAL @61 '*'
      DISPLAY '* COEFICIENT AND T_STATISTIC ON THE CONSTANT:' @61 '*'
      DISPLAY '*' @3 ###.##### %BETA(1) @20 ###.### T_STAT1 @61 '*'
      DISPLAY '* COEFICIENT AND T_STATISTIC ON THE DMU:' @61 '*'
      DISPLAY '*' @3 ###.##### %BETA(2) @20 ###.### T_STAT2 @61 '*'
      DISPLAY '* COEFICIENT AND T_STATISTIC ON THE TREND:' @61 '*'
      DISPLAY '*' @3 ###.##### %BETA(3) @20 ###.### T_STAT3 @61 '*'
      DISPLAY '* COEFICIENT AND T_STATISTIC ON THE DTB:' @61 '*'
      DISPLAY '*' @3 ###.##### %BETA(4) @20 ###.### T_STAT4 @61 '*'
      }
   IF (DET.EQ.2) {
      COMPUTE TESTSTATA=(%BETA(5)-1.)/SQRT(%SEESQ*%XX(5,5))
      DISPLAY '* PERRON TEST FOR A UNIT ROOT FOR' %LABEL(SERIES) 'WITH' LAG 'LAGS:' @55 ##.#### TESTSTATA @61 '*'
      DISPLAY '* AT LEVEL' #.## SIGNDF @20 'AND FOR LAMBDA' #.# LAMBDA  @61 '*'
      DISPLAY '* THE TABULATED CRITICAL VALUE:' @55 ##.## CVAL @61 '*'
      DISPLAY '* COEFICIENT AND T_STATISTIC ON THE CONSTANT:' @61 '*'
      DISPLAY '*' @3 ###.##### %BETA(1) @20 ###.### T_STAT6 @61 '*'
      DISPLAY '* COEFICIENT AND T_STATISTIC ON THE DMU:' @61 '*'
      DISPLAY '*' @3 ###.##### %BETA(2) @20 ###.### T_STAT7 @61 '*'
      DISPLAY '* COEFICIENT AND T_STATISTIC ON THE TREND:' @61 '*'
      DISPLAY '*' @3 ###.##### %BETA(3) @20 ###.### T_STAT8 @61 '*'
      DISPLAY '* COEFICIENT AND T_STATISTIC ON THE DTS:' @61 '*'
      DISPLAY '*' @3 ###.##### %BETA(4) @20 ###.### T_STAT9 @61 '*'
      }
   IF (DET.EQ.3) {
      COMPUTE TESTSTATB=(%BETA(6)-1.)/SQRT(%SEESQ*%XX(6,6))
      DISPLAY '* PERRON TEST FOR A UNIT ROOT FOR' %LABEL(SERIES) 'WITH' LAG 'LAGS:' @55 ##.#### TESTSTATB @61 '*'
      DISPLAY '* AT LEVEL' #.## SIGNDF @20 'AND FOR LAMBDA' #.# LAMBDA  @61 '*'
      DISPLAY '* THE TABULATED CRITICAL VALUE:' @55 ##.## CVAL @61 '*'
      DISPLAY '* COEFICIENT AND T_STATISTIC ON THE CONSTANT:' @61 '*'
      DISPLAY '*' @3 ###.##### %BETA(1) @20 ###.### T_STAT10 @61 '*'
      DISPLAY '* COEFICIENT AND T_STATISTIC ON THE DMU:' @61 '*'
      DISPLAY '*' @3 ###.##### %BETA(2) @20 ###.### T_STAT11 @61 '*'
      DISPLAY '* COEFICIENT AND T_STATISTIC ON THE TREND:' @61 '*'
      DISPLAY '*' @3 ###.##### %BETA(3) @20 ###.### T_STAT12 @61 '*'
      DISPLAY '* COEFICIENT AND T_STATISTIC ON THE DT:' @61 '*'
      DISPLAY '*' @3 ###.##### %BETA(4) @20 ###.### T_STAT13 @61 '*'
      DISPLAY '* COEFICIENT AND T_STATISTIC ON THE DTB:' @61 '*'
      DISPLAY '*' @3 ###.##### %BETA(5) @20 ###.### T_STAT14 @61 '*'
      }
DISPLAY '**************************************************************'
DISPLAY


END PERRON







