porder <- function(x, N=1, r=1, basename="norm", ..., log.p=FALSE) {
pfun <- get(paste("p", basename, sep=""))
stopifnot(r <= N)
prob <- pfun(x, ...)
retval <- pbeta(prob, r, N-r+1, log.p=log.p)
retval
}
dorder <- function(x, N=1, r=1, basename="norm", ..., log=FALSE) {
pfun <- get(paste("p", basename, sep=""))
dfun <- get(paste("d", basename, sep=""))
stopifnot(r <= N)
logdens <- -lbeta(r, N-r+1)+(r-1)*pfun(x, ..., log.p=TRUE) +(N-r)*pfun(x, ..., lower.tail=FALSE, log.p=TRUE) + dfun(x, ..., log=TRUE)
retval <- if (log) logdens else exp(logdens)
retval
}
qorder <- function(p, N=1, r=1, basename="norm", ..., log.p=FALSE) {
pfun <- get(paste("p", basename, sep=""))
qfun <- get(paste("q", basename, sep=""))
stopifnot( r <= N)
retval <- qfun(qbeta( p, r, N-r+1, log.p=log.p), ..., log.p=FALSE)
retval
}
rorder <- function(n, N=1, r=1, basename="norm", ...) {
qfun <- get(paste("q", basename, sep=""))
qfun( rbeta(n, r, N-r+1), ... )
}
porder <- function(x, N=1, r=1, basename="norm", ..., log.p=FALSE) {
pfun <- get(paste("p", basename, sep=""))
stopifnot(r <= N)
prob <- pfun(x, ...)
retval <- pbeta(prob, r, N-r+1, log.p=log.p)
retval
}
dorder <- function(x, N=1, r=1, basename="norm", ..., log=FALSE) {
pfun <- get(paste("p", basename, sep=""))
dfun <- get(paste("d", basename, sep=""))
stopifnot(r <= N)
logdens <- -lbeta(r, N-r+1) + (r-1)*pfun(x, ..., log.p=TRUE) +
(N-r)*pfun(x, ..., lower.tail=FALSE, log.p=TRUE) +
dfun(x, ..., log=TRUE)
retval <- if (log) logdens else exp(logdens)
retval
}
qorder <- function(p, N=1, r=1, basename="norm", ..., log.p=FALSE) {
pfun <- get(paste("p", basename, sep=""))
qfun <- get(paste("q", basename, sep=""))
stopifnot( r <= N)
retval <- qfun(qbeta( p, r, N-r+1, log.p=log.p), ...,
log.p=FALSE)
retval
}
rorder <- function(n, N=1, r=1, basename="norm", ...) {
qfun <- get(paste("q", basename, sep=""))
qfun( rbeta(n, r, N-r+1), ... )
}