【发布时间】:2021-12-31 19:19:34
【问题描述】:
我已经使用 SMCFCS 来估算 cox 比例风险。当我想将 SMCFCS 对象转换为 MICE 对象并使用收敛图和密度图检查我的结果时,我只收到了我无法解决的错误。我尝试了多种方法,例如miceadds::datlist2mids,但是它不起作用。有谁知道如何解决这个问题?
我在下面创建了代表。
#Libraries
library(smcfcs)
library(rms)
library(mice)
library(miceadds)
library(survival)
#Test
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)
#Methods
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
#Predictormatrix
predMatrix <- ini$predictorMatrix
predMatrix[c("time","status","sex"),] <- 0 #are complete, so do not need imputing
predMatrix[,c("time","status")] <- 0
#Imputation
db.imputed <- smcfcs(
data,
smtype= "coxph",
smformula = "Surv(time, status) ~ sex + ph.ecog",
method=method,
predictorMatrix = predMatrix,
m = 2, #test: 2
numit = 10, #test: 10
rjlimit = 1000,
noisy = FALSE,
errorProneMatrix = NULL)
#Checks
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
【问题讨论】: