Question about plot in MICE

Dear community,

Momentarily I am completely stuck at multiple imputation. I have used SMCFCS to be able to impute with cox proportional hazards. When I wanted to convert SMCFCS object to a MICE object and check my results with convergence plots and density plots, I only received errors which I could not solve. Does anyone know where this might come from?

I have created the reprex below. If more information is needed, please let me know. Thank you in advance for your help.


data <- lung
data <- data[,c(1:3,5,6)]

data$sex <- as.factor(data$sex)
data$ph.ecog[data$ph.ecog == 3] <- 2
data$ph.ecog <- as.factor(data$ph.ecog)
data$time <- as.numeric(data$time)

# Use mice for some convenient functions creating method list and predictor matrix using the dataset at hand
ini <- mice(data,m=1,maxit=0)

method <- ini$method
method[method=="pmm"] <- "norm" # replace pmm with norm for smcfcs
method[method=="polyreg"] <- "mlogit" # replace polyreg with mlogit for smcfcs

predMatrix <- ini$predictorMatrix
predMatrix[c("time","status","sex"),] <- 0 #are complete, so do not need imputing
predMatrix[,c("time","status")] <- 0 

db.imputed <- smcfcs(
  smtype= "coxph",  
  smformula = "Surv(time, status) ~  sex + ph.ecog",  
  predictorMatrix = predMatrix,    
  m = 2,        #test: 2
  numit = 10,   #test: 10
  rjlimit = 1000,           
  noisy = FALSE,            
  errorProneMatrix = NULL)

db.mice <- miceadds::datlist2mids( db.imputed$impDatasets ) #convert smcfcs datalist to mids object

#Convergence plot with actual values instead of beta on Y-axis (traceplot)
plot(db.mice) #Error
densityplot(db.mice) #Error

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.