简体   繁体   English

R 中的 MICE 包:被动插补

[英]MICE package in R: passive imputation

I aimed to handle missing values with multiple imputation and then analyse with mixed linear model.我的目标是用多重插补处理缺失值,然后用混合线性模型进行分析。

I am stacked by passive imputation for "BMI" (body mass index) and "BMI category".我被“BMI”(体重指数)和“BMI 类别”的被动插补堆积起来。 "BMI" was calculated by height and weight and then categorized into "BMI category". “BMI”按身高和体重计算,然后归类为“BMI类别”。

How to impute 'BMI category'?如何估算“BMI 类别”?

The database looks like below:数据库如下所示:

 sub_eu_surf[1:5, 3:12]

    age gender smoking exercise education sbp dbp height weight      bmi
    1  41      1       1        2        18 120  80    185    107 31.26370
    2  46      1       3        2        18 130  70    182    102 30.79338
    3  46      1       3        2        18 130  70    182    102 30.79338
    4  47      1       1        2        14 130  80    178     78 24.61810
    5  47      1       1        1        14 150  80    175     85 27.75510

Since 'bmi category' is not a predictor of my imputation, I decided to create it after imputation.由于“bmi 类别”不是我的插补的预测指标,因此我决定在插补后创建它。 And details are below:详情如下:
1. To define method and predictor 1. 定义方法和预测器

ini<-mice(sub_eu_surf, maxit=0)
meth<-ini$meth
meth["bmi"]<-"~I(weight/(height/100)^2)"

pred <- ini$predictorMatrix
pred[c("pm25_global", "pm25_eu", "pm10_eu", "no2_eu"),  ]<-0 
pred[,c("bmi", "hba1c", "pm25_eu", "pm10_eu")]<-0
pred[,"tc"]<-0
pred[c("smoking", "exercise", "hdl", "glucose"), "tc"]<-1
pred[c("smoking", "exercise", "hdl", "glucose"), "ldl"]<-0
vis <- ini$vis
imp_eu<-mice(sub_eu_surf, meth=meth, pred=pred, vis=vis, seed=200, print=F, m=5, maxit=5)
long_eu<- complete(imp_eu, "long", include=TRUE)
long_eu$bmi_category<-cut(as.numeric(long_eu$bmi), breaks=c(0, 18.5, 25, 30, 72))
complete_eu<-as.mids(long_eu)

But I received an error when analyzing my data:但是我在分析我的数据时收到一个错误:

    test1<-with(imp_eu, lme(sbp~pm25_global+gender+age+education+bmi_category, random=~1|centre))
    Error in eval(expr, envir, enclos) : object 'bmi_category' not found

How does this happen?这是怎么发生的?

You are running your analyses on the original mids object imp_eu , not on the modified complete_eu .您正在对原始mids对象imp_eu进行分析,而不是对修改后的complete_eu Try:尝试:

test1<-with(complete_eu, lme(sbp~pm25_global+gender+age+education+bmi_category, random=~1|centre))

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM