R/aggregation.misclass.R

aggregation.misclass <- function (full.data = NULL, response, x, model, cplx = NULL,
    type = c("apparent", "noinf"), fullsample.attr = NULL, ...)
{
    data <- as.data.frame(x)
    data$response <- response
    if (class(model)[1] == "penfit") {
        probs <- predict(model, data = data, penalized = x, ...)
    }  else {
        if(class(model)[1] == "glm") {
            probs <- predict(model, newdata = data, penalized = x, , type = "response", ...)
        } else {
        probs <- predict(model, data = data, type = "response",
            ...)
            }
    }
    type <- match.arg(type)
    if (type == "apparent") {
        mr <- sum(abs(round(probs) - response))/length(response)
    }
    if (type == "noinf") {
        mr <- mean(abs((matrix(response, length(response), length(response),
            byrow = TRUE) - round(probs))))
    }
    mr
}

Try the peperr package in your browser

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

peperr documentation built on March 31, 2023, 7:34 p.m.