Announcement

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

  • How to make Stata recognize saved estimates when doing suest command

    Dear Statalist user,

    I have a problem regarding my saved estimates that should be fairly easy to solve but I am unable to accomplish it. I found some Stata instructional material but was unable to find a fitting solution.


    My problem is that I have two saved estimates from two different regressions I did under the file names, "notworking1.ster" and "notworking2.ster", and I can't seem to get Stata to find either file.

    Whenever I type "suest notworking1 notworking2", it replies with the error " estimation result notworking1 not found r(111);".

    Despite this however, I can get Stata to show the individual regression tables for each estimate.

    If I type "use estimate notworking1" or "use estimate notworking2", followed then by the "estimate" or "estimates" command, it will bring up the table for whichever estimation was commanded last to be used.

    If I type though "estimates dir" though, again it doesn't bring up anything.

    I've made sure I have the right file directory and have also tried commands to restore the estimates, but to no avail, as it always says estimation result cannot be found.

    Therefore, if anyone would have an idea of what to do, I would greatly appreciate it.

    Best,

    Josh





  • #2
    The output of help estimates shows us that you can save estimates on disk - which is what you have done - or you can store estimates in memory - which allows you to switch quickly between sets of estimates, and to have multiple sets of estimates in memory for use by commands like suest. The estimates dir command shows estimates stored in memory; you have none. You need to use something like
    Code:
    estimates use notworking1
    estimates use notworking2
    estimates dir
    suest notworking1 notworking2
    An alternative to what you did with estimates save is
    Code:
    regress ...
    estimates store notworking1
    regress ...
    estimates store notworking2
    suest notworking1 notworking2
    To get a better understanding of the use of the estimates commands, see the estimates entry in the Stata Base Reference Manual PDF included with your Stata installation and accessible through Stata's Help menu.

    Comment


    • #3
      Dear William,

      Thanks for the reply.


      Doing the commands:

      Code:
      estimates use notworking1
      estimates use notworking2
      estimates dir
      suest notworking1 notworking2


      Still results in the Stata saying "estimation result notworking1 not found r(111);"



      The alternative you show, where I do my regressions, save them, and then go to use suest all in one, I don't know how to do because my regressions are done for two different time periods from a combined data set made of two merged data sets.

      Essentially, I do sub-samples from this combined data set, covering the years 2000-2008, by making certain exclusions, i.e. in the first sub sample only having certain observations from 2000-2002, and in the second having only from 2003-2008. As a result, I've usually cleared after making a regression for one time period so I can start again with all the observations for focusing on the other time period.

      This of course though deletes the estimates stored, which is why I tried to just save the estimates as files and then, in a separate Stata session, just use the suest command. That said, I would either need a way to get back dropped observations or find a way to clear without getting rid of stored estimations.

      Please let me know if you know a solution to this or another possible idea.

      Thanks again,

      Josh

      Comment


      • #4
        As a result, I've usually cleared ... This of course though deletes the estimates stored
        Actually, no. The output of help clear tells us
        Code:
        clear matrix
        clear *
        will delete the stored estimates, but for what you describe, it seems a simple
        Code:
        clear
        should suffice, and it will leave the stored estimates in place.
        Code:
        . sysuse auto, clear
        (1978 Automobile Data)
        
        . quietly regress mpg weight
        
        . estimates store gnxl
        
        . estimates dir
        
        -------------------------------------------------------
                name | command      depvar       npar  title
        -------------+-----------------------------------------
                gnxl | regress      mpg             2  
        -------------------------------------------------------
        
        . clear
        
        . estimates dir
        
        -------------------------------------------------------
                name | command      depvar       npar  title
        -------------+-----------------------------------------
                gnxl | regress      mpg             2  
        -------------------------------------------------------
        Taking a more efficient approach to your modeling will eliminate the need for the clear altogether.

        I do sub-samples from this combined data set, covering the years 2000-2008, by making certain exclusions ...
        Lacking details of your restrictions, let me suppose your first subsample is year<=2002 and foo!=43, while your second subsample is year>=2003 and foo!=26. I suggest trying something like
        Code:
        generate subsamp = .
        replace subsamp = 1 if year<=2002
        replace subsamp = . if subsamp==1 & foo==43
        replace subsamp = 2 if year>=2003
        replace subsamp  = . if subsamp==2 & foo==26
        regress ... if subsamp==1
        estimates store notworking1
        regress ... if subsamp==2
        estimates store notworking2
        suest notworking1 notworking2
        But of course the actual code will depend very much on how your subsamples are constructed. The point is to no use keep and drop to reduce the number of observations, but to construct an indicator that tells you which observations are to be included in each subsample.

        Finally, with regard to the initial code I suggested in post #2, I'm guessing (since you don't show us) that the estimates dir did not show any output, which if you read help esimtates store tells us there are no estimates stored. What I should have suggested (but again, this is a second-best solution to running both regressions and the suest in the same task) is
        Code:
        estimates use notworking1
        estimates store notworking1
        estimates use notworking2
        estimates store notworking2
        estimates dir
        suest notworking1 notworking2

        Comment


        • #5
          Dear William,

          I have now tried both doing the regressions with clearing in between the subsamples, using the simple "clear" command to keep stored estimates, then later using the "suest" command, i.e;

          Code:
          regress
          
          estimates store notworking1
          
          estimates dir
          
          -------------------------------------------------------
                  name | command      depvar       npar  title
          -------------+-----------------------------------------
           notworking1 | regress      notworking     15  
          -------------------------------------------------------
          
          clear
          
          regress
          
          estimates store notworking2
          
          estimates dir
          
          -------------------------------------------------------
                  name | command      depvar       npar  title
          -------------+-----------------------------------------
           notworking1 | regress      notworking     15  
           notworking2 | regress      notworking     15  
          -------------------------------------------------------
          
          suest notworking1 notworking2
          
          estimation sample of the model saved under notworking1 could not be restored
          r(198);
          and used

          Code:
           estimates use notworking1
          estimates store notworking1
          estimates use notworking2
          estimates store notworking2
          estimates dir
          -------------------------------------------------------
                  name | command      depvar       npar  title
          -------------+-----------------------------------------
           notworking1 | regress      notworking     15  
           notworking2 | regress      notworking     15  
          -------------------------------------------------------
          
          suest notworking1 notworking2
          but both of these after doing "suest" have resulted in

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

          I then tried to restore it via

          Code:
          . estimates restore notworking1
          (results notworking1 are active now)
          but doing the "suest command after just resulted in the same error r(198). The estimate show up after using "estimates dir" but now seem unable to be restored, whether from a saved estimate or from a stored estimate. Is there a possible solution to this?

          Comment


          • #6
            please use -estimates describe-; either
            Code:
            estimates describe networking1
            if in memory; or
            Code:
            estimates describe using networking1
            if saved to disk

            Comment


            • #7
              Apparenly you haven't tried the technique I recommended in post #4, but instead made the minimal modifications to your existing code I described as the second-best technique.

              I believe your problem in post #5 is an artifact of your having run your models on two separate datasets, rather than on a combined dataset using if clauses to choose the modeling subsamples, which is apparently required when using suest,

              Please do note Example 1 in the output of help suest which shows a situation much like yours, where the separate models are fit to subsets of the data using an if clause rather than by dropping observations. And note also the description, which includes

              The models may be estimated on different samples, due either to explicit if or in selection or to missing values.
              but says nothing at all about different samples from different datasets.

              So your next step is to modify your code to try the technique I recommended in post #4.

              Comment

              Working...
              X