# NOT RUN {
#
# Simple illustration
#
x = 1:10
y = rep(1:4, 3)[1:10]
# interaction
cbind(x, y, i(x, y, 1))
# without interaction
cbind(x, y, i(y, ref = 1))
# You can interact factors too
z = rep(c("a", "b", "c"), c(5, 3, 2))
data.frame(z, y, i(z, y))
#
# In fixest estimations
#
data(base_did)
# We interact the variable 'period' with the variable 'treat'
est_did = feols(y ~ x1 + i(treat, period, 5) | id + period, base_did)
# => special treatment in coefplot
coefplot(est_did)
# Using i() for factors
est_bis = feols(y ~ x1 + i(period, keep = 3:6) + i(treat, period, 5) | id, base_did)
coefplot(est_bis, only.inter = FALSE)
# => special treatment in etable
etable(est_bis, dict = c("6" = "six"))
# }
Run the code above in your browser using DataLab