Announcement

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

  • #16
    I have found elsewhere how to include these r-squared and RMSE. Thanks again!

    Comment


    • #17
      I have found elsewhere how to include these r-squared and RMSE. Thanks again!

      Comment


      • #18
        Code:
        capture postutil clear
        tempfile results
        postfile handle int filenum hhsize_coeff region_coeff rmse r2 using `results'
        forvalues i = 1/4 {
            use country`i', clear
            reg lncon hhsize region
            local topost(`i') (_b[hhsize]) (_b[region]) (e(rmse)) (e(r2))
            post handle `topost'
        }
        postclose handle
        preserve
        use `results', clear
        Note that I have removed the -matrix M = r(table)- command because the rest of the code makes no use of that matrix here. (You are saving different statistics from the ones in the post that started this thread--that one required some statistics found in r(table), but your problem doesn't.)

        As an aside, be careful how you use this code. If you just run this code exactly as as, the -preserve- near the end will cause the original data to come right back into memory immediately after -use `results', clear- finishes. So you will never get to see the results! So you need to add some more code to do whatever it is you need to do with the results to the end of the code. Alternatively, eliminate the -preserve- command (which will then mean that your original data will be lost.) If you are using version 16 of Stata, you can have both in memory by using frames (and, in that case there is a way to use frames that avoids using -postfile-) but with any earlier version of Stata you can't have both.

        Added: For whatever reason, when I opened this thread, it came up on #15, and I did not see #16 or #17 which made this response unnecessary. Perhaps somebody else will find it helpful, however.
        Last edited by Clyde Schechter; 29 Sep 2019, 18:36.

        Comment

        Working...
        X