Dear all,
I am writing to ask something about generating a simple variance covariance matrix from a Nx2 matrix. My codes are as follows:
After I get the matrix beta (a matrix with 500 repeatedly estimated coefficient matrix), I don't know how to calculate the variance covariance matrix from the matrix. From what I know in R, it's simply -var(beta)-, but I do not know how to make it work in Stata.
I look forward to hearing from you! Thank you very much in advance!
Best,
Long
I am writing to ask something about generating a simple variance covariance matrix from a Nx2 matrix. My codes are as follows:
Code:
set obs 50 scalar beta0 = 3 scalar beta1 = 0.5 scalar sigma2 = 9 scalar k = 500 local i = 1 while `i' <= k { gen epsilons_`i' = rnormal(0, sqrt(sigma2)) gen yvals_`i' = beta0 + beta1*xvals + epsilons_`i' reg yvals_`i' xvals matrix beta = (nullmat(beta) \ e(b)) drop epsilons_`i' yvals_`i' local i = `i' + 1 }
I look forward to hearing from you! Thank you very much in advance!
Best,
Long
Comment