diff options
Diffstat (limited to 'R/detrend.R')
-rw-r--r-- | R/detrend.R | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/R/detrend.R b/R/detrend.R index 49122c2..354ceae 100644 --- a/R/detrend.R +++ b/R/detrend.R @@ -18,8 +18,11 @@ #' #' @examples #' data(cstr) -#' fit <- detrend(cstr) -#' Zdetrend <- predict(fit) +#' fit <- detrend(cstr) # remove linear trends +#' Zdetrend <- predict(fit) # get the detrended data +#' +#' demean <- detrend(cstr,type="constant") # remove mean values +#' Zcent <- predict(demean) # get the centered data #' #' @seealso \code{\link{predict.detrend}}, \code{\link[stats]{lm}} #' @export @@ -65,11 +68,19 @@ detrend <- function(data,type=c("constant","linear")[2]){ #' Detrended \code{idframe} object based on linear trend fit #' #' @param object an object of class \code{idframe} -#' @param newdata An optional idframe object in which to look for variables with which -#' to predict. If ommited, the original detrended idframe object is used +#' @param newdata An optional idframe object in which to look for variables with +#' which to predict. If ommited, the original detrended idframe object is used #' #' @return an \code{idframe} object #' +#' @examples +#' data(distill) +#' train <- dataSlice(distill,end=60) # subset the first 60 indices +#' test <- dataSlice(distill,start=61) # subset from index 61 till the end +#' fit <- detrend(train) +#' Ztrain <- predict(fit) +#' Ztest <- predict(fit,test) +#' #' @export predict.detrend <- function(object,newdata=NULL,...){ |