drizopoulos / ltm

Latent Trait Models under IRT
30 stars 12 forks source link

Factor scores computation with Multiple Imputation fails #2

Closed tpaskhalis closed 7 years ago

tpaskhalis commented 7 years ago

I've been trying to compare the results of different computation methods for factor scoring of 2-parameter IRT model and Multiple Imputation failed. When I used the example from the documentation it also resulted in the following error:

> fit <- ltm(Abortion ~ z1)
> factor.scores(fit, method = "MI", B = 20) # Multiple Imputation
Error in FUN(X[[i]], ...) : 'dimnames' must be a list

The issue seems to be with the lines 58-59 in fscores.l.R

Instead of:

        scores.B <- lapply(1:B, array, data = 0, dim = c(nx, factors))
        hes.B <- lapply(1:B, array, data = 0, dim = c(factors, factors, nx))

I think it should be something like:

scores.B <- lapply(1:B, function(x) x <- array(data = 0, dim = c(nx, factors)))
hes.B <- lapply(1:B, function(x) x <- array(data = 0, dim = c(factors, factors, nx)))

The same issue applies to line 72

drizopoulos commented 7 years ago

Thanks for reporting this. I've committed a new version that resolves this.