Re: [R] ltm package question

From: Dimitris Rizopoulos <dimitris.rizopoulos_at_med.kuleuven.be>
Date: Mon, 10 Mar 2008 10:23:30 +0100

the Pearson chi^2 is not directly computed in 'ltm', and the reason is that both the Pearson chi^2 and the likelihood-ratio statistics do not follow the claimed chi-squared distribution, especially as the number of items increases. If you still need to compute it, then you can use the following simple function:

chisq.irt <- function (object) {

    if (!class(object) %in% c("ltm", "rasch", "tpm"))

        stop("Use only with 'ltm', 'rasch' or 'tpm' objects.\n")     nam.obj <- deparse(substitute(object))     p <- ncol(object$X)
    X <- expand.grid(rep(list(c(0, 1)), p))     res <- residuals(object, resp.patterns = data.matrix(X))     Tstat <- sum((res[, "Resid"])^2)
    df <- 2^p - attr(logLik(object), "df") - 1     pval <- pchisq(Tstat, df, lower.tail = FALSE)     names(Tstat) <- "X^2"
    names(df) <- "df"
    rval <- list(statistic = Tstat, parameter = df, p.value = pval,

        alternative = "the fitted IRT model is not appropriate for the data set",

        method = "Pearson X^2 for IRT Models",
        data.name = paste("data from model '", nam.obj, "'", sep = 
""))

    class(rval) <- "htest"
    rval
}

# Some examples
library(ltm)
fitRasch <- rasch(LSAT, constraint = cbind(length(LSAT) + 1, 1)) fit1PL <- rasch(LSAT)
fit2PL <- ltm(LSAT ~ z1)

chisq.irt(fitRasch)
chisq.irt(fit1PL)
chisq.irt(fit2PL)

# check also which perform a Bootstrap approximation # to the distribution of the statistic uner the null GoF.rasch(fitRasch)
GoF.rasch(fit1PL)

I hope it helps.

Best,
Dimitris



Dimitris Rizopoulos
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium

Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


> Hello All,
>
> I was wondering how I can get the overall Pearson chi^2 test of
> model fit
> with its df and p value in the LTM package for the 2PL models.
>
> Thanks,
>
> --
> Davood Tofighi
> Department of Psychology
> Arizona State University
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 10 Mar 2008 - 09:51:03 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 10 Mar 2008 - 10:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive