Newbie seeking help
Hi, I'm totally new at this programme having started using it yesterday. I am faced with a simple problem of having to simulate a linear model:
Yi=Beta1+Beta2Xi+Ui
where Xi and Ui are independent and i.i.d. And Beta1 must be set equal to zero and Beta1 equal to 1.
I am supposed to draw the Xi's and the Ui's from normal distributions with Xi~iidN(0,1) and U~iidN(0,2) and then investigate by simulation whether the OLS estimator, Beta2hat, of Beta2 is consistent and whether n^(1/2)(Beta2hat-Beta2) converges in distribution.
My plan would be to make a do loop for 10000 simulation with different number of observations. First n=100, then n=1000, n=10000 and so on. And then I would like to draw histograms for Beta2hat and n^(1/2)(Beta2hat-Beta2) to get an indication of the consistency and of the asymptotic distribution of Beta2hat.
As I said I'm totally new at this so bear with me. My code so far is:
As you can see I am only still at doing the loop. It reports an error message SX22.
What am I doing wrong here??!!
I am a bit confused about the difference between the compute and set instructions. I'm not yet sure when to use which so that may be the problem. But the error message indicates that the error is to be found on line 9 of the loop, that is, at the linreg instruction.
I have also attached the code so that you can execute it, change it and upload it back containing your answer in case that is easier.
I'm really stuck
so hoping to get some help.
Yi=Beta1+Beta2Xi+Ui
where Xi and Ui are independent and i.i.d. And Beta1 must be set equal to zero and Beta1 equal to 1.
I am supposed to draw the Xi's and the Ui's from normal distributions with Xi~iidN(0,1) and U~iidN(0,2) and then investigate by simulation whether the OLS estimator, Beta2hat, of Beta2 is consistent and whether n^(1/2)(Beta2hat-Beta2) converges in distribution.
My plan would be to make a do loop for 10000 simulation with different number of observations. First n=100, then n=1000, n=10000 and so on. And then I would like to draw histograms for Beta2hat and n^(1/2)(Beta2hat-Beta2) to get an indication of the consistency and of the asymptotic distribution of Beta2hat.
As I said I'm totally new at this so bear with me. My code so far is:
- Code: Select all
allocate 100
compute beta1=0, beta2=1, sigmax=1,sigmau=2
compute ndraws = 10000
do draw=1,ndraws
set x = %ran(sigmax)
set u = %ran(sigmau)
set y = beta1+beta2*x+u
linreg(noprint) y
# constant x
end do draw
As you can see I am only still at doing the loop. It reports an error message SX22.
What am I doing wrong here??!!
I am a bit confused about the difference between the compute and set instructions. I'm not yet sure when to use which so that may be the problem. But the error message indicates that the error is to be found on line 9 of the loop, that is, at the linreg instruction.
I have also attached the code so that you can execute it, change it and upload it back containing your answer in case that is easier.
I'm really stuck