We are hiring ! See our job offers.
https://github.com/cran/emplik
Raw File
Tip revision: f54d5e65d30ecadda3d5b4dd691f9c6f1b85d467 authored by Mai Zhou on 02 May 2012, 00:00:00 UTC
version 0.9-8-2
Tip revision: f54d5e6
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)
}
back to top