Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Regression and prediction in Mata

    Hi, I am relatively new to Mata, and thus I would like to receive any advice on my potential codes.

    What I am trying is to make groups for each unique value of y, run a OLS model with each of the unique value as a dependent variable, and get predicted values for each observation. However, I observed about 70,000 unique values, and thus the following code does not work because of space limitations in Stata. Thus, I would like to read the data in Mata and run the analysis with Mata. Since it must take long time, I would like to receive any comments that can contribute to improving efficiency.

    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'
    reg y_`a' $xs
    predict pre_`a'
    }


    Thank you!
Working...
X