05-22-2013 08:39 AM
Lets say we have a regression model y= b0+b1*X
I'm trying to write a code which in each cycle of simulated data (lets say for example _10,000 cycles)
doing an OLS regression and just record the b1 coefficient.
the output should be about 10,000 b1 _the number the of cycles.
The creation of b1 data will give me the opportunity to calculate statistic on that parameter.
I would really appreciate your help.
Thank you all,
05-22-2013 08:54 AM
05-22-2013 09:11 AM
This and many other examples and variations are discussed in my book Simulating Data with SAS
do SampleID = 1 to 10000; /* number of simulated samples */
do i = 1 to 50; /* number of obs per sample */
x = rand("Uniform");
eps = rand("Normal", 0, 0.5);
y = 1 - 2*x + eps; /* parameters are 1 and -2 */
proc reg data=RegSim NOPRINT outest=OutEst;
model y = x;
proc means data=OutEst;
In this example, I generate new x values for each sample. You can also generate a single set of x values and reuse it for all samples, so that only the error term is random between samples (discussion on p. 202).