[英]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.