35.0 GENMOD Command
GENMOD allows the user to build K series of NNOOBS having a given
covariance or correlation matrix structure. The user can input the
correlation matrix or the covariance matrix or read the matrix saved
by the B34S REGRESSION command PCOV or input the raw series.
Form of GENMOD command:
B34SEXEC GENMOD options parameters $
VAR variable list $
B34SEEND$
If the VAR statement is present, the only required parameter is NNOOB.
GENMOD sentence options.
PCOR - Prints correlation matrix.
PCOV - Prints covariance matrix.
GENMOD sentence parameters.
IBEGIN=n1 - Sets observation number to begin with. Default=1.
This option is only useful if the VAR sentence is used.
IEND =n2 - Sets observation to end with. Default = NOOB.
This option is only useful if the VAR sentence is used.
NNOOB=n3 - Number of observations to generate. This parameter
must be supplied.
K=n4 - Number of series. This parameter must be supplied. Max
= 99.
NREP=n5 - Number of replications. Default = 1. Max=999.
FPREFIX=k1 - Specify up to 4 letters. This is used for the
the SCA FSAVE file name. Default = GENM. This is
used the SCA FSAVE file names will be GENM1 ...
GENMn3.
NPREFIX=k2 - Specify up to 6 letters for variable names. Default
= GENMOD.
COVMAT(.....) Specifies the K(K+1)/2 lower triangle elements of
the covariance matrix.
CORMAT(.....) Specifies the K(K+1)/2 lower triangle elements of
the correlation matrix.
SMEANS(....) Specifies the K series means. Default = 0.
SVAR(...) Specifies the K series variances if CORMAT was used.
Default = 1.0.
SCAUNIT=n6 Specifies FSAVE unit. Default = 44.
PCOV(n7,n8,n9) Allows reading of B34S regression covariance
matrix output on file 37 for problem n7, subproblem
n8 and GLS level n9. If n7, n8 and n9 are supplied as
0, 0 and 0, the first COV. MATRIX file will be read.
For further detail on the B34S REGRESSION PCOV option,
see the help document for the REGRESSION command. If
the PCOV option is used, the SVAR parameter is not
needed.
SEED(r) Sets seed so that data can be replicated. If SEED is
not supplied, B34S uses a random seed. The value r
must be GT 0 and a whole number.
VAR sentence.
The VAR sentence is where the user specifies the variables to use
to generate the covariance matrix.
Examples:
1. Generate a 3 variable system with 1000 observations given the
correlation matrix is:
1.0
.8 1.0
.7 .3 1.0
we assume the variance of all series is 1.0 and the means are
0.0.
b34sexec options open('mytest.fsv') unit=44 disp=unknown$
b34srun$
b34sexec genmod k=3 nnoob=1000 seed(2.0)
cormat=( 1.0, .8, 1.0,.7,.3,1.0) $ b34srun$
2. Generate a 3 variable system with 1000 observations given the
correlation matrix is:
1.0
.8 1.0
.7 .3 1.0
we assume the variance of the series are 2.0, 3.0 and 6.0 and the
means are 100.0 200.0 and 500.0. Series names will be TEST1,
TEST2 and TEST3 and will be saved in SCA FSAVE FILES MT1 .. MT10
on unit 54.
b34sexec options open('mytest.fsv') unit=54 disp=unknown$
b34srun$
b34sexec genmod k=3 nnoob=1000 nrep=10
fprefix=(mt) nprefix=(test) scaunit(54)
svar=(2.0,3.0,6.0) smeans(100.0,200.0,500.0)
cormat=( 1.0, .8, 1.0,.7,.3,1.0) $ b34srun$
3. Run a regression with 4 series. Next generate four data sets
with the same structure as the real data containing 2000
observations. Finally load the artificial data and run
a regression. The original data loading step is not shown.
b34sexec options open('junk.fsv') disp=unknown unit(44)$
b34srun$
b34sexec regression $ model y = x1 x2 x3 x4$ b34srun$
b34sexec genmod nnoob=2000 nrep=4$
var y x1 x2 x3$
b34srun$
/$$ load the data and look at the sample correlation matrix
/$$ next calculate a regression
/$$ first we look at the sca fsave file
b34sexec scainput$ getsca browse $ b34srun$
b34sexec scainput$ getsca corr dataset(genm1)$ b34srun$
b34sexec regression $
model genmod1 =genmod2 genmod3 genmod4 genmod5$
b34srun$
b34sexec scainput$ getsca corr dataset(genm2)$ b34srun$
b34sexec regression $
model genmod1 =genmod2 genmod3 genmod4 genmod5$
b34srun$
b34sexec scainput$ getsca corr dataset(genm3)$ b34srun$
b34sexec regression $
model genmod1 =genmod2 genmod3 genmod4 genmod5$
b34srun$
b34sexec scainput$ getsca corr dataset(genm4)$ b34srun$
model genmod1 =genmod2 genmod3 genmod4 genmod5$
b34srun$
4. A logical next step would be to merge the new data
with the existing data and run a regression of Y on
the generated data to see what "might" have occured.
If we assume that the original data contained 2000
observations, then the following job will indicate
how this might be done. Note that both the covariance
matrix and the coefficients have been saved to further
document the file.
b34sexec options open('junk.fsv') disp=unknown unit(44)$
b34srun$
b34sexec options clean(44)$ b34srun$
b34sexec regression $ model y = x1 x2 x3 x4$ b34srun$
b34sexec genmod nnoob=2000 nrep=4$
var y x1 x2 x3$
b34srun$
/$$ load the data and look at the sample correlation matrix
/$$ next calculate a regression
/$$ first we look at the sca fsave file
b34sexec scainput$ getsca browse $ b34srun$
b34sexec scainput$ getsca corr dataset(genm1) merge$
b34srun$
b34sexec regression noint$
model y =genmod1 genmod2 genmod3 genmod4 genmod5$ b34srun$
b34sexec scainput$ getsca corr dataset(genm2) merge
rename(genmod1 t21 genmod2 t22 genmod3 t23 genmod4 t24
genmod5 t25)$ b34srun$
b34sexec regression noint$
model y =t21 t22 t23 t24 t25$ b34srun$
b34sexec scainput$ getsca corr dataset(genm3) merge
rename(genmod1 t31 genmod2 t32 genmod3 t33 genmod4 t34
genmod5 t35)$ b34srun$
b34sexec regression noint$
model y =t31 t32 t33 t34 t35$ b34srun$
b34sexec scainput$ getsca corr dataset(genm4) merge
rename(genmod1 t41 genmod2 t42 genmod3 t43 genmod4 t44
genmod5 t45)$ b34srun$
b34sexec regression noint$
model y =t41 t42 t43 t44 t45$ b34srun$
Note that we must suppress the constant since it is already
in the data in this case. The RENAME command was used for
files GENM2 ... GENM4.
5. Run a regression with 4 series and save the covariance matrix.
Next generate four data sets with the same structure as the
distribution of the coefficients and 2000 observations. Data
loading step is not shown.
b34sexec options open('cov.out') unit=37 disp=unknown$ b34srun$
b34sexec options open('new.fsv') unit=44 disp=unknown$ b34srun$
b34sexec options clean(37)$ b34srun$
b34sexec options clean(44)$ b34srun$
b34sexec regression pcov$ model y = x1 x2 x3 x4$ b34srun$
b34sexec genmod k=5 nnoob=2000 pcov(0,0,0) nrep=4$ b34srun$
/$$ load the data and look at the sample correlation matrix
/$$ first we look at the sca fsave file
b34sexec scainput$ getsca browse $ b34srun$
b34sexec scainput$ getsca corr dataset(genm1)$ b34srun$
b34sexec scainput$ getsca corr dataset(genm2)$ b34srun$
b34sexec scainput$ getsca corr dataset(genm3)$ b34srun$
b34sexec scainput$ getsca corr dataset(genm4)$ b34srun$
b34sexec options close(37)$ b34srun$
b34sexec options close(44)$ b34srun$