Announcement

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

  • Loop in Mata

    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.

    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
    }
    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!

  • #2
    It's not clear what you want to do. Do you want to store the predictions from 78 000 regressions in memory? If you have, say, an average of 10 observations for each unique value of the dependent variable (for the regression to work), then you would have 780 000 observations in your dataset, and thus up to the same number of unique values of the linear-probability predictions for each regression. If you want to store the unique value of the dependent variable along with its respective set of predictions, and you're storing 78 000 regressions' worth of them in double precision (Mata), then you'll need a lot of volatile memory.

    Do you plan to do some data reduction of the predictions, and storing only the unique value of the dependent variable and its probability of lying within some vigicile (I had to look that up) or other?

    Comment


    • #3
      I'm still not clear about exactly what your objective is, but if it's to "predict probabilities of" "every unique value of the dependent variable" "lying within a vigicile", then could you get there more simply with a combination of egen . . ., cut() group(20) and an ordered-categorical regression command, such as ologit or oprobit? Take a look at the example below. It uses deciles instead of vigiciles for simplicity of illustration, but it does what it seems to me that you want to.

      .ÿversionÿ14.2

      .ÿ
      .ÿclearÿ*

      .ÿsetÿmoreÿoff

      .ÿquietlyÿsysuseÿauto

      .ÿ
      .ÿegenÿintÿdecileÿ=ÿcut(price),ÿgroup(10)

      .ÿ
      .ÿoprobitÿdecileÿc.(mpgÿheadroom-gear_ratio)ÿi.foreign,ÿnolog

      OrderedÿprobitÿregressionÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿÿÿÿ74
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿLRÿchi2(9)ÿÿÿÿÿÿÿÿ=ÿÿÿÿÿÿ73.64
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.0000
      Logÿlikelihoodÿ=ÿ-133.41191ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿPseudoÿR2ÿÿÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.2163

      ------------------------------------------------------------------------------
      ÿÿÿÿÿÿdecileÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
      -------------+----------------------------------------------------------------
      ÿÿÿÿÿÿÿÿÿmpgÿ|ÿÿ-.0373863ÿÿÿ.0378184ÿÿÿÿ-0.99ÿÿÿ0.323ÿÿÿÿÿ-.111509ÿÿÿÿ.0367363
      ÿÿÿÿheadroomÿ|ÿÿ-.7623368ÿÿÿ.2085098ÿÿÿÿ-3.66ÿÿÿ0.000ÿÿÿÿ-1.171009ÿÿÿÿ-.353665
      ÿÿÿÿÿÿÿtrunkÿ|ÿÿÿ.1238316ÿÿÿ.0493484ÿÿÿÿÿ2.51ÿÿÿ0.012ÿÿÿÿÿ.0271105ÿÿÿÿ.2205527
      ÿÿÿÿÿÿweightÿ|ÿÿÿ.0016016ÿÿÿ.0006557ÿÿÿÿÿ2.44ÿÿÿ0.015ÿÿÿÿÿ.0003165ÿÿÿÿ.0028867
      ÿÿÿÿÿÿlengthÿ|ÿÿÿ.0002494ÿÿÿ.0198928ÿÿÿÿÿ0.01ÿÿÿ0.990ÿÿÿÿ-.0387397ÿÿÿÿ.0392386
      ÿÿÿÿÿÿÿÿturnÿ|ÿÿÿ-.111604ÿÿÿÿ.061523ÿÿÿÿ-1.81ÿÿÿ0.070ÿÿÿÿ-.2321869ÿÿÿÿÿ.008979
      displacementÿ|ÿÿÿ.0075455ÿÿÿ.0036925ÿÿÿÿÿ2.04ÿÿÿ0.041ÿÿÿÿÿ.0003084ÿÿÿÿ.0147826
      ÿÿgear_ratioÿ|ÿÿÿ.6216859ÿÿÿÿ.556638ÿÿÿÿÿ1.12ÿÿÿ0.264ÿÿÿÿ-.4693046ÿÿÿÿ1.712676
      ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
      ÿÿÿÿÿforeignÿ|
      ÿÿÿÿForeignÿÿ|ÿÿÿ1.977815ÿÿÿ.4513991ÿÿÿÿÿ4.38ÿÿÿ0.000ÿÿÿÿÿ1.093089ÿÿÿÿ2.862541
      -------------+----------------------------------------------------------------
      ÿÿÿÿÿÿÿ/cut1ÿ|ÿÿÿ.8847723ÿÿÿ3.355923ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-5.692715ÿÿÿÿÿ7.46226
      ÿÿÿÿÿÿÿ/cut2ÿ|ÿÿÿ1.468441ÿÿÿ3.351676ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-5.100723ÿÿÿÿ8.037604
      ÿÿÿÿÿÿÿ/cut3ÿ|ÿÿÿ1.968974ÿÿÿ3.347503ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-4.59201ÿÿÿÿ8.529959
      ÿÿÿÿÿÿÿ/cut4ÿ|ÿÿÿ2.435772ÿÿÿ3.351297ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-4.13265ÿÿÿÿ9.004193
      ÿÿÿÿÿÿÿ/cut5ÿ|ÿÿÿ2.977815ÿÿÿ3.369009ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-3.625322ÿÿÿÿ9.580951
      ÿÿÿÿÿÿÿ/cut6ÿ|ÿÿÿ3.411651ÿÿÿ3.378273ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-3.209643ÿÿÿÿ10.03294
      ÿÿÿÿÿÿÿ/cut7ÿ|ÿÿÿ3.839905ÿÿÿÿ3.38337ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-2.791379ÿÿÿÿ10.47119
      ÿÿÿÿÿÿÿ/cut8ÿ|ÿÿÿ4.458509ÿÿÿ3.388877ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-2.183568ÿÿÿÿ11.10059
      ÿÿÿÿÿÿÿ/cut9ÿ|ÿÿÿ5.234582ÿÿÿ3.379845ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-1.389792ÿÿÿÿ11.85896
      ------------------------------------------------------------------------------

      .ÿpredictÿdoubleÿpr*,ÿpr

      .ÿ
      .ÿformatÿpr1-pr10ÿ%04.2f

      .ÿ
      .ÿsortÿprice

      .ÿlistÿpr*,ÿnoobsÿsepby(decile)

      ÿÿ+------------------------------------------------------------------------------+
      ÿÿ|ÿÿpriceÿÿÿÿpr1ÿÿÿÿpr2ÿÿÿÿpr3ÿÿÿÿpr4ÿÿÿÿpr5ÿÿÿÿpr6ÿÿÿÿpr7ÿÿÿÿpr8ÿÿÿÿpr9ÿÿÿpr10ÿ|
      ÿÿ|------------------------------------------------------------------------------|
      ÿÿ|ÿÿ3,291ÿÿÿ0.29ÿÿÿ0.22ÿÿÿ0.19ÿÿÿ0.14ÿÿÿ0.10ÿÿÿ0.04ÿÿÿ0.02ÿÿÿ0.01ÿÿÿ0.00ÿÿÿ0.00ÿ|
      ÿÿ|ÿÿ3,299ÿÿÿ0.33ÿÿÿ0.23ÿÿÿ0.18ÿÿÿ0.13ÿÿÿ0.08ÿÿÿ0.03ÿÿÿ0.01ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿ|
      ÿÿ|ÿÿ3,667ÿÿÿ0.35ÿÿÿ0.23ÿÿÿ0.18ÿÿÿ0.12ÿÿÿ0.08ÿÿÿ0.03ÿÿÿ0.01ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿ|
      ÿÿ|ÿÿ3,748ÿÿÿ0.13ÿÿÿ0.16ÿÿÿ0.19ÿÿÿ0.18ÿÿÿ0.17ÿÿÿ0.09ÿÿÿ0.05ÿÿÿ0.03ÿÿÿ0.01ÿÿÿ0.00ÿ|
      ÿÿ|ÿÿ3,798ÿÿÿ0.05ÿÿÿ0.09ÿÿÿ0.14ÿÿÿ0.17ÿÿÿ0.21ÿÿÿ0.14ÿÿÿ0.09ÿÿÿ0.07ÿÿÿ0.02ÿÿÿ0.00ÿ|
      ÿÿ|ÿÿ3,799ÿÿÿ0.25ÿÿÿ0.21ÿÿÿ0.20ÿÿÿ0.15ÿÿÿ0.11ÿÿÿ0.05ÿÿÿ0.02ÿÿÿ0.01ÿÿÿ0.00ÿÿÿ0.00ÿ|
      ÿÿ|ÿÿ3,829ÿÿÿ0.62ÿÿÿ0.19ÿÿÿ0.10ÿÿÿ0.05ÿÿÿ0.02ÿÿÿ0.01ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿ|
      ÿÿ|------------------------------------------------------------------------------|
      ÿÿ|ÿÿ3,895ÿÿÿ0.12ÿÿÿ0.16ÿÿÿ0.19ÿÿÿ0.18ÿÿÿ0.17ÿÿÿ0.09ÿÿÿ0.05ÿÿÿ0.03ÿÿÿ0.01ÿÿÿ0.00ÿ|
      ÿÿ|ÿÿ3,955ÿÿÿ0.06ÿÿÿ0.10ÿÿÿ0.15ÿÿÿ0.18ÿÿÿ0.21ÿÿÿ0.13ÿÿÿ0.09ÿÿÿ0.06ÿÿÿ0.02ÿÿÿ0.00ÿ|
      ÿÿ|ÿÿ3,984ÿÿÿ0.53ÿÿÿ0.22ÿÿÿ0.13ÿÿÿ0.07ÿÿÿ0.04ÿÿÿ0.01ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿ|
      ÿÿ|ÿÿ3,995ÿÿÿ0.12ÿÿÿ0.16ÿÿÿ0.19ÿÿÿ0.18ÿÿÿ0.17ÿÿÿ0.09ÿÿÿ0.05ÿÿÿ0.03ÿÿÿ0.01ÿÿÿ0.00ÿ|
      ÿÿ|ÿÿ4,010ÿÿÿ0.02ÿÿÿ0.05ÿÿÿ0.09ÿÿÿ0.13ÿÿÿ0.20ÿÿÿ0.17ÿÿÿ0.14ÿÿÿ0.13ÿÿÿ0.06ÿÿÿ0.01ÿ|
      ÿÿ|ÿÿ4,060ÿÿÿ0.21ÿÿÿ0.20ÿÿÿ0.20ÿÿÿ0.16ÿÿÿ0.13ÿÿÿ0.06ÿÿÿ0.03ÿÿÿ0.01ÿÿÿ0.00ÿÿÿ0.00ÿ|
      ÿÿ|ÿÿ4,082ÿÿÿ0.03ÿÿÿ0.07ÿÿÿ0.12ÿÿÿ0.16ÿÿÿ0.21ÿÿÿ0.15ÿÿÿ0.11ÿÿÿ0.09ÿÿÿ0.03ÿÿÿ0.01ÿ|
      ÿÿ|------------------------------------------------------------------------------|
      ÿÿ|ÿÿ4,099ÿÿÿ0.12ÿÿÿ0.16ÿÿÿ0.19ÿÿÿ0.18ÿÿÿ0.17ÿÿÿ0.09ÿÿÿ0.05ÿÿÿ0.03ÿÿÿ0.01ÿÿÿ0.00ÿ|
      ÿÿ|ÿÿ4,172ÿÿÿ0.43ÿÿÿ0.23ÿÿÿ0.16ÿÿÿ0.10ÿÿÿ0.06ÿÿÿ0.02ÿÿÿ0.01ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿ|
      ÿÿ|ÿÿ4,181ÿÿÿ0.16ÿÿÿ0.18ÿÿÿ0.19ÿÿÿ0.18ÿÿÿ0.16ÿÿÿ0.08ÿÿÿ0.04ÿÿÿ0.02ÿÿÿ0.00ÿÿÿ0.00ÿ|
      ÿÿ|ÿÿ4,187ÿÿÿ0.31ÿÿÿ0.22ÿÿÿ0.19ÿÿÿ0.13ÿÿÿ0.09ÿÿÿ0.03ÿÿÿ0.01ÿÿÿ0.01ÿÿÿ0.00ÿÿÿ0.00ÿ|
      ÿÿ|ÿÿ4,195ÿÿÿ0.24ÿÿÿ0.21ÿÿÿ0.20ÿÿÿ0.15ÿÿÿ0.12ÿÿÿ0.05ÿÿÿ0.02ÿÿÿ0.01ÿÿÿ0.00ÿÿÿ0.00ÿ|
      ÿÿ|ÿÿ4,296ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.04ÿÿÿ0.07ÿÿÿ0.15ÿÿÿ0.16ÿÿÿ0.17ÿÿÿ0.21ÿÿÿ0.14ÿÿÿ0.05ÿ|
      ÿÿ|ÿÿ4,389ÿÿÿ0.51ÿÿÿ0.22ÿÿÿ0.14ÿÿÿ0.08ÿÿÿ0.04ÿÿÿ0.01ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿ|
      ÿÿ|ÿÿ4,424ÿÿÿ0.04ÿÿÿ0.08ÿÿÿ0.13ÿÿÿ0.17ÿÿÿ0.21ÿÿÿ0.15ÿÿÿ0.10ÿÿÿ0.08ÿÿÿ0.03ÿÿÿ0.00ÿ|
      ÿÿ|------------------------------------------------------------------------------|
      ÿÿ|ÿÿ4,425ÿÿÿ0.92ÿÿÿ0.06ÿÿÿ0.02ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿ|
      ÿÿ|ÿÿ4,453ÿÿÿ0.16ÿÿÿ0.18ÿÿÿ0.20ÿÿÿ0.18ÿÿÿ0.15ÿÿÿ0.07ÿÿÿ0.04ÿÿÿ0.02ÿÿÿ0.00ÿÿÿ0.00ÿ|
      ÿÿ|ÿÿ4,482ÿÿÿ0.63ÿÿÿ0.19ÿÿÿ0.10ÿÿÿ0.05ÿÿÿ0.02ÿÿÿ0.01ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿ|
      ÿÿ|ÿÿ4,499ÿÿÿ0.29ÿÿÿ0.22ÿÿÿ0.19ÿÿÿ0.14ÿÿÿ0.10ÿÿÿ0.04ÿÿÿ0.02ÿÿÿ0.01ÿÿÿ0.00ÿÿÿ0.00ÿ|
      ÿÿ|ÿÿ4,504ÿÿÿ0.00ÿÿÿ0.02ÿÿÿ0.04ÿÿÿ0.08ÿÿÿ0.16ÿÿÿ0.16ÿÿÿ0.17ÿÿÿ0.20ÿÿÿ0.13ÿÿÿ0.04ÿ|
      ÿÿ|ÿÿ4,516ÿÿÿ0.01ÿÿÿ0.03ÿÿÿ0.07ÿÿÿ0.12ÿÿÿ0.19ÿÿÿ0.17ÿÿÿ0.15ÿÿÿ0.15ÿÿÿ0.08ÿÿÿ0.02ÿ|
      ÿÿ|ÿÿ4,589ÿÿÿ0.03ÿÿÿ0.07ÿÿÿ0.11ÿÿÿ0.16ÿÿÿ0.21ÿÿÿ0.16ÿÿÿ0.12ÿÿÿ0.10ÿÿÿ0.04ÿÿÿ0.01ÿ|
      ÿÿ|------------------------------------------------------------------------------|
      ÿÿ|ÿÿ4,647ÿÿÿ0.02ÿÿÿ0.05ÿÿÿ0.09ÿÿÿ0.14ÿÿÿ0.20ÿÿÿ0.17ÿÿÿ0.14ÿÿÿ0.13ÿÿÿ0.06ÿÿÿ0.01ÿ|
      ÿÿ|ÿÿ4,697ÿÿÿ0.02ÿÿÿ0.06ÿÿÿ0.10ÿÿÿ0.15ÿÿÿ0.21ÿÿÿ0.16ÿÿÿ0.13ÿÿÿ0.11ÿÿÿ0.05ÿÿÿ0.01ÿ|
      ÿÿ|ÿÿ4,723ÿÿÿ0.02ÿÿÿ0.05ÿÿÿ0.09ÿÿÿ0.13ÿÿÿ0.20ÿÿÿ0.17ÿÿÿ0.14ÿÿÿ0.13ÿÿÿ0.06ÿÿÿ0.01ÿ|
      ÿÿ|ÿÿ4,733ÿÿÿ0.12ÿÿÿ0.16ÿÿÿ0.19ÿÿÿ0.18ÿÿÿ0.17ÿÿÿ0.09ÿÿÿ0.05ÿÿÿ0.03ÿÿÿ0.01ÿÿÿ0.00ÿ|
      ÿÿ|ÿÿ4,749ÿÿÿ0.02ÿÿÿ0.05ÿÿÿ0.10ÿÿÿ0.14ÿÿÿ0.21ÿÿÿ0.16ÿÿÿ0.13ÿÿÿ0.11ÿÿÿ0.05ÿÿÿ0.01ÿ|
      ÿÿ|ÿÿ4,816ÿÿÿ0.16ÿÿÿ0.18ÿÿÿ0.19ÿÿÿ0.18ÿÿÿ0.15ÿÿÿ0.07ÿÿÿ0.04ÿÿÿ0.02ÿÿÿ0.00ÿÿÿ0.00ÿ|
      ÿÿ|ÿÿ4,890ÿÿÿ0.00ÿÿÿ0.02ÿÿÿ0.04ÿÿÿ0.08ÿÿÿ0.16ÿÿÿ0.17ÿÿÿ0.17ÿÿÿ0.19ÿÿÿ0.12ÿÿÿ0.04ÿ|
      ÿÿ|ÿÿ4,934ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.03ÿÿÿ0.07ÿÿÿ0.14ÿÿÿ0.16ÿÿÿ0.17ÿÿÿ0.21ÿÿÿ0.15ÿÿÿ0.05ÿ|
      ÿÿ|------------------------------------------------------------------------------|
      ÿÿ|ÿÿ5,079ÿÿÿ0.01ÿÿÿ0.03ÿÿÿ0.07ÿÿÿ0.12ÿÿÿ0.19ÿÿÿ0.17ÿÿÿ0.15ÿÿÿ0.15ÿÿÿ0.08ÿÿÿ0.02ÿ|
      ÿÿ|ÿÿ5,104ÿÿÿ0.00ÿÿÿ0.02ÿÿÿ0.04ÿÿÿ0.08ÿÿÿ0.16ÿÿÿ0.17ÿÿÿ0.17ÿÿÿ0.19ÿÿÿ0.12ÿÿÿ0.04ÿ|
      ÿÿ|ÿÿ5,172ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.02ÿÿÿ0.04ÿÿÿ0.10ÿÿÿ0.13ÿÿÿ0.16ÿÿÿ0.24ÿÿÿ0.21ÿÿÿ0.10ÿ|
      ÿÿ|ÿÿ5,189ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.03ÿÿÿ0.07ÿÿÿ0.14ÿÿÿ0.16ÿÿÿ0.17ÿÿÿ0.21ÿÿÿ0.15ÿÿÿ0.05ÿ|
      ÿÿ|ÿÿ5,222ÿÿÿ0.00ÿÿÿ0.02ÿÿÿ0.04ÿÿÿ0.08ÿÿÿ0.16ÿÿÿ0.16ÿÿÿ0.17ÿÿÿ0.20ÿÿÿ0.12ÿÿÿ0.04ÿ|
      ÿÿ|ÿÿ5,379ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.02ÿÿÿ0.04ÿÿÿ0.10ÿÿÿ0.13ÿÿÿ0.16ÿÿÿ0.24ÿÿÿ0.21ÿÿÿ0.10ÿ|
      ÿÿ|ÿÿ5,397ÿÿÿ0.06ÿÿÿ0.11ÿÿÿ0.15ÿÿÿ0.18ÿÿÿ0.21ÿÿÿ0.13ÿÿÿ0.09ÿÿÿ0.06ÿÿÿ0.02ÿÿÿ0.00ÿ|
      ÿÿ|------------------------------------------------------------------------------|
      ÿÿ|ÿÿ5,705ÿÿÿ0.00ÿÿÿ0.02ÿÿÿ0.04ÿÿÿ0.08ÿÿÿ0.16ÿÿÿ0.17ÿÿÿ0.17ÿÿÿ0.19ÿÿÿ0.12ÿÿÿ0.04ÿ|
      ÿÿ|ÿÿ5,719ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.02ÿÿÿ0.06ÿÿÿ0.09ÿÿÿ0.13ÿÿÿ0.24ÿÿÿ0.27ÿÿÿ0.19ÿ|
      ÿÿ|ÿÿ5,788ÿÿÿ0.01ÿÿÿ0.02ÿÿÿ0.05ÿÿÿ0.09ÿÿÿ0.16ÿÿÿ0.17ÿÿÿ0.17ÿÿÿ0.19ÿÿÿ0.12ÿÿÿ0.04ÿ|
      ÿÿ|ÿÿ5,798ÿÿÿ0.00ÿÿÿ0.02ÿÿÿ0.04ÿÿÿ0.08ÿÿÿ0.16ÿÿÿ0.16ÿÿÿ0.17ÿÿÿ0.20ÿÿÿ0.13ÿÿÿ0.04ÿ|
      ÿÿ|ÿÿ5,799ÿÿÿ0.08ÿÿÿ0.12ÿÿÿ0.17ÿÿÿ0.18ÿÿÿ0.20ÿÿÿ0.12ÿÿÿ0.07ÿÿÿ0.05ÿÿÿ0.01ÿÿÿ0.00ÿ|
      ÿÿ|ÿÿ5,886ÿÿÿ0.01ÿÿÿ0.04ÿÿÿ0.08ÿÿÿ0.13ÿÿÿ0.20ÿÿÿ0.17ÿÿÿ0.15ÿÿÿ0.14ÿÿÿ0.07ÿÿÿ0.02ÿ|
      ÿÿ|ÿÿ5,899ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.02ÿÿÿ0.04ÿÿÿ0.10ÿÿÿ0.13ÿÿÿ0.16ÿÿÿ0.24ÿÿÿ0.20ÿÿÿ0.10ÿ|
      ÿÿ|------------------------------------------------------------------------------|
      ÿÿ|ÿÿ6,165ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.02ÿÿÿ0.05ÿÿÿ0.08ÿÿÿ0.13ÿÿÿ0.24ÿÿÿ0.28ÿÿÿ0.20ÿ|
      ÿÿ|ÿÿ6,229ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.02ÿÿÿ0.04ÿÿÿ0.10ÿÿÿ0.13ÿÿÿ0.16ÿÿÿ0.24ÿÿÿ0.21ÿÿÿ0.10ÿ|
      ÿÿ|ÿÿ6,295ÿÿÿ0.02ÿÿÿ0.05ÿÿÿ0.09ÿÿÿ0.14ÿÿÿ0.21ÿÿÿ0.17ÿÿÿ0.14ÿÿÿ0.12ÿÿÿ0.05ÿÿÿ0.01ÿ|
      ÿÿ|ÿÿ6,303ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.02ÿÿÿ0.05ÿÿÿ0.09ÿÿÿ0.20ÿÿÿ0.30ÿÿÿ0.33ÿ|
      ÿÿ|ÿÿ6,342ÿÿÿ0.02ÿÿÿ0.05ÿÿÿ0.09ÿÿÿ0.14ÿÿÿ0.21ÿÿÿ0.17ÿÿÿ0.14ÿÿÿ0.12ÿÿÿ0.06ÿÿÿ0.01ÿ|
      ÿÿ|ÿÿ6,486ÿÿÿ0.18ÿÿÿ0.19ÿÿÿ0.20ÿÿÿ0.17ÿÿÿ0.14ÿÿÿ0.07ÿÿÿ0.03ÿÿÿ0.02ÿÿÿ0.00ÿÿÿ0.00ÿ|
      ÿÿ|ÿÿ6,850ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.02ÿÿÿ0.05ÿÿÿ0.12ÿÿÿ0.14ÿÿÿ0.17ÿÿÿ0.23ÿÿÿ0.18ÿÿÿ0.07ÿ|
      ÿÿ|ÿÿ7,140ÿÿÿ0.01ÿÿÿ0.03ÿÿÿ0.06ÿÿÿ0.11ÿÿÿ0.19ÿÿÿ0.17ÿÿÿ0.16ÿÿÿ0.16ÿÿÿ0.09ÿÿÿ0.02ÿ|
      ÿÿ|------------------------------------------------------------------------------|
      ÿÿ|ÿÿ7,827ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.03ÿÿÿ0.05ÿÿÿ0.09ÿÿÿ0.20ÿÿÿ0.30ÿÿÿ0.33ÿ|
      ÿÿ|ÿÿ8,129ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.02ÿÿÿ0.05ÿÿÿ0.12ÿÿÿ0.14ÿÿÿ0.17ÿÿÿ0.23ÿÿÿ0.18ÿÿÿ0.08ÿ|
      ÿÿ|ÿÿ8,814ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.04ÿÿÿ0.07ÿÿÿ0.11ÿÿÿ0.23ÿÿÿ0.29ÿÿÿ0.24ÿ|
      ÿÿ|ÿÿ9,690ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.02ÿÿÿ0.06ÿÿÿ0.09ÿÿÿ0.13ÿÿÿ0.24ÿÿÿ0.27ÿÿÿ0.19ÿ|
      ÿÿ|ÿÿ9,735ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.02ÿÿÿ0.06ÿÿÿ0.09ÿÿÿ0.14ÿÿÿ0.24ÿÿÿ0.26ÿÿÿ0.17ÿ|
      ÿÿ|ÿ10,371ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.03ÿÿÿ0.06ÿÿÿ0.10ÿÿÿ0.21ÿÿÿ0.30ÿÿÿ0.29ÿ|
      ÿÿ|ÿ10,372ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.02ÿÿÿ0.05ÿÿÿ0.11ÿÿÿ0.14ÿÿÿ0.16ÿÿÿ0.23ÿÿÿ0.19ÿÿÿ0.09ÿ|
      ÿÿ|------------------------------------------------------------------------------|
      ÿÿ|ÿ11,385ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.02ÿÿÿ0.09ÿÿÿ0.23ÿÿÿ0.65ÿ|
      ÿÿ|ÿ11,497ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.03ÿÿÿ0.11ÿÿÿ0.85ÿ|
      ÿÿ|ÿ11,995ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.02ÿÿÿ0.05ÿÿÿ0.14ÿÿÿ0.28ÿÿÿ0.51ÿ|
      ÿÿ|ÿ12,990ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.02ÿÿÿ0.05ÿÿÿ0.13ÿÿÿ0.28ÿÿÿ0.51ÿ|
      ÿÿ|ÿ13,466ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.03ÿÿÿ0.08ÿÿÿ0.12ÿÿÿ0.15ÿÿÿ0.24ÿÿÿ0.23ÿÿÿ0.13ÿ|
      ÿÿ|ÿ13,594ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.06ÿÿÿ0.93ÿ|
      ÿÿ|ÿ14,500ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.02ÿÿÿ0.06ÿÿÿ0.10ÿÿÿ0.14ÿÿÿ0.24ÿÿÿ0.26ÿÿÿ0.17ÿ|
      ÿÿ|ÿ15,906ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.00ÿÿÿ0.01ÿÿÿ0.05ÿÿÿ0.08ÿÿÿ0.12ÿÿÿ0.23ÿÿÿ0.28ÿÿÿ0.22ÿ|
      ÿÿ+------------------------------------------------------------------------------+

      .ÿ
      .ÿexit

      endÿofÿdo-file


      .

      Comment


      • #4
        It is possible to reduce my sample size, but I will face the same problem such as memory issues unless the reduction is substantial. This is the reason why I would like to use Mata.

        Basically, what I would like to do is as follows:

        I got each p vector that consists of predicted values for every observation (thus, sample size X 1). Then, I would like to merge them into one matrix.

        Code:
         mata: p= p1,p2, p3, p4, p5, ... pmax
        I have tried to do programming like:

        Code:
         mata:
        void merge(real scalar i) {
            for (i=1; i<= 100; i++) {
            p[i] = p[i],p[i+1]
             }
        }
        end
        However, my codes did not work with the following error:

        Code:
        mata: merge(100)
             merge(): 3301 subscript invalid
             <istmt>: - function returned error
        r(3301);
        Could you please give me any advice?

        Thank you!


        Comment

        Working...
        X