简体   繁体   English

R:具有多重插补数据的有序逻辑回归(amelia 包)

[英]R: Ordered logistic regression with multiple imputation data (amelia package)

I am analyzing data from European Social Survey.我正在分析来自欧洲社会调查的数据。 Due to quite a bit of missing data I have used the amelia package for imputation.由于缺少大量数据,我使用了 amelia 包进行插补。 The dependent value is ordinal with 4 values, and I had therefore planned to perform a ordered logistic regression with the "ologit" function in the Zelig-package:依赖值是 4 个值的序数,因此我计划使用 Zelig 包中的“ologit”函数执行有序逻辑回归:

z.out <- zelig(as.factor(Y) ~ X1 + X2, model = "ologit", data = ameliadata)

That code will run, but when I ask for the results the following error code is shown:该代码将运行,但是当我询问结果时,会显示以下错误代码:

z.out: z.out:

Model: Combined Imputations Error in se[i, ] <- sqrt(diag(vcovlist[[i]])) : number of items to replace is not a multiple of replacement length模型:se[i, ] <- sqrt(diag(vcovlist[[i]])) 中的组合插补错误:要替换的项目数不是替换长度的倍数

I have five separate imputed datasets.我有五个单独的估算数据集。 Analyzed separately I am able to use Zelig and the "ologit"-function with each of these five.单独分析,我可以将 Zelig 和“ologit”函数用于这五个函数中的每一个。 The problem only arises when I use my combined amelia data-object.只有当我使用组合的 amelia 数据对象时才会出现问题。 I have tried to estimate different models with the same amelia-output, and I only seem to have a problem with the ones related to ordered regression.我试图用相同的 amelia 输出来估计不同的模型,但我似乎只对与有序回归相关的模型有问题。 For example, the "ls"-model runs just fine, and if I change the depended variable to a dichotomous I can also run a "logit"-model without problems.例如,“ls”模型运行得很好,如果我将因变量更改为二分变量,我也可以毫无问题地运行“logit”模型。

I am therefore wondering whether anyone has been able to run "ologit" with zelig on amelia data previously or if anyone has any idea about what could be the problem?因此,我想知道之前是否有人能够在 amelia 数据上使用 zelig 运行“ologit”,或者是否有人知道可能是什么问题? I will greatly appreciate any ideas and suggestions.我将不胜感激任何想法和建议。 Thank you so much for your time and help.非常感谢您的时间和帮助。

This is an example with the wine dataset from the ordinal package:这是来自 ordinal 包的 wine 数据集的示例:

library(Amelia)
library(Zelig)
library(ordinal)

data(wine)
w <- wine

set.seed(10)
w[sample(1:nrow(w), 20), "response"] <- NA
w[sample(1:nrow(w), 20), "rating"] <- NA
w[sample(1:nrow(w), 20), "temp"] <- NA
w[sample(1:nrow(w), 5), "contact"] <- NA
w[sample(1:nrow(w), 5), "bottle"] <- NA


w.amelia <- amelia(w, m = 5, idvars="bottle", ords = c("rating","judge"),
                     noms = c("contact", "temp"),
                     incheck = TRUE)

z.out <- zelig(rating ~ contact + temp, model = "ologit", data = w.amelia)

summary(z.out)

Looks like that the zilig function (with model = "ologit") is not working well with the amelia object.看起来zilig函数(带有模型 =“ologit”)与 amelia 对象不能很好地配合使用。
So to do that you could call the zilig function individually to each one of the 5 imputed dataset with the amelia package.为此,您可以使用amelia包对 5 个估算数据集中的每一个单独调用zilig函数。 Below we can see the fitted models for two imputed dataset.下面我们可以看到两个插补数据集的拟合模型。

z.out1 <- zelig(rating ~ contact + temp, model = "ologit", data = w.amelia$imputations$imp1)
z.out2 <- zelig(rating ~ contact + temp, model = "ologit", data = w.amelia$imputations$imp2)

Receiving an output to each imputed data:接收每个插补数据的输出:

> summary(z.out1)
Model: 
Call:
z5$zelig(formula = rating ~ contact + temp, data = w.amelia$imputations$imp1)

Coefficients:
           Value Std. Error t value
contactyes 1.973     0.4937   3.997
tempwarm   1.493     0.4617   3.235

Intercepts:
    Value   Std. Error t value
1|2 -1.2246  0.4425    -2.7675
2|3  1.0072  0.3884     2.5931
3|4  2.8052  0.5101     5.4987
4|5  4.0133  0.6135     6.5411

Residual Deviance: 189.7068 
AIC: 201.7068 
Next step: Use 'setx' method
> summary(z.out2)
Model: 
Call:
z5$zelig(formula = rating ~ contact + temp, data = w.amelia$imputations$imp2)

Coefficients:
           Value Std. Error t value
contactyes  1.73     0.4760   3.635
tempwarm    1.69     0.4774   3.539

Intercepts:
    Value   Std. Error t value
1|2 -0.6469  0.4850    -1.3338
2|3  1.3290  0.4659     2.8525
3|4  2.8718  0.5571     5.1547
4|5  4.2483  0.6751     6.2932

Residual Deviance: 198.7817 
AIC: 210.7817 
Next step: Use 'setx' method

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

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