简体   繁体   English

使用 MICE 进行多重插补后的个人 AUC

[英]Individual AUC after multiple imputation using MICE

I have a question about calculating an AUC for every individual in a dataset, after imputation using MICE.我有一个关于在使用 MICE 进行插补后为数据集中的每个人计算 AUC 的问题。

I know how I can do it in a complete cases dataset.我知道如何在完整的案例数据集中做到这一点。 I have done it as follows:我做了如下:

id <- c(1,2,3,4,5,6,7,8,9,10)
measure_1 <- c(60,80,90,55,60,61,77,67,88,90)
measure_2 <- c(55,88,88,55,70,61,80,66,65,92)
measure_3 <- c(62,88,85,56,68,62,89,62,70,99)
measure_4 <- c(62,90,83,54,65,62,91,59,67,96)
dat <- data.frame(id, measure_1, measure_2, measure_3, measure_4)
dat
x <- c(0,7,14,21) # number of days

library(Bolstad2)
f <- function(a){
   Patient <- dat[a,]
   vector_patient <- c(Patient[2:5])
   AUCpatient <- sintegral(x,vector_patient)$int
   return(AUCpatient)
}

vector <- c(1:10)
listAUC <- lapply(vector, f)
vector_AUC <- unlist(listAUC, use.names=FALSE)
vector_AUC

This gave me a vector with all the AUCs for all patients.这给了我一个包含所有患者所有 AUC 的向量。 This vector can be added to my dataset if I want to.如果我愿意,可以将此向量添加到我的数据集中。

But now I have a problem: I have missings in my dataset.但现在我有一个问题:我的数据集中有缺失。 My dataset can be obtained using the following code:我的数据集可以使用以下代码获得:

id <- c(1,2,3,4,5,6,7,8,9,10)
measure1 <- c(60,NA,90,55,60,61,77,67,88,90)
measure2 <- c(55,NA,NA,55,70,NA,80,66,65,92)
measure3 <- c(62,88,85,NA,68,62,89,62,70,99)
measure4 <- c(62,90,83,54,NA,62,NA,59,67,96)
datmis <- data.frame(id, measure1, measure2, measure3, measure4)
datmis

I want to impute this dataset using MICE.我想使用 MICE 来估算这个数据集。

library(mice)
imp <- mice(datmis, maxit = 0)
meth <- imp$method
pred <- imp$predictorMatrix
imp <- mice(datmis, method = meth, predictorMatrix = pred, seed = 2018, maxit = 10, m = 5)

So now I have everything imputed.所以现在我已经估算了一切。 I want to create the AUCs for every individual, in every imputed dataset.我想在每个估算数据集中为每个人创建 AUC。 Then I want to pool the results, resulting in one single AUC for every individual.然后我想合并结果,为每个人生成一个 AUC。 However, using the formula create in the previous example does not work anymore.但是,使用前面示例中的公式 create 不再起作用。 Is there someone who can help me out?有人可以帮助我吗?

Here's one way to do it.这是一种方法。 After you run your imputation you can在你运行你的插补之后,你可以

  1. Run through each imputed dataset运行每个插补数据集
  2. Compute the AUC with the impuated data用插补数据计算 AUC
  3. Pool estimates together using Rubin's rule使用鲁宾规则将估计值汇集在一起

The first 2 points are covered with the code below前 2 点被下面的代码覆盖

x <- c(0,7,14,21) # number of days
library("tidyverse")
library("MESS")
res <- lapply(1:5, function(i) { 
    complete(imp, i) %>% 
    group_by(id) %>% 
    mutate(AUC=MESS::auc(x, c(measure1, measure2, measure3, measure4)))})

I'm using the auc function from the MESS since that is rather fast and flexible but you could replace it with your version.我正在使用MESSauc函数,因为它相当快速和灵活,但您可以将其替换为您的版本。

This produces a list of 5 data frames that can be used for pooling the estimates (part 3 from the list above).这会生成一个包含 5 个数据框的列表,可用于合并估计值(上面列表中的第 3 部分)。

library("mitools")
with(imputationList(res), lm(AUC ~ 1)) %>% pool() %>% summary()

This produces这产生

            estimate std.error statistic       df      p.value
(Intercept)  1512.77  81.62359  18.53349 7.389246 1.829668e-07

One more comment regarding the imputation: Are you sure you want to predict the measures using id as a numeric variable.关于插补的另一条评论:您确定要使用id作为数字变量来预测度量吗? That produces a regression-like predictor for the missing variables which seems rather unrealistic.这为缺失的变量产生了一个类似回归的预测器,这似乎很不切实际。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用小鼠 package 进行多重插补 - Multiple imputation using mice package 在 mlr 中使用 MICE 进行插补 - Imputation using MICE in mlr 使用 MICE 进行多重插补后,如何使用 lm() 在 R 中的子集上运行线性回归 - How to run a linear regression using lm() on a subset in R after multiple imputation using MICE 使用鼠标 R 包进行多次插补后聚类稳健标准错误 - Cluster robust standard errors after multiple imputation using mice R package 如何在使用 MICE 进行多重插补后进行描述性统计(中位数、IQR、频率、比例等) - How to proceed with descriptive statistics (median, IQR, frequencies, proportions etc) after multiple imputation using MICE 如何使用MICE包进行多次插补后的预测 - How to do the prediction after multiple imputation with MICE package 如何在小鼠多重插补后创建相关矩阵 - How to create correlation matrix after mice multiple imputation 使用 MICE 包进行多次插补后合并 Cox PH 结果 - Pooling Cox PH results after multiple imputation with the MICE package 如何在多次插补后将所有数据集组合成一个数据框(小鼠) - How to combine all datasets into a data frame after multiple imputation (mice) 使用R中的鼠标包进行多次插补的残差平方和 - Residuals sum of squared for multiple imputation using mice package in R
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM