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?
Download collin command for stata and suitable value for vif ?I use command findit collin, and scroll to the last, then click collin from https://stats.idre.ucl…
Testing for Serial Correlation and Individual EffectsHi, Sorry if I am sending a duplicate question, but I found no equivalent question in the list. I a…
Time series ARIMA, how to forecast future?Hi everyone, I am new to STATA time series, and here is a question I have on how to perform forecas…
mlogit + margins + testUsing Stata 15.1, I was wondering how I test for equality of the coefficients for the marginal effec…
Producing three way graphHello Statalist I would like to produce a three way graph on stata like the one provided in the att…
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