diff options
-rw-r--r-- | R/detrend.R | 38 | ||||
-rw-r--r-- | man/detrend.idframe.Rd | 32 | ||||
-rw-r--r-- | man/predict.detrend.idframe.Rd | 31 |
3 files changed, 90 insertions, 11 deletions
diff --git a/R/detrend.R b/R/detrend.R index 8fde614..45cdbbe 100644 --- a/R/detrend.R +++ b/R/detrend.R @@ -4,21 +4,21 @@ #' #' @param data an object of class \code{idframe} #' +#' @return +#' A list containing the following elements +#' +#' \tabular{ll}{ +#' \code{fitted.values} \tab \code{idframe} object with detrended variables +#' \code{output.trend} \tab \code{list} containing trend fits for each output variable \cr +#' \code{input.trend} \tab \code{list} containing trend fits for each input variable +#' } +#' #' @examples #' data(cstr) #' fit <- detrend(cstr) -#' cstr_detrend <- predict(fit) -#' -#' ## Examples for train and test sets -#' data(cstr) -#' splitList <- dataPartition(cstr,p=0.6) -#' train <- splitList$estimation # training set -#' test <- splitList$validation # testing set -#' fit <- detrend(trend) -#' train_detrend <- predict(fit) -#' test_detrend <- predict(fit,newdata=test) +#' cstr_detrend <- predict(fit) #' -#' @seealso \code{\link[stats]{lm}} +#' @seealso \code{\link{predict.detrend.idframe}}, \code{\link[stats]{lm}} #' @export detrend.idframe <- function(data){ @@ -41,7 +41,23 @@ detrend.idframe <- function(data){ #' Predict method for trend fits on idframe objects #' +#' Detrended \code{idframe} object based on linear trend fit #' +#' @param object an object of class \code{idframe} +#' @param newdata An optional idframe object in whic to look for variables with which +#' to predict. If ommited, the original detrended idframe object is used +#' +#' @return an \code{idframe} object +#' +#' @examples +#' ## Examples for train and test sets +#' data(cstr) +#' splitList <- dataPartition(cstr,p=0.6) +#' train <- splitList$estimation # training set +#' test <- splitList$validation # testing set +#' fit <- detrend(trend) +#' train_detrend <- predict(fit) +#' test_detrend <- predict(fit,newdata=test) #' @export predict.detrend.idframe <- function(object,newdata=NULL,...){ diff --git a/man/detrend.idframe.Rd b/man/detrend.idframe.Rd new file mode 100644 index 0000000..9461363 --- /dev/null +++ b/man/detrend.idframe.Rd @@ -0,0 +1,32 @@ +% Generated by roxygen2 (4.1.0): do not edit by hand +% Please edit documentation in R/detrend.R +\name{detrend.idframe} +\alias{detrend.idframe} +\title{Remove linear trends} +\usage{ +detrend.idframe(data) +} +\arguments{ +\item{data}{an object of class \code{idframe}} +} +\value{ +A list containing the following elements + +\tabular{ll}{ + \code{fitted.values} \tab \code{idframe} object with detrended variables + \code{output.trend} \tab \code{list} containing trend fits for each output variable \cr + \code{input.trend} \tab \code{list} containing trend fits for each input variable + } +} +\description{ +Removes the linear function from the input and output matrices. +} +\examples{ +data(cstr) +fit <- detrend(cstr) +cstr_detrend <- predict(fit) +} +\seealso{ +\code{\link{predict.detrend.idframe}}, \code{\link[stats]{lm}} +} + diff --git a/man/predict.detrend.idframe.Rd b/man/predict.detrend.idframe.Rd new file mode 100644 index 0000000..933a907 --- /dev/null +++ b/man/predict.detrend.idframe.Rd @@ -0,0 +1,31 @@ +% Generated by roxygen2 (4.1.0): do not edit by hand +% Please edit documentation in R/detrend.R +\name{predict.detrend.idframe} +\alias{predict.detrend.idframe} +\title{Predict method for trend fits on idframe objects} +\usage{ +\method{predict}{detrend.idframe}(object, newdata = NULL, ...) +} +\arguments{ +\item{object}{an object of class \code{idframe}} + +\item{newdata}{An optional idframe object in whic to look for variables with which +to predict. If ommited, the original detrended idframe object is used} +} +\value{ +an \code{idframe} object +} +\description{ +Detrended \code{idframe} object based on linear trend fit +} +\examples{ +## Examples for train and test sets +data(cstr) +splitList <- dataPartition(cstr,p=0.6) +train <- splitList$estimation # training set +test <- splitList$validation # testing set +fit <- detrend(trend) +train_detrend <- predict(fit) +test_detrend <- predict(fit,newdata=test) +} + |