I would like to run the following 4 sequential models. I would like to create interactions on the fly. How can I include i.var and tell the local macro to pass them to xtreg?
local mod1 = "OTC i.event_date_my"
local mod2 = "`mod1' state_ab#c.event_date_my" // adds state-specific linear time trends
local mod3 = "`mod2' state_ab#(c.event_date_my#c.event_date_my)" // adds quadratic state-specific time trends, and
local mod4 = "`mod3' cov_food_st_person cov_unemp_rate" // the final column adds covariates.
local models "`mod1'" "`mod2'" "`mod3'" "`mod4'"
#delimit ;
foreach dv of local dvs
{;
foreach mod of local models
{;
eststo: quie xtreg `dv' `mod', fe vce(cluster state_ab);
estadd ysumm , mean ; // return only mean
display `dv';
};
};
#delimit cr
---> Stata is complaining at me by throwing this error message: invalid 'i.event_date_my'
Any suggestions? Thank you.
Related Posts with How do include virtual factor variables (created with i. or c. operators) in local macros to use them in for loops?
practicing Code: xtreg zscore lnasset lnassetsq diverse leverage eeffqr DGS10 CPIAUCSL_PCH GDPC1_PC1, fe Fixe…
xtreg fe versus areg robust errors?Hello! I apologize if some of the questions in this post seem simple, but this has to do with my the…
test runHello! I apologize if some of the questions in this post seem simple, but this has to do with my the…
Read a list of variables in a loop, while ignoring some variables that don't existHello, I'm trying to use a list of variables that have suffixes based on years, using a loop. Howev…
Selecting 3 controls per caseHello everyone. I know a couple of topics have covered this but I can't seem to figure out how to se…
Subscribe to:
Post Comments (Atom)
0 Response to How do include virtual factor variables (created with i. or c. operators) in local macros to use them in for loops?
Post a Comment