I am trying to implement inverse probability treatment weighting with multinomial logistic regression using CIMTx package in R. However, I get an error that reads Error in pred_ps[, i] : subscript out of bounds
when I use the following code, which uses the default settings for two treatments. How do I fix the error?
set.seed(1)
#load data
data <- data_sim(
sample_size = 1000,
n_trt = 2,
x = "rnorm(0,1)", #List of covariates
lp_y = rep("x1",2), #linear effects in the outcome generating model
nlp_y = NULL, #nonlinear effects in the outcome generating model
align = TRUE, #predictors in treatment assignment model and outcome generating model are the same
tau = c(0,0), #outcome event probabilities (equal outcome event probability across three treatment groups)
delta = c(0), #ratio of units (equal sample sizes for each group)
psi = 1 #sparsity of covariate overlap (moderate covariate overlap)
)
#Run IPTW with multinomial logistic regression
iptw_multi_res <- ce_estimate(y = data$y, x = data$covariates , w = data$w,
method = "IPTW-Multinomial", estimand = "ATE")
summary(iptw_multi_res)