https://github.com/cran/ftsa
Raw File
Tip revision: bdacd962e07983b325d3672c4048f4337223e4de authored by Han Lin Shang on 09 December 2010, 00:00:00 UTC
version 2.4
Tip revision: bdacd96
sd.fts.R
`sd.fts` <- function(x, method = c("coordinate", "FM", "mode", "RP", "RPD"), trim = 0.25,...)
{
   if (class(x)[1] == "fts"|class(x)[1] == "fds"|class(x)[1] == "sfts"){
       functions = t(x$y)
       n = dim(functions)[1]
       p = dim(functions)[2]
       method = match.arg(method)
       if (method == "coordinate"){
           loc = (n-1)*apply(functions, 2, sd)/n
       }
       if (method == "FM"){
           lista = depth.FM(x, trim = trim)$ltrim
           loc = sqrt(func.var(functions[lista,]))
       }
       if (method == "mode"){
           lista = depth.mode(x, trim = trim)$ltrim
           loc = sqrt(func.var(functions[lista,]))
       }
       if (method == "RP"){
           lista = depth.RP(x, trim = trim)$ltrim
           loc = sqrt(func.var(functions[lista,]))
       }
       if (method == "RPD"){
           lista = depth.RPD(x, trim = trim)$ltrim
           loc = sqrt(func.var(functions[lista,]))
       }
       if (class(x)[1] == "fds"){
           warning("Object is not a functional time series.")
       }
       return(list(x = x$x, y = loc))
   }
   else {
        stop("Not a functional object.")
   }
}
back to top