So I'm doing a simulation exercise where I had to make the error time be correlated with the independent variable X and see what happens to the empirical distribution. So I changed my code from this :
data samples;
do samp = 1 to 1000;
do t = 1 to 100;
u = rannor(1996)*5;
x = 100 + 3*rannor(6991);
y = 10 + 0.5*x + u;
output;
end;
end;
run;
to this:
data samples;
do samp = 1 to 1000;
do t = 1 to 100;
u = rannor(1996)*5;
x = 100 + 3*rannor(6991) + 0.3*u;
y = 10 + 0.5*x + u;
output;
end;
end;
run;
Then I'm supposed to figure out of the model satisfies the assumption that E(U|X) = 0. To do this I have to run a single regression using only the first sample by putting WHERE SAMP=1 after the proc reg statement. Then I have to pull out the residuals and the predicted values of Y. Then I need t do a proc contents on the staset and have X,Y, Yhat, u and uhat in it. Then I need to calculate the correlation between X and uhat. I'm so confused how to go about this. Here is all my code if you guys can please help, thanks.
data samples;
do samp = 1 to 1000;
do t = 1 to 100;
u = rannor(1996)*5;
x = 100 + 3*rannor(6991) + 0.3*u;
y = 10 + 0.5*x + u;
output;
end;
end;
run;
proc corr;
where samp=1;
var x y u;
run;
proc reg data=samples outest=bvalues outseb noprint;
by samp;
model y = x;
run;
data one two;
set bvalues;
if _type_ ='PARMS' then output one;
else if _type_ ='SEB' then output two;
run;
proc sql;
create table mystuff
as select one.intercept as b0hat, one.x as b1hat,
two.intercept as seb0, two.x as seb1
from one, two
where one.samp = two.samp;
quit;
proc means data=mystuff;
var b0hat b1hat;
run;
proc univariate data=mystuff noprint;
var b0hat b1hat;
histogram / normal;
run;
proc reg data=samples WHERE SAMP=1 noprint;
by samp;
model y = x;
run;
I copied and pasted all my code into the question.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.