Displaying 1 result from an estimated 1 matches for "xperm".
Did you mean:
eperm
2008 Jan 11
1
Adding weights to ecdf
...)
# x = vector with observations.
# weig = weigths, one per observation.
{
n <- length(x)
if (n < 1)
stop("'x' have 1 or more non-missing values")
if (n != length(weig))
stop("'weig' must have same length than 'x'")
xPerm <- order(x)
weig <- weig/sum(weig)
x <- x[xPerm]
weig <- weig[xPerm]
ndIdx <- !duplicated(x)
vals <- x[ndIdx]
weig <- sapply(x[ndIdx],function(xx) sum(weig[x==xx]))
rval <- approxfun(vals, cumsum(weig),
method = "constant", y...