Hi, I am trying to run some basic tests across fixed effects models and save the p-value (Prob>F).
Here's some basic syntax below that mirrors my (much more involved and more complicated) modeling, where I progressively test different coefficients across race and south, and do this for multiple outcomes within a foreach loop.
Ultimately, I would like to store each resulting p-value into a data frame that identifies the variable, outcome, and category (race and south) it came from. If anyone has recommendations to do that within a loop framework like the below, I would appreciate them!
Here's some basic syntax below that mirrors my (much more involved and more complicated) modeling, where I progressively test different coefficients across race and south, and do this for multiple outcomes within a foreach loop.
Ultimately, I would like to store each resulting p-value into a data frame that identifies the variable, outcome, and category (race and south) it came from. If anyone has recommendations to do that within a loop framework like the below, I would appreciate them!
Code:
use "https://www.stata-press.com/data/r17/nlswork.dta", clear foreach var of varlist hours ln_wage { /***/ Race xtreg `var' tenure ttl_exp i.year if race == 1, fe vce(cluster idcode) local coef_tenurewhite_`var' =_b[tenure] local coef_expwhite_`var' =_b[ttl_exp] xtreg `var' tenure ttl_exp i.year if race == 2, fe vce(cluster idcode) test `coef_tenurewhite_`var'' =_b[tenure] test `coef_expwhite_`var'' =_b[ttl_exp] /***/ South xtreg `var' tenure ttl_exp i.year if south == 1, fe vce(cluster idcode) local coef_tenuresouth_`var' =_b[tenure] local coef_expsouth_`var' =_b[ttl_exp] xtreg `var' tenure ttl_exp i.year if south == 0, fe vce(cluster idcode) test `coef_tenuresouth_`var'' =_b[tenure] test `coef_expsouth_`var'' =_b[ttl_exp] }
Comment