IQSS / Zelig

A statistical framework that serves as a common interface to a large range of models
http://zeligproject.org
110 stars 43 forks source link

ologit with Amelia-data #334

Open nrawh opened 5 years ago

nrawh commented 5 years ago

I am working with a dataset where I have imputed missing values with the Amelia-package. 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 message 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 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 asked Amelia to return five imputed dataset. Analyzed separately I am able to use Zelig and the "ologit"-function with each of these five. The problem only arises with the amelia data-object.

I am therefore wondering whether anyone has been able to run "ologit" with zelig on amelia data previously or if anyone has any idea why this is not working for me?

In advance, thank you all very much for any ideas.

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)
sdcharle commented 3 years ago

Bummer. I'm still having this problem in 2021!