Hi all,
I’m running into a confusing issue with the cmest() function from the CMAverse package in R. I’m trying to run a mediation model with "model = "rb" and "estimation = "paramfunc" / "inference = "delta".
Here’s my code:
# Subset to complete cases
base_med <- subset(base_sub, complete_case == 1)
# Check for missing values
vars <- c("Factor1", "AGPI_n_3", "c_qiv", "centre", "nn_Sexe", "primipare", "fum",
"alcool_1", "metudes", "agediv", "dural_n", "age_acc", "c24_Revenus",
"a5_hometot", "m_sumcesd", "pandietg_Pdt_nrj", "bmi")
colSums(is.na(base_med[, vars]))
# All zeros
# Run cmest
model_med1 <- cmest(
data = base_med,
model = "rb",
outcome = "c_qiv",
exposure = "Factor1",
mediator = "AGPI_n_3",
basec = c("centre", "nn_Sexe", "primipare", "fum", "alcool_1", "metudes",
"agediv", "dural_n", "age_acc", "c24_Revenus", "a5_hometot",
"m_sumcesd", "pandietg_Pdt_nrj", "bmi"),
EMint = TRUE,
mreg = list("linear"),
yreg = "linear",
mval = list(3.6),
estimation = "paramfunc",
inference = "delta"
)
I get the following error:
Error in cmest(...): NAs in the data; delete rows with NAs from the data or set multimp = TRUE
The confusing part is that I checked all variables included in the model, and there are no missing values (colSums(is.na(base_med[, vars])) returns 0 for all). I also ensured that categorical covariates are factors.
Has anyone seen this error before with cmest()? Could it be related to internal checks in CMAverse? Any advice on how to resolve this would be much appreciated.
NB : my outcome, mediator and exposure are all continuous
Thanks in advance!