I am trying to run a linear probability model with the following code. The model aims to run a model for every unique value of the dependent variable ($y) and predict probabilities of lying within a vigicile. Because I observed about 78,000 unique values for $y, I need to run about 78,000 regression models. However, as Stata limits to store variables up to about 32,000 and matrix up to 11,000, I am trying to read the data in Mata.
As END statement for Mata is in conflict with loop, I would like to use one-line calls to Mata, which enables to save lots of predicted values (i.e., adding new predicted values to previously predicted values).
I have tried to use st_store and putmata, but they did not work. Could you please provide any comments?
Thank you for your help in advance!
Code:
egen group = group($y) tempname max su group scalar `max' = r(max) forvalues a = 1(1) `=`max'' { gen y_`a' = 0 replace y_`a' = 1 if group <= `a' qui reg y_`a' $xs predict pre_y_`a' }
As END statement for Mata is in conflict with loop, I would like to use one-line calls to Mata, which enables to save lots of predicted values (i.e., adding new predicted values to previously predicted values).
Code:
egen group = group($y)
tempname max
su group
scalar `max' = r(max)
forvalues a = 1(1) `=`max'' {
gen y_`a' = 0
replace y_`a' = 1 if group <= `a'
qui reg y_`a' $xs
predict pre_y_`a'
mata : XXXXX
}
Thank you for your help in advance!
Comment