I need help with looping in mata. I have to write a code for Beta coefficients for OLS in mata through loop. I am not sure how to call for the variables and create the code. Here is what I have so far.
foreach j of local X { if { //for X'X matrix XX = [mata:XX = cross(X,1 , X,1) XX] } else {mata:Xy = cross(X,1 , y,0) Xy }
foreach j of local X { if { //for X'X matrix XX = [mata:XX = cross(X,1 , X,1) XX] } else {mata:Xy = cross(X,1 , y,0) Xy }