21.0 BTEST Command The BTEST command allows estimation, testing and forecasting with a VARMA, VAR or VMA model. For basic references, see BTIDEN command. The BTEST command can be called with the FORECAST command (See section 32) to investigate alternative VAR forecasting models. In this mode of operation the user inputs all control cards except the AR( ) values which are generated. (Note: Do not confuse the FORECAST sentence of the BTEST command with the FORECAST command.) The estimated model is of the form. A(B) SAR(B) Z(t) = M(B) SMA(B) e(t) where A(B), SAR(B), M(B) and SMA(B) are the AR, seasonal AR, MA and seasonal MA matrixes respectively and B is the lag operator. In general: A(B) = (I- a(1)B - ... - a(k)B(**k)) where k is the max AR order. SAR(B) = (I-sar(1)B(**S) - .. -sar(j)B**(S*j)) where S is the seasonal period and j is the seasonal matrix order. Form of Command. B34SEXEC BTEST options parameters$ TITLE=(' ') $ SERIESN VAR=Xvar1 NAME=(' ') DIF=( )( ) TM=r1 PLAM=r2$ BISPEC options parameters $ TRISPEC options parameters $ POLYSPEC options parameters $ REVERSE options parameters $ CONSTANT=(key1,key2) $ AR(order,row,col)= value option $ SAR(order,row,col)= value option $ MA(order,row,col)= value option $ SMA(order,row,col)= value option $ COVARIANCE(row,col) = value $ OUTPUT options parameters $ FORECAST options parameters $ B34SEEND$ The only required sentences are SERIESN and at least one or more of sentences AR, SAR, MA, SMA. The maximum number of series for the BTEST command is 30. A SERIESN sentence must be supplied for each series loaded. The BISPEC, POLYSPEC and TRISPEC sentences allow nonlinear tests to be performed following Hinich. BTEST sentence options. NOFIT - Set if the user just wants to forecast with a known model. If the NOFIT option is selected, the COVARIANCE sentences must be used to input the covariance matrix. COND - Use conditional estimation method. This is the default. EXACT - Use exact estimation method. The exact estimation method can only be used if the maximum order of the seasonal matrix is LE 1. BTEST sentence parameters. IBEGIN=n1 Sets beginning observation. Defaults to 1. IEND=n2 Sets ending observation. Defaults to NOOB. EPSILON=r1 Sets relative convergence criterion. Default=.001. MAXIT=n3 Sets maximum number of iterations. Default = 10. S=n4 Sets seasonal period or factor. Will default to 12 if SAR or SMA sentences are found. For further detail, see SAR and SMA sentences. ISEAR=n5 If n5 = 2 will save coefficients for a subsequent job with n5 =-2 to set to 0.00 all parameters where abs(T) < SIG1 which is specified below. SIG1=r2 Sets the significance to cut off coefficients. Must be supplied. Note: ISEAR is usually set by the FORECAST paragraph (see section 32.). If ISEAR is set manually with a direct call to BTEST, then it is imperative that the next BTEST job be the same in every respect to first job except for the fact that ISEAR =-2. The constant will not be removed if it has been requested. Multiple following jobs cak have isear=-2. ISEAR can only be set 0, 2, or -2. TITLE sentence. TITLE=('Any title here up to 80 characters')$ The TITLE sentence is optional. SERIESN sentence. The SERIESN sentence controls variable input, and optionally additional variable naming and transformation. Parameters for SERIESN sentence. VAR=Xvar Specify input variable. This parameter must be supplied. NAME=(' A max of 65 characters additional name description here') TM=r1 Specifies a constant to add to the data. PLAM=r21 Specifies Box - Cox Transformation. If PLAM is not set, the data is unchanged. If PLAM is set to 0.0, XNEW=DLOG(XOLD + TM). If PLAM GE .0001 XNEW=(XOLD + TM) ** PLAM. DIF=(n1,n2)(n3,n4) Specifies differencing. There is a max of two differencing factors (). The first integer in ( ) is the number of differences, the second integer is the order of the difference. For example DIF=(1,1)(1,12) is first differencing and seasonal differencing. BISPEC sentence. The BISPEC sentence performs various nonlinearity, gaussianity and martingale tests suggested by Hinich. Any transformations called for on the BISPEC sentence are only for these tests and have no effect on any other options in other sentences in the command. The BISPEC sentence tests at which frequencies there is evidence of nonlinearity and whether there is memory (there is a Martingale). The form of the BISPEC sentence in the BTEST and BTIDEN commands is the same. To save space, detail for this sentence is listed only under the BTIDEN command help file. If the BISPEC sentence is given with no options or parameters, gaussianity and nonlinearity tests will be performed. TRISPEC sentence The TRISPEC command performs 4th order nonlinearity tests suggested by Hinich. Further detail on this sentence is listed under the BTIDEN command. POLYSPEC sentence The POLYSPEC command performs various nonlinearity tests suggested by Hinich within the sample. Further detail on this sentence is listed under the BTIDEN command. REVERSE sentence The REVERSE sentence performs various Time reversability tests suggested by Hinich and Rothman. Further detail in this sentence is listed under the BTIDEN command. CONSTANT sentence. The optional CONSTANT sentence allows the user to override the constant defaults. If there is differencing in the model, the program defaults to no estimated condtant. If there is no differencing in the model, the program will default to estimating a constant. General form of the command. CONSTANT=(key1,key2)$ Key1 and key2 can be set as YES or NO. If the CONSTANT sentence is supplied there must be at many arguments as there are series inputted. AR, SAR, MA and SMA sentences. The AR, SAR, MA and SMA sentences allow the user to input the VARMA model. At least one of one of the above sentences is required. The general form of the sentence (illustrated for AR) is: AR(n1,n2,n3)=r options$ n1 = the order of the matrix. n2 and n3 are the row and column dimensions. The only options allowed are FIXED and FREE. The FREE option is assumed. Usage note: If the SAR or SMA sentences are used, S, which is set on the BTEST sentence, defaults to 12. When using the SAR and SMA sentences n1 refers to the seasonal factor order. For example if S=4, SAR(3,1,1)=.2 $ sets the 12th order (3*4) seasonal AR (1,1) matrix term to .2. AR(3,1,2)=.5 $ would set the 3rd order AR (1,2) matrix term to .5. Since the AR and SAR matrix factors are multiplicative, setting a first order AR matrix element and a 12th order matrix element is not the same thing as a first order AR matrix and a 12th order seasonal matrix element. COVARIANCE sentence. The COVARIANCE sentences allow the user to input the covariance matrix. The COVARIANCE sentence is required if the NOFIT option has been specified in the BTEST sentence and no estimation is done. It can be useful if the EXACT option has been specified and the user wishes to start with the CONDITIONAL covariance matrix values. Form of sentence. COVARIANCE(n1,n2) = r $ n1 = row dimension, n2 = col dimension and r= covariance value. n1 must be GE n2 (only lower triangular elements must be specified. If there are k series, there must be k*(k+1)/2 COVARIANCE sentences. OUTPUT sentence. The OUTPUT sentence is used to control output of BTEST paragraph. Options on OUTPUT sentence. IPRINT - Will print cross correlation matrices. RESIDUALS - Will list residuals. ISACF - Plot residual ACF. Note that LAGRHO must be set > 0. ISCCF - Plot residual CCF. Note that LAGRHO must be set > 0. ICORMT - Will print full matrix of correlation of parameters. NOPCRM - Will suppress correlation matrix of parameters. IPLOT - Plot standardized residuals. This option gives side by side plots and is valid for LE 5 series. MQSTAT - Gives Multivariate Q Statistic. Parameters on OUTPUT sentence. IPARM=n1 - Will give current parameters values every n1 th iteration. Default is to print only summary. LAGRHO=n2 - # of residual cross correlation matrixes to output. Max allowed = 120. Unless IPRINT set, will only be in +, - . form. Unless LAGRHO is set, no cross correlations of any form will be output. IPER=n2 - Sets markings on x axis for plots. Default is markings every 10 periods. If n2=12, markings will be 1,2,...,9,0,A,B. The range for n2 is 0 - 36 where 0 means markings every 10 periods. ICOPY=n3 - Sets number of copies of summary information. Default=1. NFMAT=n4 - Sets number of psi matrices to print if forecasting is done. IRES=n5 Controls residual output on unit 44 in SCA FSAVE format. If RESIDUALS option is set and n5 > 0, residuals are only outputed to a file with name RESIDUAL. If RESIDUALS is set and n5 < 0, then residuals are listed and punched. Series listed are OBSNUM, RESID1, RESID2,.. SERIES1, SERIES2,... YHAT1, YHAT2 ... Note: Residual = actual - forecast. ISCAU=n6 - Sets coefficient save unit. Unit n6 must be LRECL=80,RECFM=FB. If n6 LT 0, unit n6 is rewound prior to saving. Saving is done in SCA SAVEFILE format. These files can be read by the SCAINPUT command. SCAP=key - Sets SCA SAVEFULE data set prefix. The default = MOD. Assume that SCAP=ES1 where there is a model where there are 2 AR matrices, 3 MA matrices and 1 seasonal MA matrix. In each dataset produced the names of the variables will reflect their order. For example if the AR matrices were or order 1 and 6, their names would be AR1 and AR6. Three SCA SAVEFILES will be produced. Their names will be ES1AR2 (containing AR1 and AR6), ES1MA3 (containing the appropriately labeled MA matrices) and ES1MA1 (containing the appropriately labeled seasonal MA matrix. These files can be read by the SCAINPUT command. NSTDER=r1 - Sets number of standard errors for ACF and CCF +, -, . plots. Default = 2. NSTDER must be specified as LE 5 digits and GE 0.0 . FORECAST sentence. The FORECAST sentence is needed if forecasts are desired. The parameters NT and NF are required. Options on FORECAST sentence. SE - Will give SE as well as forecasts if OUTPUT=BOTH or OUTPUT=NEW. ACTUAL - Will give actual values as well as forecasts if OUTPUT=BOTH or OUTPUT=NEW. UNIT - Will write forecast output to unit 40. Unit 40 must be LRECL=80,RECFM=FB and must be allocated prior to the B34S run. OUTPUT must be set =NEW or =BOTH SCAUNIT- Will write forecast output to unit 44 in SCA FSAVE format. Forecasts and optionally SE's are written. Unit 44 must be LRECL=80, RECFM=FB and must be allocated prior to the B34S run. The SCA dataset name is FORECi where i goes from 1 to NTO. The unit status is rewound. Series names are FOR1 ... FORk and SE1 ... SEk. If there is actual data available, then the series ERR1 ... ERRk are given where ERRi = ACTIALi - FORi. The mean sum of squared errors is given in the file as a comment. Parameters on FORECAST sentence. NT=(n1,n2) Sets origin n1 and n2. Up to 99 origins can be set. NF=(n3,n4) Sets numbers of forecasts at origins listed with NT parameter. OUTPUT=key If key = ORIGINAL, old forecast output used. This is the default. key = NEW, new forecast output used. key = BOTH, both new and original form used. Sample job # 1 Estimate a VAR model with gas data for up to 6 lags. B34SEXEC BTEST$ TITLE=('Estimation run with Gas Data') $ SERIESN VAR=GASIN NAME=('B-J GAS INPUT DATA') $ SERIESN VAR=GASOUT NAME=('B-J GAS OUTPUT DATA')$ AR(1,1,1)=1.9 $ AR(1,2,2)=1.5 $ AR(2,1,1)=-1.2 $ AR(2,2,2)=-.59 $ AR(3,1,1)=.17 $ AR(3,2,1)=-.44 $ AR(3,2,2)=-.17 $ AR(4,2,1)=.15 $ AR(4,2,2)=.13 $ AR(5,2,1)=-.12 $ AR(6,2,1)=.11 $ OUTPUT IPRINT LAGRHO=24 NSTDER = 2.5 NOPCRM$ FORECAST NT=(296,250) NF=(24,20) SE ACTUAL OUTPUT=BOTH $ BISPEC $ B34SEEND$ Sample job # 2 Estimate Gas model (see Stokes (1991) Chapter 8) and produce an SCA FSAVE output file GASFOR.DAT. Note that the job has been set up so that GASFOR.DAT is created (DISP=NEW). The setup to allocate the file ONCE IT HAS BEEN CREATED has been commented out. The complete SCA FSAVE file is shown. It is assumed that the gas data has been loaded as is shown in Stokes(1991). b34sexec options open('gasfor.dat') unit(44) disp=new$ b34seend$ /$b34sexec options open('gasfor.dat') unit(44) disp=old$ b34seend$ b34sexec btest$ title=('estimation run with gas data') $ seriesn var=gasin name=('b-j gas input data') $ seriesn var=gasout name=('b-j gas output data') $ ar(1,1,1)=1.9 $ ar(1,2,2)=1.5 $ ar(2,1,1)=-1.2 $ ar(2,2,2)=-.59 $ ar(3,1,1)=.17 $ ar(3,2,1)=-.44 $ ar(3,2,2)=-.17 $ ar(4,2,1)=.15 $ ar(4,2,2)=.13 $ ar(5,2,1)=-.12 $ ar(6,2,1)=.11 $ output iprint lagrho=24 $ constant=(yes,yes)$ covariance(1,1)=.3$ covariance(2,1)= -.1 $ covariance(2,2)= .06 $ forecast nt=(296,250) nf=(24,20) se actual output=new scaunit$ * bispec iauto iturno imart nbd=1$ b34srun$ The SCA FSAVE file GASFOR.DAT, which contains datasets FOREC1 and FOREC2, is shown below. ==FOREC1 -- FILE CREATED 03/02/92 AT TIME 13:18:34 -- FORECASTS AND OPTIONALLY SE S FROM B34S BTEST OPTION -- MAX ORDER AR, SAR, MA, SMA 6 0 0 0 -- # ELEMENTS AR, SAR, MA, SMA 11 0 0 0 -- # MATRIX AR, SAR, MA, SMA 6 1 1 1 -- # VARIABLE PARAMETERS IN MODEL 13 -- 24 FORECASTS STARTING AT ORIGIN 296 --$FORM=(4E18.10) --$MISS= 0.1000000000E+32 --$NVAR= 5 TROW= 24 TCOL= 5 --$NAME=OBSNUM NROW= 24 NCOL= 1 TYPE= 3 --$NAME=FOR1 NROW= 24 NCOL= 1 TYPE= 3 --$NAME=FOR2 NROW= 24 NCOL= 1 TYPE= 3 --$NAME=SE1 NROW= 24 NCOL= 1 TYPE= 3 --$NAME=SE2 NROW= 24 NCOL= 1 TYPE= 3 297.0000000 -0.2651124568 56.65440577 0.1895486079 0.2369459389 298.0000000 -0.2298621859 56.39592108 0.4207994020 0.4314104960 299.0000000 -0.1836254058 56.19190271 0.6396774662 0.5978136972 300.0000000 -0.1419514566 56.02140258 0.8119985222 0.7226953599 301.0000000 -0.1111549129 55.81667896 0.9305305696 0.8672522696 302.0000000 -0.9175253708E-01 55.56371439 1.003444128 1.132717652 303.0000000 -0.8144400363E-01 55.27668221 1.044173665 1.528226141 304.0000000 -0.7715927174E-01 54.98784371 1.065164164 1.967527714 305.0000000 -0.7618380390E-01 54.72607245 1.075365873 2.363441950 306.0000000 -0.7659095206E-01 54.50861682 1.080191219 2.670238850 307.0000000 -0.7725382896E-01 54.33937760 1.082504342 2.881342599 308.0000000 -0.7766232060E-01 54.21283383 1.083676227 3.013562364 309.0000000 -0.7769498280E-01 54.11905311 1.084321732 3.091040662 310.0000000 -0.7742482864E-01 54.04785401 1.084709118 3.135065206 311.0000000 -0.7698678072E-01 53.99112576 1.084956731 3.160396379 312.0000000 -0.7650458876E-01 53.94351991 1.085119810 3.175776210 313.0000000 -0.7606193711E-01 53.90209218 1.085227257 3.185863274 314.0000000 -0.7570021975E-01 53.86552219 1.085296702 3.192984116 315.0000000 -0.7542866530E-01 53.83333984 1.085340315 3.198264654 316.0000000 -0.7523739762E-01 53.80536776 1.085366882 3.202257727 317.0000000 -0.7510850478E-01 53.78141647 1.085382639 3.205266043 318.0000000 -0.7502340381E-01 53.76117792 1.085391803 3.207494974 319.0000000 -0.7496665112E-01 53.74423567 1.085397073 3.209112658 320.0000000 -0.7492714888E-01 53.73012155 1.085400099 3.210265071 END OF DATA. ==FOREC2 -- FILE CREATED 03/02/92 AT TIME 13:18:34 -- FORECASTS AND OPTIONALLY SE S FROM B34S BTEST OPTION -- MAX ORDER AR, SAR, MA, SMA 6 0 0 0 -- # ELEMENTS AR, SAR, MA, SMA 11 0 0 0 -- # MATRIX AR, SAR, MA, SMA 6 1 1 1 -- # VARIABLE PARAMETERS IN MODEL 13 -- MEAN SQUARED ERROR SERIES 1 = 0.43862035 -- MEAN SQUARED ERROR SERIES 2 = 2.4262578 -- CORR. FORE./ACTUAL SERIES 1 = 0.26092573 -- CORR. FORE./ACTUAL SERIES 2 = 0.81076906 -- NOTE: ERR = ACTUAL SERIES - FORECASTED SERIES -- 20 FORECASTS STARTING AT ORIGIN 250 --$FORM=(4E18.10) --$MISS= 0.1000000000E+32 --$NVAR= 7 TROW= 20 TCOL= 7 --$NAME=OBSNUM NROW= 20 NCOL= 1 TYPE= 3 --$NAME=FOR1 NROW= 20 NCOL= 1 TYPE= 3 --$NAME=FOR2 NROW= 20 NCOL= 1 TYPE= 3 --$NAME=SE1 NROW= 20 NCOL= 1 TYPE= 3 --$NAME=SE2 NROW= 20 NCOL= 1 TYPE= 3 --$NAME=ERR1 NROW= 20 NCOL= 1 TYPE= 3 --$NAME=ERR2 NROW= 20 NCOL= 1 TYPE= 3 251.0000000 0.3540976275E-01 56.22992798 0.1895486079 0.2369459389 0.1495902372 0.7007202337E-01 252.0000000 0.3077777901 56.15087443 0.4207994020 0.4314104960 0.3542222099 0.2491255669 253.0000000 0.4187987466 55.91016533 0.6396774662 0.5978136972 0.2902012534 0.4898346701 254.0000000 0.4115083669 55.33867971 0.8119985222 0.7226953599 0.1934916331 0.6613202908 255.0000000 0.3382523136 54.53258462 0.9305305696 0.8672522696 0.1627476864 0.6674153844 256.0000000 0.2419490710 53.71336042 1.003444128 1.132717652 0.3610509290 0.2866395753 257.0000000 0.1501104132 53.07920953 1.044173665 1.528226141 0.7928895868 -0.7920953248E-01 258.0000000 0.7603642579E-01 52.72328949 1.065164164 1.967527714 1.146963574 -0.7232894897 259.0000000 0.2293045760E-01 52.63282113 1.075365873 2.363441950 1.226069542 -1.032821133 260.0000000 -0.1169088266E-01 52.73003717 1.080191219 2.670238850 0.8356908827 -1.130037167 261.0000000 -0.3254571601E-01 52.92026846 1.082504342 2.881342599 0.1345457160 -1.820268457 262.0000000 -0.4442276354E-01 53.12554995 1.083676227 3.013562364 0.6942276354E-01 -2.725549954 263.0000000 -0.5113832880E-01 53.29862407 1.084321732 3.091040662 0.4331383288 -3.298624074 264.0000000 -0.5526411046E-01 53.42161716 1.084709118 3.135065206 0.9772641105 -3.421617156 265.0000000 -0.5827807456E-01 53.49694845 1.084956731 3.160396379 1.090278075 -1.496948448 266.0000000 -0.6087657269E-01 53.53690103 1.085119810 3.175776210 0.9268765727 0.4630989696 267.0000000 -0.6328867254E-01 53.55557356 1.085227257 3.185863274 0.5902886725 1.544426437 268.0000000 -0.6551906090E-01 53.56435452 1.085296702 3.192984116 0.1585190609 0.9356454778 269.0000000 -0.6750263550E-01 53.57043188 1.085340315 3.198264654 -0.3904973645 -0.7704318791 270.0000000 -0.6918388251E-01 53.57720422 1.085366882 3.202257727 -0.6788161175 -2.177204223 END OF DATA. // Sample Job 3. The 20 forecasts for the in sample period starting at 250 are saved into B34S and merged with the existing data if the below listed commands are added to sample job 2. Note that the variables FOR1 and FOR2 in SCA FSAVE file GASFOR are recoded FGASIN and FGASOUT respectively. Remember that the B34S paragraph PRIOR to the SCAINPUT paragraph MUST end with B34SRUN$ in place of B34SEEND$ . B34SEXEC SCAINPUT$ GETSCA DATASET=FOREC2 SCAUNIT=44 HEADING=('Gas and Forecasts') MERGE RECODE(FOR1,FGASIN,FOR2,FGASOUT) $ B34SEEND$ Note that if the MERGE keywork was not used, only the SCA FSAVE file would be loaded. This is usually the case of what is done if in-sample forecasting is done, since the actual data can be recovered by use of the ERR1 and ERR2 variables. If the user wants to estimate a model using less data than is available, use IBEGIN and IEND on the B34SEXEC BTEST sentence and merge the forecasted data. If the keyword CORR is supplied on the GETSCA sentence of the job using the form of example 3, then correlations of the actual and forecasted series are calculated.