I was trying to estimate a causal effect using inverse probability weighting from the causalweightspackage. However, I keep running into the following error message:
Error in model.frame.default(formula = d ~ x, drop.unused.levels = TRUE) : variable lengths differ (found for 'x')
I want to estimate the causal effect taking into consideration a matrix including multiple control variables. When using a single control from the data-set, R manages to generate an estimate, but when I try to use the matrix including all my control variables, I receive the above-mentioned error message.
My code is as follows and appears to generate estimates when using a single control instead of my predefined matrix of multiple controls as observable in the following code:
attach(data_clean2)
controls <- cbind(marits_1, nationality1, mother_tongue1, educ1,
lastj_fct1, child_subsidies, contr_2y,
unempl_r, gdp_gr, insured_earn)
ipw_atet <- treatweight(y = duration_ue2, # take initial data
d = treatment,
x = controls,
ATET = TRUE, # if = FALSE, estimates ATE (default)
trim = (1-pscore_max0),
boot = 2)
Has anyone encountered similar problems and found a solution?
Thanks in advance