/* ** DESCRIPTION: ** ** Version 1.1: February 29, 1996 ** ** This program accompanies the paper ** ** "INCREASING SEASONAL VARIATION: UNIT ROOTS AND SHIFTS IN MEAN AND TRENDS" ** ** Be sure to read the following instructions before you try to run the pro- ** gram. ** ** 1. WHAT DO YOU NEED ? ** To run the program you need a computer on which GAUSS is installed. We have ** tested the program and it runs with GAUSS 386i, versions 3.01 and 3.10. If ** you use another version of GAUSS you might have to make some changes before ** the program will run on your computer. ** ** 2. INSTALLATION: ** => Copy this file from the network to your harddisk ( on our network ** this can be done using FTP, but this may vary per network). ** => Start GAUSS. ** => Go to the directory that contains the file that you have retreived ** from the network. ** => Start the program by typing (in the GAUSS command-mode): ** RUN [FILENAME] ** Where [FILENAME] is the name of the program-file. ** ** 3. CONFIGURATION ** Be sure that ANSI.SYS is installed in your CONFIG.SYS, otherwise the menus ** will not be displayed properly. If you have not installed ANSI.SYS, add the ** following line to your CONFIG.SYS file: ** DEVICE = C:\DOS\ANSI.SYS (Assuming DOS is installed in C:\DOS) ** ** If you have any problems running the program, or have detected an error, ** please send an e-mail to Philip Hans Franses: ** franses@ect.few.eur.nl ** or Bart Hobijn: ** hobijnb@fasecon.econ.nyu.edu ** We hope this would not be necessary. */ /* ** Increasing Seasonal Variation, Simulation Program. Version 1, January 1996 ** ** Philip Hans Franses and Bart Hobijn. ** */ new; Closeall; Screen on; Call CsrType(0); ContBool = 1; DumFile = "dummy"; Vnames = { c }; prec = 4; ISVHelp; Do While (ContBool == 1); @ Initializing parameters @ { s , T , T1 , n , OutFile } = ISVPara; const = Ones( T , 1 ); dum = Eye(s); dum = (Ones( (T./s) , 1 )).*.(dum[.,2:s]); trend = SeqA( 1 , 1 , T ); tbdum = zeros( T1 , 1 )|Ones( T-T1 , 1 ); tbconst = tbdum.*const; @ constant after break @ tbtrend = tbdum.*trend; @ trend after break @ tbdum = tbdum.*dum; @ dummies after break @ tbdtrend = tbdum.*trend; @ dummy-trend after break @ extdum = zeros( T1 , s )|eye( s )|Zeros((T-T1-s),s); @ s observations after break not relevant in test regression @ @ Building screen @ WinInfo("Increasing Seasonal Variation, Simulation Program"); Locate 6,1; PrintInv("Estimated time needed : ");""; PrintInv("Simulation (of "$+FToCV(N,7,0)$+"): "); Locate 6,30; "not yet computed"; Locate 7,30; "not yet simulating"; Locate 25,1; PrintInv("ENTER to interrupt program"); @ Generating polynomial lags @ Locate 4,1; PrintBld("Generating polynomial lags"); factor = Zeros( s+2 , 3 ); factor[2,1] = 1; factor[s+2,1] = -1; factor[s+1:s+2,2] = (1|-1); factor[1:2,3] = (1|-1); factor[s+1:s+2,3] = (-1|1); @ Creating dummy-file @ Locate 4,1; PrintBld("Creating Dummy-files for results."); Col = 0.1*N; Create fh=^DumFile With ^Vnames,Col,8; NoTests = 18; i = 0; Do While ( i .< NoTests ); i=i+1; Call WriteR( fh , 0.75.*Ones(1,col) ); EnDo; @ i @ @ Opening file for both @ @ reading and writing @ Close(fh); open fh=^DumFile for Update; @ Starting time @ tstart = HSEC ; Days = 0 ; tprev = tstart; @ Starting simulations @ Sim = 0; Do While (Sim .< N); Locate 4,1; PrintBld("Generating series.... "); Y = ISVGenr( s , T+s+1 , (N-Sim) ); @ Initializing matrix for test-@ @ results @ TestRes = Zeros( NoTests , Cols( Y ) ); @ Regressions @ Locate 4,1; PrintBld("Computing test-statistics... "); i = 0; Do While ( i .< MinC( (N-Sim)|(Cols(Y))) ); i = i+1; @ Simulation counter @ If ( Sim == 0 ) and ( i == 1 ); Locate 7,30; " "; EndIf; Locate 7,30; (Sim+i); MuCnt = 0; Do While ( MuCnt < 3 ); MuCnt = MuCnt + 1; @ Screen output off @ Screen off; If (MuCnt == 1); mu = const~dum~extdum; ElseIf (MuCnt == 2); mu = const~dum~extdum~(const.*trend); Else; mu = const~dum~extdum~(const.*trend)~(dum.*trend); EndIf; TBCnt = 0; Do While (TBCnt < 2); TBCnt = TBCnt+1; If (TBCnt == 1); TBmu = tbconst~tbdum; Else; TBmu = tbconst~tbdum~tbtrend~tbdtrend; EndIf; @ Generating y[l,m] series @ LagY = LagMat( Y[.,i] , s+1 ); LagY = LagY*factor; X1 = LagY[.,1:(Cols(LagY)-1)]; X1 = X1~Mu~TBMu; Y1 = LagY[.,Cols(LagY)]; B1 = Y1/X1; @ SSR @ S1 = (Y1-X1*B1); S1 = Moment( S1 , 1 ); @ Degrees of freedom @ Df1= T-Cols(X1); @ T-values ã1 and ã2 @ T1_2 = InvPD(Moment(X1,1)).*(S1./df1); T1_2 = SqRt( Diag(T1_2) ); T1_2 = B1[1:2]./T1_2[1:2]; TestRes[2.*(MuCnt-1)+TBCnt,i] = T1_2[1]; TestRes[6+2.*(MuCnt-1)+TBCnt,i] = T1_2[2]; X0 = mu~Tbmu ; B0 = Y1/X0; S0 = Moment((Y1-X0*B0),1); df0= T-Cols(X0); F = ((S0-S1)./S1).*(df1./(df0-df1)); TestRes[12+2.*(MuCnt-1)+TBcnt,i] = F; @ Possibility to stop program @ Screen on; WinBreak; Screen off; EnDo; @ TBCnt @ EnDo; @ MuCnt @ @ Updating estimated @ @ time needed @ Screen on; If ( Sim == 0 ) and ( i == 1 ); Locate 6,30; " "; EndIf; tnow = HSec; If (tnow < tprev); Days = Days+1; EndIf; EstTime = Trunc(( tnow-tstart+Days.*(100*60*60*24) )./(Sim+i)); EstTime = (N-Sim-i).*EstTime; Locate 6,30; " "; Locate 6,30; ETStr( EstTime ); tprev= Tnow; EnDo; @ i @ Sim = Sim + i; Clear LagY, X1, X0, Y1, mu; @ Writing results output file @ Locate 4,1; PrintBld("Writing results to file... "); i = 0; p = WinPrc("Writing to file...", 12 , 40 ); Do While ( i .< NoTests ); i = i+1; Res = SeekR( fh , i ); Res = (ReadR(fh,1)'); If ( ( Sim-Cols(TestRes) ) == 0 ); Res = TestRes[i,.]'; ElseIf ( ( Sim-Cols(TestRes) ) < Col ); Res = Res[(Col-Sim+Cols(TestRes)+1):Col]; Res = (TestRes[i,.]')|Res ; Else; Res = (TestRes[i,.]')|Res ; EndIf; Res = SortC( Res , 1 ); If ( Sim < col ); Res = (0.75.*Ones((Col-Sim),1))|Res; EndIf; If ( i <= 12 ); Res = Res[1:Col]; Else; Res = Res[(Rows(Res)-Col+1):Rows(Res)]; EndIf; Call SeekR( fh , i ); Res = WriteR( fh , Res' ); WinPrcMs( Trunc(100.*i./NoTests) , p ); If ( Res /= 1 ); ErrorLog("Wrong output to file"); End; EndIf; EnDo; EnDo; @ Sim @ Clear res, TestRes ; @ Constructing percentiles @ Cls; WinInfo("Increasing Seasonal Variation, Simulation Program"); Locate 4,1; PrintBld("Constructing percentiles"); prct = { 0.01 , 0.025 , 0.05 , 0.1 }; prct = prct.*N; prcf = Col-Rev(prct)+1; prct = prct'; prcf = prcf'; TestRes = Zeros( NoTests , Cols(prct) ); i = 0; p = WinPrc("Completed...", 12 , 40 ); Do While ( i .< NoTests ); i = i+1; Res = SeekR( fh , i ); Res = ReadR(fh,1); If ( i <= 12 ) ; TestRes[i,.] = Res[prct]; Else; TestRes[i,.] = Res[prcf]; EndIf; WinPrcMs( Trunc(100.*i./NoTests) , p ); EnDo; @ Deleting dummy-files @ Cls; WinInfo("Increasing Seasonal Variation, Simulation Program"); Locate 4,1; PrintBld("Deleting dummy-files"); Locate 5,1; closeall; dos del dummy.dat; dos del dummy.dht; @ Generating output @ Cls; WinInfo("Increasing Seasonal Variation, Simulation Program"); Locate 4,1; PrintBld("Generating output to file:"); Locate 5,1; OutFile; tnow = HSec; If (tnow < tprev); Days = Days+1; EndIf; EstTime = Trunc(( tnow-tstart+Days.*(100*60*60*24) )); Screen off; Output file=^OutFile Reset; ISVOut( s , T , N , TestRes , EstTime); Output off; Screen on; @ Another experiment ? @ Cls; WinInfo("Increasing Seasonal Variation, Simulation Program"); Question = "Do want to do another experiment ?"; ContBool = WinYesNo( Question , 7 , 34 ); EnDo; @ ContBool @ @ Final screen @ Cls; WinInfo("Increasing Seasonal Variation, Simulation Program"); Locate 4,1; PrintBld("End Of Program, CTRL-F3 to view output-file."); Locate 5,1; Call CsrType(1); /* ** PROCEDURE WINYESNO: ** ** Purpose: ** Interactive Yes or No question. ** ** Format: ** Bool = WinYesNo( Question , x , y ); ** ** Input: ** Question string, question to be asked to user. ** X scalar, row for upper-left corner of window. ** Y scalar, column fo upper-left corner of window. ** ** Output: ** Bool logical scalar, 1 if answered YES and 0 in answered NO. ** */ Proc(1) = WinYesNo( Question , X , Y ); Local i , width, height, bool ; bool = 1; width = MaxC((StrLen(Question)+4)|12); height = 7 ; If ( ( (X+Height-1) > 27 ) Or ( (Y+Width-1) > 80 ) ); ErrorLog("Window does not fit on screen"); End; EndIf; WinInit( X , Y , height , width ); Locate (X+2),(Y+2) ; print Question ; Locate (X+height-2),(Y-4+Trunc(width./2)); PrintDos"\27[7mYes\27[0m No"; i = key; Do Until ( i == 13 ); If ( i == 1077 ); If ( Bool == 1 ); Bool = 0 ; Locate (X+height-2),(Y-4+Trunc(width./2)); PrintDos"Yes \27[7mNo\27[0m"; EndIf; i = key ; ElseIf ( i == 1075 ); If ( Bool == 0 ); Bool = 1 ; Locate (X+height-2),(Y-4+Trunc(width./2)); PrintDos"\27[7mYes\27[0m No"; EndIf; i = key ; ElseIf ( (i == 121) Or ( i == 89 ) ); If ( Bool == 0 ); Bool = 1; Locate (X+height-2),(Y-4+Trunc(width./2)); PrintDos"\27[7mYes\27[0m No"; EndIf; i = key ; ElseIf ( (i == 110) Or ( i == 78 ) ); If ( Bool == 1 ); Bool = 0 ; Locate (X+height-2),(Y-4+Trunc(width./2)); PrintDos"Yes \27[7mNo\27[0m"; EndIf; i = key ; Else; i = key ; EndIf; EnDo; RetP( Bool ); EndP; /* ** PROCEDURE WINCHC: ** ** Purpose: ** Interactive choice window ** ** Format: ** Ch = WinChc( question , ch1 , ch2 , ch3 , ch4 , X , Y ) ** ** Input: ** Question string, question to ask. ** Ch1 string, first choice ** Ch2 string, second choice ** Ch3 string, third choice ** Ch4 string, fourth choice ** X scalar, row of upper left corner. ** Y scalar, column upper left corner. ** ** Output: ** Ch scalar, choice made by user. ** */ Proc(1) = WinChc( question , ch1 , ch2 , ch3 , ch4 , X , Y ); Local i , N , height , width , ch , ch0 ; If ( ch1 $== "" ); ErrorLog("No question to ask"); End; Else; If ( ch2 $== "" ); ErrorLog("No choice to make"); End; Else; If ( ch3 $== "" ); N = 2; Ch1 = "1 "$+Ch1 ; Ch2 = "2 "$+Ch2 ; Else; If ( ch4 $== "" ); N = 3 ; Ch1 = "1 "$+Ch1 ; Ch2 = "2 "$+Ch2 ; Ch3 = "3 "$+Ch3 ; Else; N = 4; Ch1 = "1 "$+Ch1 ; Ch2 = "2 "$+Ch2 ; Ch3 = "3 "$+Ch3 ; Ch4 = "4 "$+Ch4 ; EndIf; EndIf; EndIf; EndIf; Height = (7+2*N); Width = (StrLen(ch1))|(StrLen(ch2))|(StrLen(ch3)); Width = Width|(StrLen(ch4))|(StrLen(Question))|29; Width = 4+MaxC(Width); WinInit( X , Y , height , width ); Locate (X+2),(Y+2); question; Locate (X+4),(Y+2); ch1 ; Locate (X+6),(Y+2); ch2 ; If ( N == 2 ); Locate (X+8),(Y+2); " Enter confirms choice"; ElseIf ( N == 3 ); Locate (X+8),(Y+2); ch3; Locate (X+10),(Y+2); " Enter confirms choice"; Else; Locate (X+8),(Y+2); ch3; Locate (X+10),(Y+2); ch4; Locate (X+12),(Y+2); " Enter confirms choice"; EndIf; ch = 1; ch0 = 2 ; winchmes( ch1 , ch2 , ch3 , ch4 , X , Y , ch , ch0 ); i = key; Do Until ( i == 13 ); If ( i == 1072 ); If ( ch > 1 ); ch0= ch ; ch = ch-1 ; winchmes( ch1 , ch2 , ch3 , ch4 , X , Y , ch , ch0 ); EndIf; i = key ; ElseIf ( i == 1080 ); If ( ch < N ); ch0 = ch ; ch = ch+1; winchmes( ch1 , ch2 , ch3 , ch4 , X , Y , ch , ch0 ); EndIf; i = key ; ElseIf ( i == 49 ); ch0 = ch; ch = 1; winchmes( ch1 , ch2 , ch3 , ch4 , X , Y , ch , ch0 ); i = key ; ElseIf ( i == 50 ); ch0 = ch; ch = 2; winchmes( ch1 , ch2 , ch3 , ch4 , X , Y , ch , ch0 ); i = key ; i = key ; ElseIf (( i == 51 ) And ( N >= 3 ) ); ch0 = ch; ch = 3; winchmes( ch1 , ch2 , ch3 , ch4 , X , Y , ch , ch0 ); i = key ; ElseIf (( i == 52 ) And ( N == 4 ) ); ch0 = ch; ch = 4; winchmes( ch1 , ch2 , ch3 , ch4 , X , Y , ch , ch0 ); i = key ; Else; i = key ; EndIf; EnDo; RetP( ch ); EndP; /* ** PROCEDURE WINCHMES: ** ** Additional procedure to winchc. ** */ Proc(0) = WinChMes( ch1 , ch2 , ch3 , ch4 , X , Y , newch , oldch ); Local b ; Locate (X+2+2*Oldch),(Y+2); If ( Oldch == 1 ); ch1 ; ElseIf ( Oldch == 2 ); ch2 ; ElseIf ( Oldch == 3 ); ch3 ; Else; ch4; EndIF; Locate (X+2+2*newch),(Y+2); If ( Newch == 1 ); PrintDos "\27[7m"$+ch1$+"\27[0m" ; ElseIf ( Newch == 2 ); PrintDos "\27[7m"$+ch2$+"\27[0m" ; ElseIf ( Newch == 3 ); PrintDos "\27[7m"$+ch3$+"\27[0m" ; Else; PrintDos "\27[7m"$+ch4$+"\27[0m" ; EndIF; EndP; /* ** PROCEDURE WININIT: ** ** Purpose: ** Initializing interactive window. ** ** Format: ** WinInit( X , Y , height , width ) ** ** Input: ** X scalar, row where window is placed ** Y scalar, column where window is placed ** height scalar, height of window. ** width scalar, width of window. ** ** Output ** none */ Proc(0) = WinInit( X , Y , height , width ); Local i , topstr , midstr , botstr ; topstr = "É"; i = 1; Do While ( i < (width-1) ); i = i+1 ; topstr = topstr$+"Í"; EnDo; topstr = topstr$+"»"; midstr = "º"; i = 1; Do While ( i < (width-1) ); i = i+1 ; midstr = midstr$+" "; EnDo; midstr = midstr$+"º"; botstr = "È"; i = 1; Do While ( i < (width-1) ); i = i+1 ; botstr = botstr$+"Í"; EnDo; botstr = botstr$+"¼"; i = -1 ; Do While ( i < (height-1) ); i=i+1; Locate X+i,Y ; If ( i == 0 ); Topstr ; ElseIf ( i == (height-1) ); BotStr ; Else; Midstr; EndIf; EnDo; EndP; /* ** PROCEDURE WINVEC: ** ** Purpose: ** Interactive vector-input. ** ** Format: ** V = WinVec(Question,vname,X,Y,N,intgr); ** ** Input: ** Question string, question to be asked to user ** vname string, name of the vector to be put in. ** X scalar, row for upper-left corner of window. ** Y scalar, column fo upper-left corner of window. ** N scalar, number of elements of vector. ** intgr logical scalar, 1 if only integers are accepted, 0 otherwise. ** ** Output: ** V [ N x 1 ]-vector. ** */ Proc(1) = WinVec( Question , VName , X , Y , N , intgr ); Local width , height , i , inp , outstr , V ; height = 10 ; width = MaxC((19+StrLen(VName))|27|(StrLen(Question)+2)); WinInit( X , Y , height , width ); Locate (X+2),(Y+2) ; Question; Locate (X+4),(Y+2) ; if (intgr == 0); "Input:"; ElseIf ( intgr == 1 ); "Input (only integers) :"; Else; ErrorLog(" Wrong input in procedure "); End; EndIf; outstr = Vname$+FToS(N," [%*.*lfx1]-vector",1,0); Locate (X+5),(Y+2) ; outstr ; i = 0; Do While ( i < N ); i = i+1; Outstr = VName$+FToS(i,"[%*.*lf] = ",1,0); If ( intgr == 0 ); Locate (X+7),(Y+2); Outstr$+" "; Locate (X+7),(Y+StrLen(VName)+9) ; inp = con(1,1); Else; inp = 0.1 ; Do Until ( Trunc( inp ) == inp ); Locate (X+7),(Y+2); Outstr$+" "; Locate (X+7),(Y+StrLen(VName)+9) ; inp = con(1,1); EnDo; EndIf; If ( i == 1 ); V = inp ; Else; V = V|inp ; EndIf; EnDo; RetP( V ); EndP; /* ** PROCEDURE WININFO: ** ** Purpose: ** Information-window at top of screen. ** ** Format: ** WinInfo( Message ); ** ** Input: ** Message string, maximum 76 characters. ** ** Output: ** None ** */ Proc( 0 ) = WinInfo( Message ); Local y ; Wininit( 1 , 1 , 3 , 80 ); Locate 1,4 ; PrintDos"\27[7m INFORMATION \27[0m"; If ( StrLen(Message) > 76 ); ErrorLog("String too long to fit in information-window"); End; EndIf; Locate 2,3 ; Message ; EndP; /* ** PROCEDURE WINSCAL: ** ** Purpose: ** Interactive scalar input. ** ** Format: ** S = Winscal( Question , vname , X , Y , intgr ); ** ** Input: ** Question string, question to be asked to user ** vname string, name of the vector to be put in. ** X scalar, row for upper-left corner of window. ** Y scalar, column fo upper-left corner of window. ** intgr logical scalar, 1 if only integers are accepted, 0 otherwise. ** ** Output: ** S Scalar. ** */ Proc(1) = WinScal( Question , vname , X , Y , intgr ); Local S , height , width ; Height = 7; Width = 4+MaxC(StrLen(Question)|(StrLen(Vname)+13)); WinInit( X , Y , height , width ) ; Locate ( X+2 ),( Y+2 ); Question ; If ( Intgr == 1 ); S = 1.5; Do Until ( Trunc(S) == S ); Locate ( X+4 ),( Y+2 ); vname$+" = "; Locate ( X+4 ),( Y+5+StrLen(Vname) ); S = Con(1,1); EnDo; Else; Locate ( X+4 ),( Y+2 ); vname$+" = "; Locate ( X+4 ),( Y+5+StrLen(Vname) ); S = Con(1,1); EndIf; RetP( S ); EndP; /* ** PROCEDURE WININFCL: ** ** Purpose: ** Clearing information-window. ** */ Proc(0) = wininfcl ; Locate 2,3 ; " "; EndP; /* ** PROCEDURE WININFMS: ** ** Purpose: ** message in information-window. ** ** Format: ** WinInfMs(Message); ** ** Input: ** Message string, maximum 76 characters message. ** */ Proc(0) = WinInfMs( Message ); Local b ; wininfcl ; If ( StrLen(Message) > 76 ); ErrorLog("String too long to fit in information-window"); End; EndIf; Locate 2,3 ; Message ; EndP; /* ** PROCEDURE WINSLCT: ** ** Purpose: ** Interactive selection from a vector ** ** Format: ** St = WinSlct(Question,vname,t,prec,n,X,Y); ** ** Input: ** Question string, containing question to be asked to user. ** vname string, containing name of vector from which elements are ** selected. ** t [Lx1]-vector, containing values to be selected. (L>=N) ** prec scalar, number of decimals to be displayed in selection box. ** n scalar, number of elements to be selected. ** X scalar, row for upper left corner. ** Y scalar, column for upper left corner ** ** Output: ** St [Nx1]-vector, containing selected values from t. ** */ Proc(1) = WinSlct( Question , vname , t , prec , n , X , Y ); Local L , field , height , hght1 , hght2 , width , wdth1 , wdth2 , st , i , iscrl , j , jscrl , k ; L = Rows( t ); If ( N > L ); ErrorLog(" Wrong input in procedure "); End; EndIf; hght1 = 5 ; hght2 = (N+2) ; height = 6+MaxC(hght1|hght2); field = ( Trunc( Ln( MaxC(ABS(t)) )./Ln( 10 ) ) )+prec+1; wdth1 = 2+MaxC((field)|(5+StrLen(Vname))); wdth2 = 2+MaxC((field)|(12)); width = 4+MaxC((StrLen(Question))|(wdth1+wdth2+1)); WinInit( X , Y , height , width ); WinInit( (X+4) , (Y+2) , hght1 , wdth1 ); WinInit( (X+4) , (Y+3+wdth1) , hght2 , wdth2 ); Locate (X+2),(Y+2) ; Question ; Locate (X+4),(Y+4) ; PrintDos "\27[7m"$+vname$+"=\27[0m"; Locate (X+4),(Y+5+wdth1) ; PrintDos "\27[7mSELECTED\27[0m"; format /ld field,prec; j = 0; Do While ( j < N ); j = j+1; i = 1; iscrl = 2 ; jscrl = 0 ; Do While ( jscrl < 3 ); jscrl = jscrl+1; Locate ( X+4+jscrl ),(Y+3) ; If ( Iscrl == jscrl ); PrintDos"\27[7m"; Locate ( X+4+jscrl ),(Y+3) ; print t[(i+jscrl-1)]; printdos"\27[0m"; Else; Print t[(i+jscrl-1)]; Endif; EnDo; k = key ; Do Until ( k == 13 ); If ( K == 1072 ) ; If ( iscrl > 1 ); iscrl = iscrl-1 ; Else; If ( i > 1 ); i = i-1 ; EndIf; EndIf; K = Key ; jscrl = 0 ; Do While ( jscrl < 3 ); jscrl = jscrl+1; Locate ( X+4+jscrl ),(Y+3) ; If ( Iscrl == jscrl ); PrintDos"\27[7m"; Locate ( X+4+jscrl ),(Y+3) ; print t[(i+jscrl-1)]; printdos"\27[0m"; Else; Print t[(i+jscrl-1)]; Endif; EnDo; ElseIf ( K == 1080 ) ; If ( iscrl < 3 ); iscrl = iscrl+1 ; Else; If ( i < (L-2) ); i = i+1 ; EndIf; EndIf; K = Key ; jscrl = 0 ; Do While ( jscrl < 3 ); jscrl = jscrl+1; Locate ( X+4+jscrl ),(Y+3) ; If ( Iscrl == jscrl ); PrintDos"\27[7m"; Locate ( X+4+jscrl ),(Y+3) ; print t[(i+jscrl-1)]; printdos"\27[0m"; Else; Print t[(i+jscrl-1)]; Endif; EnDo; Else; k = key ; EndIf; EnDo ; If ( j == 1 ); st = t[(i+iscrl-1)]; Else; st = st|t[(i+iscrl-1)]; EndIf; Locate ( X+4+j ) , ( Y+4+wdth1 ); print st[j]; EnDo; retp(st); endP; /* ** PROCEDURE WINSTR: ** ** Purpose: ** Interactive string input. ** ** Format: ** S = Winscal( Question , vname , X , Y , l ); ** ** Input: ** Question string, question to be asked to user ** vname string, name of the string to be entered. ** X scalar, row for upper-left corner of window. ** Y scalar, column fo upper-left corner of window. ** l scalar, maximum length of string S. ** ** Output: ** S String. ** */ Proc(1) = WinStr( Question , vname , X , Y , l ); Local S , height , width ; Height = 7; Width = 4+MaxC(StrLen(Question)|(StrLen(Vname)+l+6)); WinInit( X , Y , height , width ) ; Locate ( X+2 ),( Y+2 ); Question ; S = 1.5; Locate ( X+4 ),( Y+2 ); vname$+" ="$+Chrs(32.*Ones(1,l)); Locate ( X+4 ),( Y+5+StrLen(Vname) ); S = ConS; RetP( S ); EndP; /* ** PROCEDURE WINPRC: ** ** Purpose: ** Percentage window initialization. ** ** Format: ** p = WinPrc( message , x , y ); ** ** Input: ** message string, message to be displayed in window. ** X scalar, row for upper-left corner of window. ** Y scalar, column fo upper-left corner of window. ** ** Output: ** p [2 x 1]-vector containing position information for ** changing percentages. ** */ Proc(1) = WinPrc( message , X , Y ); Local i , width, height, p ; width = MaxC((StrLen(message)+4)|18); height = 6 ; If ( ( (X+Height-1) > 27 ) Or ( (Y+Width-1) > 80 ) ); ErrorLog("Window does not fit on screen"); End; EndIf; WinInit( X , Y , height , width ); Locate (X+1),(Y+2) ; print message ; Locate (X+height-3),(Y-7+Trunc(width./2)); "0% 100%"; Locate (X+height-2),(Y-5+Trunc(width./2)); chrs(177~(176.*ones(1,9))); P=(X+height-2)|(Y-5+Trunc(width./2)); RetP( P ); EndP; /* ** PROCEDURE WINPRCMS: ** ** Purpose: ** Changes percentage in percentage-window. ** ** Format: ** WinPrcMs(prc,p) ; ** ** Input: ** prc scalar, percentage to be displayed. (0-100) ** p [2x1]-vector, containing position information of percentage window. ** */ Proc(0) = WinPrcMs(prc,p); Local X , Y , d , prcstr ; d = trunc( prc./ 10 ) ; If ( prc < 0 ) or ( prc > 100 ); ErrorLog("no percentage input"); End; EndIf; If ( d == 10 ); prcstr = 219.*Ones(1,10); ElseIf ( d == 0 ); prcstr = 177 ; Else; prcstr = (178.*Ones(1,d))~177; EndIf; prcstr = chrs(prcstr); Locate P[1],P[2] ; prcstr ; EndP; /* ** PROCEDURE WINCNT: ** ** Purpose: ** counter window initialization. ** ** Format: ** p = WinCnt( message , x , y , cnt ); ** ** Input: ** message string, message to be displayed in window. ** X scalar, row for upper-left corner of window. ** Y scalar, column fo upper-left corner of window. ** cnt scalar, counter-value to be displayed. ** ** Output: ** p [2 x 1]-vector containing position information for ** changing percentages. ** */ Proc(1) = WinCnt( message , X , Y , cnt ); Local i , width, height, p ; width = MaxC((StrLen(message)+4)|12); height = 5 ; If ( ( (X+Height-1) > 27 ) Or ( (Y+Width-1) > 80 ) ); ErrorLog("Window does not fit on screen"); End; EndIf; WinInit( X , Y , height , width ); Locate (X+1),(Y+2) ; print message ; Locate (X+height-2),(Y-3+Trunc(width./2)); cnt = FToCV(cnt,trunc(ln(maxc(10|cnt))./ln(10)+1),0); format /ld 6,0 ; $cnt; P=(X+height-2)|(Y-3+Trunc(width./2)); RetP( P ); EndP; /* ** PROCEDURE WINCNTMS: ** ** Purpose: ** Changes counter in counter-window. ** ** Format: ** Wincntms(cnt,p) ; ** ** Input: ** prc scalar, counter value to be displayed. ** p [2x1]-vector, containing position information of percentage window. ** */ Proc(0) = WinCntMs(cnt,p); Local cntstr ; cntstr = FtoCV(cnt,trunc(ln(maxc(10|cnt))./ln(10)+1),0); Locate P[1],P[2] ; format /ld 6,0 ; $cntstr ; EndP; /* ** PROCEDURE WINCLS: ** ** Purpose: ** Clears whole screen, but information window. ** ** Format: ** WinCls; ** ** No input or output. ** */ Proc(0) = WinClS; Scroll (4|1|25|80|-40|7); EndP; /* PROCEDURE WINBREAK: ** ** Purpose: ** Program termination. ** ** Format: ** WinBreak ** ** No input or output ** */ Proc(0) = WinBreak ; Local ch , i ; i = key ; If ( i == 13 ); Ch = WinYesNo("Quit Program ?",10,32); If ( Ch == 1 ); ClS; ErrorLog("Program stopped by user"); End; EndIf; EndIf; EndP; /* ** Procedure PrintInv: ** ** Purpose: ** Displays string in reverse video mode. ** ** Format: ** PrintInv(str); ** ** Input: ** str string to be displayed ** ** no output */ Proc(0) = PrintInv(str) ; Local outstr ; outstr = "\27[7m"$+str$+"\27[0m"; PrintDos outstr ; EndP; /* ** Procedure PrintBld: ** ** Purpose: ** Displays string bold. ** ** Format: ** PrintBld(str); ** ** Input: ** str string to be displayed ** ** no output */ Proc(0) = PrintBld(str) ; Local outstr ; outstr = "\27[1m"$+str$+"\27[0m"; PrintDos outstr ; EndP; /* ** Procedure PrintBlk: ** ** Purpose: ** Displays string blinking. ** ** Format: ** PrintBlk(str); ** ** Input: ** str string to be displayed ** ** no output */ Proc(0) = PrintBlk(str) ; Local outstr ; outstr = "\27[5m"$+str$+"\27[0m"; PrintDos outstr ; EndP; Proc(0) = wait; waitc; EndP; /* ** DelC: ** Deleting colums from matrix. */ Proc(1) = DelC( X , c ); Local e ; e = SeqA( 1 , 1 , cols(x) ); e = SumC( (e.==c')' ); X = ( DelIf( X' , e ) )'; RetP(X); EndP; /* ** Procedure DELRC: ** ** Purpose: ** Deletes row and/or column from matrix. ** ** Format: ** Y = DelRC( X , R , C ); ** ** Input: ** X [NxK]-matrix. ** R scalar, number of row to be deleted. ** C scalar, number of column to be deleted. ** ** Output: ** Y [(N-1)x(K-1)], [(N-1)xK] or [Nx(K-1)]-matrix, X with row and/or ** column deleted ** ** Note: ** If only a row has to be deleted, then set C=0 and vice versa. ** */ Proc(1) = DelRC( X , R , C ); Local N , K , Y , e ; N = Rows(X); K = Cols(X); If ( R/=0 ); @ Verwijderen R-de rij @ e = Zeros( N , 1 ); e[R] = 1 ; Y = DelIf( X , e ); Else; Y = X ; EndIf; If ( C/=0 ); @ verwijderen K-de rij @ e = Zeros( K , 1 ); e[C] = 1 ; Y = (DelIf( Y' , e ))'; EndIf; RetP( Y ); EndP; /* ** Seasonal Unit Roots: ** Constructing matrix with lagged variable. ** ** Output: ** matrix with l+1 colums: ** first column X[t-l] ** last column X[t] */ Proc(1) = LagMat( X , l ); Local Y , vr , vc , t ; l = l+1; T = Rows( X ); vr = SeqA(l+1,1,T-l+1); vc = SeqA(1,1,l); vr = vr-vc'; Y = Submat( X , vr , 0 ); Y = reshape(Y , rows(vr) , cols(vr) ); RetP(Y); EndP; /* ** Seasonal Unit Roots, program 1: ** Generates series. ** ** Y = ISVGenr( s , T , MaxCols ); ** */ Proc(1) = ISVGenr( s , T , MaxCols ); Local Y , Y0 , NoSer , A ; /* ** The number of series generated is adjusted to the workspace available. */ NoSer = coreleft; NoSer = Trunc((NoSer./(2.5*T+50*s)-(s+4).*2)./8); NoSer = MinC( (MaxCols|NoSer) ); Y = RndN( (T+(20*s)) , NoSer ); Y0 = Zeros( s+1 , NoSer ); A = (Ones( 1 , NoSer )|Zeros( s , NoSer ))+ (Zeros(s-1,NoSer)|Ones( 1 , NoSer )|(-Ones(1,NoSer))); Y = RecSerAR( Y , Y0 , A ); Y = Y[(20*s+1):Rows(Y),.]; RetP( Y ); EndP; /* ** Increasing Seasonal Variation, Simulation Program: ** Help-procedure. ** */ Proc(0) = ISVHelp ; Cls; WinInfo("Increasing Seasonal Variation, Simulation Program"); Locate 7,8; PrintBld("INCREASING SEASONAL VARIATION"); Locate 9,35; PrintBld("Econometric Institute"); Locate 10,35; PrintBld("Erasmus University Rotterdam"); Locate 13,35; PrintBld("Monte Carlo Simulations"); Locate 14,35; PrintBld("version 1, January 1996"); Locate 17,35; PrintBld("Philip Hans Franses and Bart Hobijn"); Locate 18,35; "Correspondence:"; Locate 19,35; "Econometric Institute,"; Locate 20,35; "Erasmus University Rotterdam"; Locate 21,35; "P.O.Box 1738, NL-3000 DR Rotterdam"; Locate 22,35; "The Netherlands"; Locate 25,1; PrintInv("PRESS ANY KEY TO CONTINUE"); Wait; Cls; WinInfo("Increasing Seasonal Variation, Simulation Program, Help (screen 1)"); Locate 4,1; "Monte-Carlo program which generates critical values HEGY-test."; " s "; "DGP: (1 - B)(1 - B ) Y = e e => N(0,1) "; " t t t"; " for t = 1,..,T, s = 2,3,4,5,6,7,12 or 13."; "Test-equation"; " s s "; " (1 - B) (1 - B )Y = ã (1-B ) y + ã (1-B) y + "; " t 1 t-1 2 t-s "; " "; " s-1 s-1 "; " I [à + ä à D + ç + ä ç D t] + æ + u "; " t>T1 0 j=1 j jt 0 j=1 j jt t t "; " "; "where æ contains intercept, seasonal dummies and/or trend and/or dummy-trend"; " t"; "Equation estimated both unrestricted and under ç[i]=0 for all i=0..s-1"; " "; "Critical values computed for:"; "(i) t-tests: ã[1]=0 and ã[2]=0"; "(ii) F-test: ã[1]=ã[2]=0"; Locate 25,1; PrintInv("PRESS ANY KEY TO CONTINUE"); Wait; Cls; WinInfo("Increasing Seasonal Variation, Simulation Program, Help (screen 2)"); Locate 4,1; PrintBld("Parameter-choice:");" "; "You can specify both s and T, where T=M*s and M, i.e. the number of years,"; "can be chosen. Of course the number of replications, N, is also variable."; " "; PrintBld("Output:");" "; "The output will be written to an ASCII-file, the name of which can be speci"; "fied. If you also include a PATH then remember that all slashes have to be "; "double slashes. That is '\\' has to be '\\\\'!"; " "; PrintBld("Simulation:");" "; "The series generated will have a length of T+20s. The first 20s observations"; "will be discarded and are only used to start up the random-walk processes."; " "; PrintBld("Memory requirement:");" "; "Adjust N to a proper size in case of an out-of-"; "memory message. The program will make a dummy file containing simulation"; "results in the directory from which the program is run. This file is called"; "DUMMY.DAT with header file DUMMY.DHT. Be sure that there is enough space on"; "your hard-disk and that there are no other files with the same name in the "; "directory. If there are they will be overwritten and then deleted."; Locate 25,1; PrintInv("PRESS ANY KEY TO CONTINUE"); Wait; ClS; EndP; /* ** Increasing Seasonal Variation, Simulation Program: ** Output procedure. ** */ Proc(0) = ISVOut( s , T , N , OutMat , TimeUsed ); Local i, HeadCol1 , HeadCol2 , HeadRow1 , Mask , Omat , fmt , NoTests , HeadRow2 , HeadCol3 ; " "; "Critical values test statistics based on "$+FToCV(N,1,0) " Monte Carlo Simulations" " "; " s "; "DGP: (1 - B )(1 - B ) Y = e e => N(0,1) "; " t t t "; " for t = 1.."$+FToCV(T,1,0); " s = "$+FToCV(s,1,0); " "; "Test-equation"; " s s "; " (1 - B) (1 - B )Y = ã (1-B ) y + ã (1-B) y + "; " t 1 t-1 2 t-s "; " "; " s-1 s-1 "; " I [à + ä à D + ç + ä ç D t] + æ + u "; " t>T1 0 j=1 j jt 0 j=1 j jt t t "; " "; "legenda æ[t]:"; "(n)t : (no) trend "; "(n)dt : (no) dummy*trend"; " "; "post-break variables:"; "(n)pbt : (no) post-break trend, i.e. ç[i] i=0..s-1 is either (zero) or not."; " "; HeadCol1 = { "ã1" ,"ã2" ,"ã1 ï ã2" }; HeadCol2 = { "nt,ndt" , "t,ndt" , "t,dt" }; HeadCol3 = { "npbt" , "pbt" }; HeadCol1 = HeadCol1.*.Ones(6,1); HeadCol2 = Ones(3,1).*.(HeadCol2.*.ones(2,1)); HeadCol3 = Ones(9,1).*.HeadCol3; HeadRow1 = { "Test" "æ[t]" "break" 0.01 0.025 0.05 0.1 }; HeadRow2 = { "Test" "æ[t]" "break" 0.9 0.95 0.975 0.99 }; NoTests = Rows(HeadCol1); Mask = (0~0~0)~Ones(1,4); " "; "T-Tests:"; "-----------------------------------------------------------------------------"; fmt = {"-*.*s" 10 8 , "*.*f" 9 3 }; fmt = (fmt[1,.].*(1|1|1))|(fmt[2,.].*Ones(4,1)); call printfm( HeadRow1 , mask , fmt );""; "-----------------------------------------------------------------------------"; Omat = (HeadCol1[1:12]~HeadCol2[1:12]~HeadCol3[1:12]~OutMat[1:12,.]); fmt = {"-*.*s" 10 8 , "*.*f" 9 2 }; fmt = (fmt[1,.].*(1|1|1))|(fmt[2,.].*Ones(4,1)); call printfm( omat , mask , fmt ); "-----------------------------------------------------------------------------"; " "; " "; "F-Tests:"; "-----------------------------------------------------------------------------"; fmt = {"-*.*s" 10 8 , "*.*f" 9 3 }; fmt = (fmt[1,.].*(1|1|1))|(fmt[2,.].*Ones(4,1)); call printfm( HeadRow2 , mask , fmt );""; "-----------------------------------------------------------------------------"; Omat = (HeadCol1[13:18]~HeadCol2[13:18]~HeadCol3[13:18,.]~OutMat[13:18,.]); fmt = {"-*.*s" 10 8 , "*.*f" 9 2 }; fmt = (fmt[1,.].*(1|1|1))|(fmt[2,.].*Ones(4,1)); call printfm( omat , mask , fmt );""; "-----------------------------------------------------------------------------"; " "; ETStr(TimeUsed)$+" needed for simulations. "; EndP; /* ** Increasing Seasonal Variation, Simulation Program: ** Parameter-choice procedure ** ** { s , T , T1 , N , Outfile } = ISVpara; ** */ Proc(5) = ISVPara ; Local N , T , T1 , s , OutFile , Question , vname , X , Y ; Cls; WinInfo("Increasing Seasonal Variation: Choose Parameters and Output-file"); Locate 4,1; PrintBld("Use UP and DOWN arrows to select and ENTER to confirm choice."); Question = "Number of seasons ?"; vname = "s"; X = 6; Y = 1; s = { 2 , 3 , 4 , 5 , 6 , 7 , 12 , 13 }; s = WinSlct( Question , vname , s , 0 , 1 , X , Y ); Question = "Number of years ? (T=M*s)"; vname = "M"; X = 6; Y = 40; T = WinScal( Question , vname , X , Y , 1 ); T = T*s; Question = "Year of structural break (T1)?"; X = 9; Y = 30; T1 = SeqA( 2 , 1 , ((T./s)-4) ); T1 = WinSlct( Question , vname , T1 , 0 , 1 , X , Y ); T1 = T1*s; Question = "Number of replications ?"; vname = " N "; X = 12; Y = 23; N = { 100 , 500 , 1000 , 2500 , 5000 , 10000 , 25000 , 50000 , 100000 , 250000 , 500000 }; N = WinSlct( Question , vname , N , 0 , 1 , X , Y ); Locate 4,1; PrintBld("Type in PATH and NAME of output-file. "); Question = "Output-file ? (Do not specify extension (=.OUT))"; vname = "PATH\\\\FILE(.OUT)"; X = 9 ; Y = 3 ; outfile = WinStr( Question , vname , X , Y , 50 ); outfile = outfile$+".out"; Cls; RetP( s , t , t1 , n , outfile ); EndP;