1. Generate a covariate matrix X of dimension n × k, where n = 500 and k = 4. The first column
in X should be a column of ones and the other three columns can be generated from a relatively
diffuse normal or uniform distribution. Let β = (1, 1.25, 1.5, 1.75)0 and let σ
2 = 1. Simulate y from
the model y = Xβ + ε, where ε ∼ N(0, σ2
In). (This process is exactly the same as the one in lab
assignment 1. Therefore, you can reuse your codes.)
1. Estimate β by ordinary least squares, and let βˆOLS denote this estimator for β. Compute s
discussed in class.
2. Estimate β and σ
2 by maximizing the log-likelihood function derived in class. Let βˆMLE and
MLE denote the two estimators respectively.
3. Compare βˆMLE with βˆOLS. Compare ˆσ
MLE with s
4. Is βˆMLE an unbiased estimator of β? Why? Is ˆσ
MLE an unbiased estimator of σ
Please submit your computer codes for question 1 and 2. Please submit answers for question 3 and
4 either by using comments in MATLAB or submitting a separate file with answers.
For this exercise, the TAs will provide support on coding in Matlab (free on Apporto
– see the link to VCL on Canvas), but you can use any software you are comfortable
with. The idea behind this exercise is not to use packages or click on buttons, but to
do the coding from scratch, following the theoretical derivations presented in class.