R/logLik.tpm.R

logLik.tpm <-
function (object, ...) {
    if (!inherits(object, "tpm"))
        stop("Use only with 'tpm' objects.\n")
    out <- object$log.Lik
    attr(out, "df") <- if (!is.null(constr <- object$constraint)) {
        if (object$type == "rasch") 2 * nrow(object$coef) + 1 - nrow(constr) else 3 * nrow(object$coef) - nrow(constr)
    } else {
        if (object$type == "rasch") 2 * nrow(object$coef) + 1 else 3 * nrow(object$coef)
    }
    attr(out, "nobs") <- nrow(object$X)
    class(out) <- "logLik"
    out
}

Try the ltm package in your browser

Any scripts or data that you put into this service are public.

ltm documentation built on March 18, 2022, 6:36 p.m.