Announcement

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

  • Calculating Chow test in a loop and reporting them in a table

    Hello,

    I have dataset divided by groups, and I am computing the Chow test for some subgroups of the sample (https://www.stata.com/support/faqs/s...how-statistic/). I am trying to report the statistic as one more statistic with estout using the following code:

    HTML Code:
    sysuse auto, clear
    
    eststo: reg price mpg
        scalar RSS_full = e(rss)
        scalar k        = e(rank) + 1
    
    eststo clear    
    forvalues i = 1/5 {
    
    eststo: quietly reg price mpg if rep78 == `i'
        scalar RSS`i' = e(rss)
        scalar N`i'   = e(N)
        
    quietly reg price mpg if rep78 != `i'
        scalar RSSn`i' = e(rss)
        scalar Nn`i'   = e(N)    
        
        estadd local chow = ((RSS_full - RSS`i' - RSSn`i')/k)/((RSS`i' + RSSn`i')/(N`i' + Nn`i' - 2*k))
    }
    
    esttab, s(N chow r2_a,label("N" "Chow Test" "Adjusted R2"))
    The resulting output is the following:

    Click image for larger version

Name:	stata.png
Views:	1
Size:	42.6 KB
ID:	1713836


    That is, even though the Chow test has been properly calculated, it is not reported on the table. Instead I get the message
    HTML Code:
    (tabulating estimates stored by eststo; specify "." to tabulate the active results)
    But this only saves the last regression calculated... How can I properly report the chow statistic?

    Thank you

  • #2
    estout is from SSC, as you are asked to explain (FAQ Advice #12).

    Code:
    sysuse auto, clear
    estimates clear
    
    eststo: reg price mpg
        scalar RSS_full = e(rss)
        scalar k        = e(rank) + 1
    
    eststo clear    
    forvalues i = 1/5 {
    
    eststo: quietly reg price mpg if rep78 == `i'
        scalar RSS`i' = e(rss)
        scalar N`i'   = e(N)
        
    quietly reg price mpg if rep78 != `i'
        scalar RSSn`i' = e(rss)
        scalar Nn`i'   = e(N)    
        
        estadd local chow = ((RSS_full - RSS`i' - RSSn`i')/k)/((RSS`i' + RSSn`i')/(N`i' + Nn`i' - 2*k)): est`i'
    }
    
    esttab, s(N chow r2_a,label("N" "Chow Test" "Adjusted R2"))

    Comment

    Working...
    X