Announcement

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

  • conduct hausman test and display resulting p-value in esttab output

    My MWE looks like this:

    Code:
    clear
    sysuse auto.dta
    
    gen time = _n
    
    xtset rep78 time
    
    estimates clear
    
    eststo: xi: reg price mpg i.rep78
    eststo: xi: reg price length i.rep78
    eststo: xi: reg price weight i.rep78
    
    esttab * using output.tex, replace
    Technically, what I am doing here are fixed-effects models, using the fact that reg ... i.rep78 gives the same as xtreg ... , fe.

    What I would like is to add a row in the esttab output that displays for each estimation the p-value of a Hausman-Test, determining whether RE would give a better fit than FE.

    How would I have to change the above code to achieve that? I guess I should use loops, i.e. looping through each variable mpg length weight, but I don't know if there is one result stored in r() that I can display, without displaying the estimators for the RE-models.

  • #2
    Here is what I came up with:
    Code:
    clear
    sysuse auto.dta
    
    gen time = _n
    
    xtset rep78 time
    
    estimates clear
    
    eststo: xi: reg price mpg i.rep78
    
    eststo: xtreg price mpg, re
    hausman est1
    return list
    local phausman = r(p)
    di phausman
    estimates drop est2
    
    eststo: xi: reg price length i.rep78
    eststo: xi: reg price weight i.rep78
    
    esttab * using mwe29.3..tex, replace stats(p chi2 F N)
    I want to run the same three models as before.
    After the first model, which is a FE-model, I run a RE-model with equivalent specifications, then conducted a hausman test (marked in red). This hausman test stores its p-value, i.e. the "decision maker" whether to use fixed or random effects, in r(p) (marked in yellow at the bottom):
    Click image for larger version

Name:	mwe29.3.png
Views:	1
Size:	50.0 KB
ID:	1380977


    Now, I do not want to display the detailed results of the RE-estimate and the Hausman test in my esttab output. I only want the initial three models (marked in blue). Hence, I use
    Code:
    estimates drop est2
    but this does not take care of the fact that I cannot append the p-value of the Hausman test to the first model's estimates (est1), ideally under a different name so as not to overwrite that model's p-value (marked also yellow in the picture above, at the top).
    I tried to store that value under the new name phausman, but that did not work.

    Is there something I am missing? Does it not make sense to include the result of a Hausman test together with other results of a fixed-effects-model?

    Best,
    Max Piper.
    Last edited by Max Piper; 29 Mar 2017, 15:45.

    Comment

    Working...
    X