swh:1:snp:9492dda1ea1583c5fa5285d6ddcd2ab9f57129b4
Tip revision: 256eb1eaaa97805c6f0501eebd9a6f8791279ef7 authored by Patrick Mair on 15 March 2024, 08:36:29 UTC
version 1.0-6
version 1.0-6
Tip revision: 256eb1e
predict.ppar.R
predict.ppar <- function(object, cutpoint = "randomized", ...)
{
# predict method for objects of class ppar
# cutpoint ... either value between 0 and 1, or randomized assignment
Pi <- pmat(object) #expected values
X <- object$X.ex
if (max(X, na.rm = TRUE) > 1) stop("Available for dichotomous models only!")
K <- dim(X)[2]
N <- dim(X)[1]
y <- as.vector(t(X)) #observed values
pi.hat <- as.vector(t(Pi))
if (cutpoint == "randomized") {
pvec <- runif(length(y))
} else {
pvec <- rep(cutpoint, length(y))
}
classvec <- (pvec < pi.hat)*1 #expected 0/1 vector
classmat <- matrix(classvec, ncol = K, nrow = N, byrow = TRUE)
dimnames(classmat) <- list(rownames(X), colnames(X))
return(classmat)
}