Gauss exercises II:
Gauss exercises II: 1. Generate a set of three orthogonal regressors, X (including the constant) and define a true 3x1 parameter vector, beta, of your choice. a) Generate normal errors, u, and compute the regressand, y=Xβ+u. Then regress y only on the first two columns of X and retain your estimate b. Repeat these steps (generation of errors and y, regression) 500 times using a loop command, e.g. for. Looking at the average of your 500 estimates, does the regression seem to produce a bias? b) Redo exercise a) but now start from a set of three regressors that are not orthogonal to each other any more. Specifically, make sure that x2 and x3 are correlated (though not perfectly). Do your results indicate that there is a bias problem now? c) In the previous setup, estimate the parameter on the third regressor, β3, using residual regression, i.e. regress the residuals from regressing y upon x1 and x2 (ºy*) on the residuals from regressing x3 upon x1 and x2 (ºx*3). Do you obtain the same estimate as in the case, where you simply regress y on all three columns of X? What happens when you regress y on x*3? Finally, what happens when you regress y* on x3? d) Now add two further columns to the regressor matrix used in b), but keep generating y only as a linear function of the first three columns of X. What happens to your OLS estimates when, instead of regressing y upon the first three columns of X, you now regress on all 5 columns of X? 2. When a certain sequence of commands or data manipulations is required several times in a program it can be useful to outsource this sequence of commands to a so-called procedure. Whenever the respective sequence of commands is needed, instead of entering every single command in your program you then simply call the procedure, which has to be defined only once, e.g. at the end of your code. The structure of a procedure in Gauss is as follows: proc (# outputs) = myprocedure(x,y,z,
.); /*x,y,z,
. are data inputs */ local a,b,c,
; /* defines local variables that are used in the procedure */ a=x*y;b=z-a;
.. /* commands that manipulate the data in the desired way */ output1=a;output2=b^2;
.; /* define which output you want the proc to return */ retp(output1,output2,output3
.); /* return output */ endp; To call the procedure in your program, simply type {output1,output2,output3
}=myprocedure(x,y,z,
.); Try to write a procedure for OLS estimation that returns b, the corresponding standard errors, R2 and adjusted R2 as output, using X and y as inputs.
Free TextEditor
Create Date : 06 กุมภาพันธ์ 2554 |
Last Update : 6 กุมภาพันธ์ 2554 10:35:22 น. |
|
0 comments
|
Counter : 524 Pageviews. |
|
|