简体   繁体   English

R Mice:使用 with() 函数分析插补数据集

[英]R Mice: analyzing imputed dataset with with() function

I am trying to run an analysis using a dataset imputed through the mice package.我正在尝试使用通过 mouse 包估算的数据集运行分析。 However, when using the with() function to run a linear regression on the imputed data, I get an error stating that the variables I am trying to analyze do not exit.但是,当使用 with() 函数对插补数据运行线性回归时,我收到一条错误消息,指出我尝试分析的变量没有退出。 Here is an example:下面是一个例子:

imputed_dataset <- mice(original_data, formulas = list_of_formulas, m = 5, maxit = 10)
model <- with(imputed_dataset, lm(my_outcome ~ some_imputed_predictor + other_predictor_that_was_not_imputed))

I can get the with() function to return a model if I only include predictors that have been imputed by Mice.如果我只包含由 Mice 估算的预测变量,我可以使用 with() 函数返回一个模型。 I am not able to get the function to work if a variable that was not imputed is included in the formula.如果公式中包含未估算的变量,我将无法使该函数工作。 What should I do to be able to run my regression model, with some imputed predictors and some non-imputed predictors?我应该怎么做才能运行我的回归模型,其中包含一些估算的预测变量和一些非估算的预测变量?

The answer to this problem can be found in this thread.这个问题的答案可以在这个线程中找到。 The formula needs to be wrapped like this公式需要这样包装

model <- with(imputed_dataset, formula(format(lm(my_outcome ~ my_regressors))))

Running mice with a formula as a variable: instant evaluation instead of later evaluation? 用公式作为变量运行鼠标:即时评估而不是后期评估?

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

相关问题 在 R 的 MICE 中对每个插补数据集执行操作 - Perform operation on each imputed dataset in R's MICE 如何使用鼠标或 R 中的另一个包从多个变量中提取多个估算值到单个数据集中? - How extract several imputed values from several variables using mice or another package in R into a single dataset? 使用小鼠在 r 中按组组合估算数据 - Combine imputed data by group in r using mice R 中 MICE 多重估算变量的直方图 - Histogram of MICE multiple imputed variable in R 是否可以重新调整多重插补数据集中的变量(使用鼠标创建)? - Is it possible to relevel a variable within a multiply imputed dataset (created using mice)? 在来自小鼠(R)的部分估算数据上运行glm.mids - Run glm.mids on a subset of imputed data from mice (R) 如何从R-package&#39;老鼠&#39;中提取汇总的估算数据? - How to extract aggregated imputed data from R-package 'mice'? R - 老鼠 - 添加一列,对具有插补值的列进行求和 - R - mice - adding a column that sums columns with imputed values 将估算数据集从 SAS 转移到 R? - Transfer imputed dataset from SAS to R? 将Zelig“ sim”函数与Amelia数据集结合使用,以获取跨R中的估算数据集汇总的估计值 - Using Zelig “sim” function with Amelia dataset to obtain estimates pooled across imputed datasets in R
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM