【问题标题】:Multiple imputation: from SMCFCS to MICE for (convergence) plots多重插补:从 SMCFCS 到 MICE 的(收敛)图
【发布时间】: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

【问题讨论】:

    标签: r plot


    【解决方案1】:

    最简单的方法是直接用micemiceadds 重新运行它,参见https://www.rdocumentation.org/packages/miceadds/versions/3.11-6/topics/mice.impute.smcfcs

    imp <- mice::mice(dat, maxit=0)
    method <- imp$method
    method["x"] <- "smcfcs"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-28
      • 1970-01-01
      相关资源
      最近更新 更多