https://github.com/cran/ftsa
Raw File
Tip revision: 7621951a183186ccd8706e35121ccdc4dbfddd1a authored by Shang H on 10 December 2014, 07:56:05 UTC
version 4.1
Tip revision: 7621951
quantile.outliers.pond.R
`quantile.outliers.pond` <- function(data, dfunc = depth.mode, nb = 200, suav = 0.05,...)
{
    functions = t(data$y)
    n <- dim(functions)[1]
    m <- dim(functions)[2]
    if(is.null(n) && is.null(m)) 
       stop("I do not have a matrix")
       d = dfunc(data,...)$prof
       cuantiles <- numeric(nb)
       vv = var(functions)
       pr = d/sum(d)
       for(i in 1:nb){
           bsample <- functions[sample(1:n, size = n, replace = T, prob = pr),]
           if(suav>0){
              bsample <- bsample + mvrnorm(n = n, rep(0, m), vv * suav)
           }
           bsample = fts(1:dim(bsample)[1], bsample)
           d = dfunc(bsample,...)$prof
           cuantiles[i] <- quantile(d, probs = 0.01, type = 8)
       }
     return(cuantiles)
}
back to top