swh:1:snp:7d062e61dfe39b25a891852629fe3416f36554de
Tip revision: f4080b27a2890dc27b345b3c4eba5544ed897f2b authored by Mai Zhou on 25 March 2005, 00:00:00 UTC
version 0.8-4
version 0.8-4
Tip revision: f4080b2
redistF.R
redistF <- function(y, d, Fdist) {
n <- length(d)
if ( length(y) != n ) stop("length of y and d must agree")
if ( any((d != 0) & (d !=1)) ) stop("d must be either 0 or 1")
if ( length(Fdist) != n ) stop("Fdist must have length n")
# Fdist must be a probability distribution
# the time vector is the ysort, and the prob mass is in Fdist
yorder <- order(y, -d)
ysort <- y[yorder]
dsort <- d[yorder]
WeightMat <- diag( rep(1, n) )
for (i in 1:(n-1))
if ( dsort[i] == 0 ) {
WeightMat[i, (i+1):n] <- Fdist[(i+1):n]/sum(Fdist[(i+1):n])
WeightMat[i,i] <- 0
}
list(y=ysort, d=dsort, weight=WeightMat, ordY=yorder)
}