IQSS / ZeligMultilevel

Five Multi-level Zelig Models
8 stars 3 forks source link

Investigate bug with multiply imputed data and ```ls.mixed``` #1

Open whatever opened 12 years ago

whatever commented 12 years ago

ls.mixed gets an error while computing the design matrix within its qi method. This seems to only occur for multiply imputed models.

Program output and a traceback can be found here:

>>>> model.full <- zelig(attitude ~ age + married + male + income + tag(1 |
>>>> state), model = "ls.mixed", data = imp$imputations,  REML = FALSE,
>>>> subset = wave4)
>>>>
>>>> x.out <- setx(model.full)
>>>>
>>>> simout <- sim(x.out, x = x.out)
>>>>

The model estimates fine with the zelig() function, setx() works fine in setting the explanatory variables at their means, but when I attempt to use sim(), I get:

>>>>
>>>> Error in eval(expr, envir, enclos) : object 'age' not found
>>>>
>>>> A traceback produces this:
>>>>
>>>> 13: eval(expr, envir, enclos)
>>>> 12: eval(predvars, data, env)
>>>> 11: model.frame.default(object, data, xlev = xlev)
>>>> 10: model.frame(object, data, xlev = xlev)
>>>> 9: model.matrix.default(parsefml$fixed, data = D)
>>>> 8: model.matrix(parsefml$fixed, data = D)
>>>> 7: model.matrix(parsefml$fixed, data = D)
>>>> 6: is.data.frame(x)
>>>> 5: colnames(model.matrix(parsefml$fixed, data = D))
>>>> 4: qi.mer(object[[1]], simpar = simpar, x = as.matrix(x), x1 = if
>>>> (!is.null(x1)) as.matrix(x1))
>>>> 3: qi(object[[1]], simpar = simpar, x = as.matrix(x), x1 = if
>>>> (!is.null(x1)) as.matrix(x1))
>>>> 2: sim.setx.MI(model.full, x = x.out)
>>>> 1: sim(model.full, x = x.out)
cchoirat commented 8 years ago

Add an example in Zelig 5.