cem
cem copied to clipboard
CEM matching with multiply imputed datasets
Hello!
I want to use CEM matching on a multiply imputed dataset. I have followed the example as stated in the manual. When I want to use the att function for estimating the SATT I get the following error: variable 'ecmo' is not a factorError: variable 'ecmo' was fitted with type "factor" but type "numeric" was supplied. “ecmo” is a factor variable with two levels, non-ECMO and ECMO) and is a factor variable throughout all datasets… I have tried adding an additional variable ‘ecmo_num” to all imputed datasets, a numeric variable with 0 for the non-ECMO and 1 for the ECMO group. The att function then works, but gives a p-value of 1.4… something I do not understand. Is this an error you by any chance know?
Kind regards, Lara Pladet
require(cem) imputed <- amp$imputations[1:30] #amp = multiply imputed dataset (m = 30, maxit = 30) from MICE object to Amelia todrop <- c("ecmo", "HADSAngstScore", "HADSDepressieScore", "IESScore", "IESMEanScore", "BarthelScore", "EQ5DScore", "CFQMeanScore", "PTSD", "HulpInvullen", "Sum_SOFA_ExCNS_ICopname", "Opnamejaar", "BMI") mat1 <- cem(treatment= "ecmo", datalist=imputed, drop = todrop, data=data1) #data1 is the original dataset with missings mat1 #21 ECMO are now matched to 25 non-ECMO patients
#estimating SATT out1 <- att(mat1, HADSAngstScore ~ ecmo, data=imputed) # variable 'ecmo' is not a factorError: variable 'ecmo' was fitted with type "factor" but type "numeric" was supplied
#trying with ecmo_num instead of 'ecmo' lapply(1:length(imputed), FUN=function(x){as.numeric(imputed[[x]]$ecmo)}-1)
for(x in 1:length( imputed)){ imputed[[x]]$ecmo_num <- as.numeric( imputed[[x]]$ecmo) - 1 }
test <- cem(treatment= "ecmo_num", datalist=imputed, drop = todrop, data=data1) test1 <- att(test, HADSAngstScore ~ ecmo_num, data=imputed) #p-value 1.4... ??