简体   繁体   English

使用 MICE 进行多重插补后,如何使用 lm() 在 R 中的子集上运行线性回归

[英]How to run a linear regression using lm() on a subset in R after multiple imputation using MICE

I want to run a linear regression analysis on my multiple imputed data.我想对我的多重插补数据进行线性回归分析。 I imputed my dataset using mice.我使用老鼠估算了我的数据集。 The formula I used to run a linear regression on my whole imputed set is as follows:我用来在整个估算集上运行线性回归的公式如下:

 mod1 <-with(imp, lm(outc ~ age + sex))
 pool_mod1 <- pool(mod1)
 summary(pool_mod1)

This works fine.这工作正常。 Now I want to create a subset of BMI, by saying: I want to apply this regression analysis to the group of people with a BMI below 30 and to the group of people with a BMI above or equal to 30. I tried to do the following:现在我想创建一个 BMI 的子集,说:我想将此回归分析应用于 BMI 低于 30 的人群和 BMI 高于或等于 30 的人群。我试图做下列的:

 mod2 <-with(imp, lm(outc ~ age + sex), subset=(bmi<30))
 pool_mod2 <- pool(mod2)
 summary(pool_mod2)

 mod3 <-with(imp, lm(outc ~ age + sex), subset=(bmi>=30))
 pool_mod3 <- pool(mod3)
 summary(pool_mod3)

I do not get an error, but the problem is: all three analysis give me exactly the same results.我没有收到错误消息,但问题是:所有三种分析都给了我完全相同的结果。 I thought this could be just the real life situation, however, if I use variables other than bmi (like blood pressure < 150), the same thing happens to me.我认为这可能只是现实生活中的情况,但是,如果我使用 bmi 以外的变量(例如血压 < 150),同样的事情也会发生在我身上。

So my question is: how can I do subset analysis in R when the data is imputed using mice?所以我的问题是:当使用鼠标估算数据时,如何在 R 中进行子集分析?

(BMI is imputed as well, I do not know if that is a problem?) (BMI也是推算的,不知道是不是有问题?)

You should place subset within lm() , not outside of it.您应该将subset放在lm() ,而不是之外。

with(imp, lm(outc ~ age + sex, subset=(bmi<30)))

A reproducible example.一个可重复的例子。

with(mtcars, lm(mpg ~ disp + hp)) # Both produce the same
with(mtcars, lm(mpg ~ disp + hp), subset=(cyl < 6))    

Coefficients:
(Intercept)         disp           hp  
   30.73590     -0.03035     -0.02484  


with(mtcars, lm(mpg ~ disp + hp, subset=(cyl < 6))) # Calculates on the subset

Coefficients:
(Intercept)         disp           hp  
   43.04006     -0.11954     -0.04609 

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

相关问题 使用 MICE 进行多重插补后的个人 AUC - Individual AUC after multiple imputation using MICE 使用小鼠 package 进行多重插补 - Multiple imputation using mice package 在带有分类变量的 r output 中使用 lm() 的多元线性回归不完整? - Multiple Linear Regression using lm() in r output with categorical variable is incomplete? 使用鼠标 R 包进行多次插补后聚类稳健标准错误 - Cluster robust standard errors after multiple imputation using mice R package 使用R中的鼠标包进行多次插补的残差平方和 - Residuals sum of squared for multiple imputation using mice package in R 使用R中的小鼠包进行多次插补的残留图 - Residual plots for multiple imputation using mice package in R 使用 MICE(使用 R)进行多重插补后逻辑和顺序 model 的 AUC - AUC of logistic and ordinal model following multiple imputation using MICE (with R) 当使用seed = NA时,如何找出MICE R-package选择哪个种子进行多重插补? - How to find out which seed the MICE R-package chose for multiple imputation when using seed=NA? 如何在使用 MICE 进行多重插补后进行描述性统计(中位数、IQR、频率、比例等) - How to proceed with descriptive statistics (median, IQR, frequencies, proportions etc) after multiple imputation using MICE 在 mlr 中使用 MICE 进行插补 - Imputation using MICE in mlr
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM