2

I am analyzing data from European Social Survey. Due to quite a bit of missing data I have used the amelia package for imputation. 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:

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:

Model: Combined Imputations Error in se[i, ] <- sqrt(diag(vcovlist[[i]])) : number of items to replace is not a multiple of replacement length

I have five separate imputed datasets. Analyzed separately I am able to use Zelig and the "ologit"-function with each of these five. The problem only arises when I use my combined amelia data-object. 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. 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.

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? 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:

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)
Nora H.
  • 63
  • 6

1 Answers1

1

Looks like that the zilig function (with model = "ologit") is not working well with the amelia object.
So to do that you could call the zilig function individually to each one of the 5 imputed dataset with the amelia package. 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
claudius
  • 747
  • 1
  • 10
  • 24
  • Thank you so much for your answer! I was really hoping that it was some way to use the Amelia object, but I guess, as you say, it's just not working out, and the best solution probably is to analyze the datasets individually. Very interesting to hear that it's not just for me this isn't working. Thanks a lot again for taking a look at this and your thorough answer – Nora H. Sep 23 '19 at 17:59