Announcement

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

  • suest command: estimation sample of the model saved under X could not be restored

    Good day statalisters,

    I am trying to use the suest command to test if coefficients from a linear regression and an instrumental variables regression are significantly different from one another. I cannot use the Hausman test as I am using survey data with probability weights and cluster-robust standard errors. The data I am using is from the Trends in International Mathematics and Science Study (TIMSS) and the pv package is used to run the regressions with plausible values (ssc install pv).

    I am running the following regressions, with model I being the linear regression model and model II being the instrumental variable model (the first stage regression of the IV model was run separately - not shown here):
    Code:
    *PV regression
    pv , pv(math_pv*) jkzone(JKZONE) jkrep(JKREP) weight(TOTWGT) jrr timss: xi: reg @pv MathPR  Math_intrinsic i.school_location i.School_safety bullying_SCL Math_class_size Teacher_accountability i.Math_PI i.books_in_home HSES i.speaks_test_language i.student_sex Student_Age [aw=@w], robust cluster(MT_IDTEACH)
    est store I
    
    *IV regression
    pv , pv(math_pv*) jkzone(JKZONE) jkrep(JKREP) weight(TOTWGT) jrr timss: xi: ivregress 2sls @pv Math_intrinsic i.school_location i.School_safety bullying_SCL Math_class_size Teacher_accountability i.Math_PI i.books_in_home HSES i.speaks_test_language i.student_sex Student_Age (MathPR=SciencePR) [aw=@w] , robust cluster(MT_IDTEACH)
    est store II
    I then use the suest code as follows:
    Code:
    suest II I
    and it returns the error:
    estimation sample of the model saved under II could not be restored
    r(198);

    Any help would be greatly appreciated! A sample of the data is provided below.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(MathPR SciencePR Math_intrinsic) byte(school_location School_safety) float bullying_SCL int Math_class_size float Teacher_accountability byte(Math_PI books_in_home) float HSES byte(speaks_test_language student_sex) double Student_Age
      .6767668   .28471103    .4267516 0 3  -.1514476  38   .1932887 2 1  -4.589302 1 1 17.25
      .6767668    .8832139    .1802771 1 3  1.4730828  45   1.298639 3 0  -4.589302 1 1 15.08
     -.4886714   -.3134181  -1.7995194 4 0  1.3955585  64   .1932887 3 0  -4.589302 1 1  14.5
     -2.398073  -2.1964524  -2.1793277 0 2  -.9123261  27 -.53621215 1 0  -4.589302 0 0 16.25
    -1.4862378  -.27377465    -1.31475 1 2   1.586333  45   .1932887 0 0  -4.589302 0 0 16.08
      .6767668    .8832139    .4019347 1 3    3.12654  48   1.298639 3 0  -4.589302 1 1    18
      .6767668    .8832139  -.31370085 0 3  -.6166733  38   .1932887 3 0  -4.589302 1 0 15.75
    -2.1200454  -1.4422493    .4452515 2 3 -.41079915  46   .1932887 2 0  -4.589302 1 0 17.83
      .6767668  .031254113    .8281376 2 2 -1.2932657  42  -1.377403 3 0  -4.589302 1 1 14.58
    -1.0380422  -.06092897    .7620944 1 2  -.6267825  98   .7167283 3 1  -4.589302 0 0 16.17
     -.6328472   -.6807983   -1.837227 4 2  1.0584339  64   .1932887 2 0  -4.589302 1 0 14.75
    -.50897855    .8832139  -.31904855 0 3   .4633826  49   1.298639 3 0  -4.589302 1 1 15.42
      .6767668    .8832139   1.2743094 3 3  -.5204309  38   .1932887 3 1  -4.589302 1 1 15.67
      .6767668    .8832139   1.2743094 0 3  .51902235  54   .1932887 3 0  -4.589302 1 1  14.5
     -.4931108   -.6131534  -.25801075 0 2  1.5123183  68  -.5320541 2 2 -3.9811494 1 1 16.42
     -2.386701  -.28272328  -1.5482956 4 1  1.5416265  44   .1932887 3 0 -3.9811494 1 1    15
      .3326921   -.9348434   -.4535648 0 3  -.4008917  41   1.298639 3 1 -3.9811494 1 1 14.92
     -3.723965   -1.236533  -1.2114418 0 0   1.405856  53  -1.963472 1 0 -3.9811494 1 0    19
    -.08936088   .28471103   -.5943833 4 2 -.11315808 115   .7751996 3 0 -3.9811494 1 1 14.67
      .6767668    .8832139   1.2743094 0 3  -.7440723  55  -.5320541 3 1 -3.9811494 1 1 15.33
    -.08655683  -1.9167427    .4503328 0 1  .02412174  52   .1932887 3 0 -3.9811494 1 1 16.83
    -1.3817012   -.6121857   .06787527 0 3  2.3048825  64   .1932887 1 0 -3.9811494 1 0 15.08
    -1.0152998  -1.6388594     .826775 0 3 -1.2018198  54  -.6520603 2 1 -3.9811494 1 0 14.25
      .6767668    .8832139    .8914233 1 2    .888905  57   .7751996 3 0 -3.9811494 1 1  14.5
     -.8729917    .8832139   1.0744292 0 3  1.5933495  25   1.298639 3 0 -3.9811494 1 0    16
      .6767668    .8832139   .23092845 1 3  2.3528757  98   .7167283 3 0 -3.9811494 0 0 16.42
    -1.4373527    .2460354  -.40170285 0 3  .27704683  74   .1932887 2 0 -3.9811494 1 0 17.33
      .6767668   .54480296   .53784347 4 3    1.97683 115   .7751996 2 0 -3.9811494 1 1 14.67
     -.1876462    .8832139   -.6659923 4 1   .5979941  49  -1.963472 2 1 -3.9811494 1 1  16.5
      .6767668    .0380227    .5431357 1 3   1.678239  47   .7167283 3 1 -3.9811494 0 1 16.67
      .6767668    .8832139   1.2743094 3 3  -.7096612  37   1.298639 3 1 -3.9811494 1 1 14.83
      .6767668    .8832139    .7848208 0 3    3.12654  40  -1.377403 3 0 -3.9811494 3 0 17.17
    -.14903605  -1.3569423   .26118279 0 2   .7417966  26   1.298639 2 0 -3.9811494 1 1  14.5
    -2.3629801   -1.620542   -.2012464 4 3  1.3312018  44   .1932887 3 2 -3.9811494 1 0    17
    -1.5336967   -1.388952   -.8166596 0 3   .7668611  52 -1.9159825 1 1 -3.9811494 1 1  14.5
    -1.8983575   .56211215  -1.6178962 0 3   2.707776  80   1.298639 3 0 -3.9811494 1 1 16.67
    -1.0380422   -.8168808     -.54815 0 3   2.708467  34   .1932887 2 0 -3.9811494 0 0 16.58
     .23440674   .56211215    .7472612 4 2   .1809394  32  -.5320541 2 1 -3.9811494 1 0 17.75
     -.8731431   -.8168808   -.5430655 2 2  1.1192192 108   .7167283 3 3 -3.9811494 1 0  15.5
      .6767668    .8832139  -.16184653 1 3  -.7819822  98   .7167283 3 1 -3.9811494 1 1 15.75
    -.08936088  -.48557475   1.2743094 4 3 .025976947  50   .7751996 2 0 -3.9811494 1 0 16.08
    -.50897855  .066968136    -.737709 1 3  1.5274576  98   .7167283 0 2 -3.9811494 1 0 17.17
    -1.5813745   -.8717746   -1.776383 1 3  1.4048352  42  -1.377403 2 0 -3.9811494 3 0 15.75
      .6767668    .8832139    .7377237 0 3  1.2076674  62   .1932887 2 0 -3.9811494 1 1 16.67
     -.9921886   .00929958     .692853 4 3 -1.2932657  52  .04985677 0 0 -3.9811494 1 0 17.75
     -1.506321    .2450676   -1.602127 0 2 -.50277036  59   1.298639 2 2 -3.9811494 1 0  15.5
     -.9310315   -.7078685  -.17841627 1 2 -1.2041543  58  -1.377403 2 1 -3.9811494 1 0 16.58
      .6767668  -.06092897  -.06228221 1 3   1.382715  51   .1932887 3 0 -3.9811494 1 1 16.17
      .6767668   .54480296    -1.02053 1 3  1.0347371  68   .1932887 2 0 -3.9811494 0 0 14.92
     -.1876462    .2623768   .20205447 1 3    2.19184  98   .7167283 3 1 -3.9811494 1 1 14.92
      .6767668    .8832139   -.3391902 4 3  -.7987245  35  -1.377403 3 0 -3.9811494 1 1 14.17
      .6767668     .331971  -1.6076163 2 3   .9323292  38   .1932887 3 1 -3.9811494 1 1 14.67
    -1.7787747   -.6807983   -.4196265 0 3  -.5386193  26   1.298639 3 0 -3.9811494 1 1 14.42
     -.4931108   -1.320598   1.0744292 3 3 -.37180355  73  -.6520603 1 1 -3.9811494 1 1 14.83
     -1.204492  .031254113  -.22387725 3 3  1.3898066  56   .7751996 3 4 -3.9811494 0 0 15.42
     .25471392           .    .7156831 1 3   .8750167  40   .1932887 1 0 -3.9811494 3 0    17
    -.06661846    .8832139   -.4196265 0 2  -.9585081  56   .7167283 2 1 -3.9811494 1 0 15.08
     .25471392    .8832139   -.5868443 4 3   .4673751  36   .1932887 2 0 -3.9811494 1 1 16.67
     -.9907067           .  -.08446168 1 3   .5973586  39  -1.118123 2 0 -3.9811494 3 1 14.67
     -.4886714   -.8194182  -.25841075 4 3   1.472912  38   .1932887 2 0 -3.9811494 1 0 16.08
      .6767668   .28471103   -.9018676 1 2   1.690691  86   .1932887 0 0 -3.9811494 1 0 15.75
      .6767668    .8832139   -.6113003 2 3  1.3681393  62   .1932887 3 0 -3.9811494 1 0 17.42
     -1.276893  .010869186   .11541858 0 3  1.5890336  49  -.5320541 2 0 -3.9811494 1 0    18
     -.6509178    .8832139   -.7205046 4 3   .8208346  49  -1.963472 3 0 -3.9811494 1 0 15.08
      .3326921    .5772174   1.2743094 1 3  1.1710728  43   1.298639 3 0 -3.9811494 1 1 14.92
    -1.5521773   -.6351079  -1.7949414 3 0   .3045433  38  -.5320541 2 1 -3.9811494 1 0 14.33
      .6767668  -.04265196   .28936982 1 3 -1.1683102  49   .1932887 3 1 -3.9811494 1 1 15.17
    -.10966805  -1.1349068    .4929727 0 3  -.1014244  52 -1.9159825 3 1 -3.9811494 1 1 15.67
     .27745634   .28471103   -.9452633 4 3   .6020373  43   .1932887 3 0 -3.9811494 2 0 16.33
      .6767668    .8832139    .8281376 1 3   -.980961  55   1.298639 3 0 -3.9811494 0 0 15.67
      .6767668   -.6807983   1.2743094 0 3  -.7394847  41  -2.502051 3 1 -3.9811494 2 0 15.75
      .6767668    .5844464  -1.3518157 1 3  1.5442594  59  -.5320541 0 0 -3.9811494 1 0 15.67
      .6767668    .8832139    .6300222 0 3   -.701727  54  -.6520603 3 0 -3.9811494 1 1 16.17
     -.4886714   .22370116   -.4196265 3 2   1.818362  52   .7751996 2 1 -3.9811494 1 0 16.83
     -.1876462  -.27279314  -.30543435 1 2  1.7959652  98   .7167283 2 0 -3.9811494 3 0 17.42
      .6767668    .8832139   .16473973 1 3  2.0171459  42  -.5320541 3 0 -3.9811494 1 0    15
     .23440674  -.04265196   .22787303 1 2  1.3404462  55  -1.377403 2 1 -3.9811494 1 0    18
     .25471392   .28471103   1.0280179 2 3 -.27180627  45  -.5320541 3 1 -3.9811494 1 0 16.83
      -1.97363 -.006440024   -.2032803 4 0  2.0713465  52  -.5320541 1 1 -3.9811494 1 1  17.5
      .6767668  -2.1472397   1.2743094 0 2  -.2355946  80   1.298639 3 1  -3.939518 2 0 14.83
      .6767668    .8832139    .7848208 1 2  -.3032076  39  -1.377403 3 2  -3.939518 1 1 15.58
      .6767668    .2623768    .6696445 0 2   .8395413  97   .7751996 3 2  -3.939518 1 1 17.58
    -.10966805  -.04361976    .5804835 1 3  1.2820423  52   .7751996 2 1  -3.939518 1 1 17.17
      .6767668   .05481461   -.9334217 1 3 -1.2932657  98   .7167283 3 0  -3.939518 0 1 18.33
      .6767668    .5844464   .26014954 0 2   .7253527 118   1.298639 3 0  -3.939518 1 0 15.67
      .6767668   .54480296   1.2743094 0 3  1.1173382  42   .1932887 3 4  -3.939518 3 1 14.33
     -.4963766  -.25190526   .28401294 1 2   .4525651  49   .1932887 1 1  -3.939518 3 1  14.5
      .6767668    .8832139   1.0744292 4 3  1.7825637  35  -1.377403 2 2  -3.939518 2 1 15.25
    -1.1488405  -.25075212    .6300222 0 0    .627751  68  -.5320541 3 4  -3.939518 0 1 15.25
     .24574797    .3542316     .763096 0 3   .4099571  60  -.5320541 3 1  -3.939518 1 1 15.58
      .6767668  -1.1578292   1.2743094 2 3    1.31917  72   1.298639 2 1  -3.939518 1 0 15.67
      .6767668    .3309895   -1.213872 0 2  1.1181397  60  -.5320541 2 2  -3.939518 1 1 14.25
     -.9151638  -1.0505408  -.02984388 0 0 -.08003784  12   .7751996 3 0  -3.939518 0 1 16.08
    -1.7786235   -.6807983 -.066014454 0 2  -.7923887 108   .7751996 2 1  -3.939518 1 1 14.67
     -3.418566  -1.8917173     -.31636 0 3  1.8106883  74   .1932887 1 3  -3.939518 2 1    15
      .6767668    .5834786   -1.353957 0 1  -.7161782  16   .1932887 2 0  -3.939518 0 1 14.33
      .6767668    .8832139   1.2743094 2 3  -.7654406  76  -1.377403 3 2  -3.939518 1 1 16.42
    -.56033766  -.54194343    .6730431 0 3  2.5043385  64   1.298639 3 1  -3.939518 1 0  14.5
    -.10966805   -2.092257   1.2743094 3 3   -.321905  40   .1932887 3 0  -3.939518 1 0 13.92
     -1.356722  .033129778   -.6265423 4 3  1.1741279  39  -1.377403 0 1  -3.939518 1 1 17.08
    end
    label values school_location BCBG05B
    label def BCBG05B 0 "Remote rural", modify
    label def BCBG05B 1 "Small town", modify
    label def BCBG05B 2 "Medium City", modify
    label def BCBG05B 3 "Suburban", modify
    label def BCBG05B 4 "Urban", modify
    label values School_safety agreedisagree_4op_pos
    label values Math_PI agreedisagree_4op_pos
    label def agreedisagree_4op_pos 0 "Disagree a lot", modify
    label def agreedisagree_4op_pos 1 "Disagree a little", modify
    label def agreedisagree_4op_pos 2 "Agree a little", modify
    label def agreedisagree_4op_pos 3 "Agree a lot", modify
    label values books_in_home BSBG04
    label def BSBG04 0 "None or very few (0-10 books)", modify
    label def BSBG04 1 "Enough to fill one shelf (11-25 books)", modify
    label def BSBG04 2 "Enough to fill one bookcase (26-100 books)", modify
    label def BSBG04 3 "Enough to fill two bookcases (101-200 books)", modify
    label def BSBG04 4 "Enough to fill three or more bookcases (more than 200)", modify
    label values speaks_test_language neveralways_4options_pos
    label def neveralways_4options_pos 0 "Never", modify
    label def neveralways_4options_pos 1 "Sometimes", modify
    label def neveralways_4options_pos 2 "Almost Always", modify
    label def neveralways_4options_pos 3 "Always", modify
    label values student_sex boygirl
    label def boygirl 0 "Boy", modify
    label def boygirl 1 "Girl", modify

  • #2
    Probably the command pv obliterates the previous estimation sample after each run. suest needs the estimation samples in memory. Consider the following:

    Code:
    sysuse auto, clear
    qui regress mpg weight disp
    est sto m1
    webuse grunfeld, clear
    qui regress invest mvalue kstock
    est sto m2
    suest m1 m2
    Res.:

    Code:
    . suest m1 m2
    estimation sample of the model saved under m1 could not be restored
    r(198);

    I get the same error because I cleared memory when loading the Grunfeld dataset.
    Last edited by Andrew Musau; 19 Jan 2023, 01:54.

    Comment


    • #3
      Thanks Andrew! That makes sense, do you perhaps know of an alternate package or methodology to store the estimation samples?

      Comment


      • #4
        I can deal with my problem in #2 by appending the auto and Grunfeld datasets, so that I need not clear memory when I load the latter. In your case, it seems that you are using the same dataset, so the issue appears to be with the command itself which I do not use and therefore cannot provide any suggestions. In any case, even if you were to use the official commands (regress and ivregress), suest does not support ivregress, so you will need a completely different strategy.

        Comment


        • #5
          I see, I'll look for another approach then, thanks so much!

          Comment

          Working...
          X