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?
Creation of panel of 16 months by linking monthly samples from CPSMy main purpose is to see how a person changes job and how it affects the wage in few selective stat…
Merging datasets with same variable but different values for the variableHi. I wanted to understand the finer working of the -merge- command and it isn't clear to me from re…
LATE Difference-in-DifferencesHi all, I'm trying to estimate a generalized DID (two periods three groups)'s local average treatme…
reshape wide to longDear All, How can I reshpae the following wide data into long data format? Thanks. Code: * Example …
Print excel after calculating Shannon entropyDear Statalists, I have a problem since I am calculating the Shannon entropy for a very huge number …
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