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?
Calculate Relative Risk with 95% CI from two-way tableHello, i have to variables (sex (male/female) & hypertens) and would like to calculate the 95% C…
Do File Error - Incomplete Command ExecutionHi All I am using Stata 13 (on a MacBook MacOS Catalina), I have an error in executing commands fro…
Dummy for first duplicateHello, I am trying to figure out how to create a dummy variable for the first duplicates of the yea…
Fixed effects model with control groupDear all, I am examining the impact of merger activities on the costs of firms. The purpose is the …
Survey weights in pooled dataHi, I am using for my analysis pooled survey data from five different countries. I would normally u…
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