Learn R Programming

WiSEBoot (version 1.4.0)

deSeasonalize: De-seasonalize daily, monthly, or data series with IDs

Description

Generally, this function performs data standardization by an ID. It is useful for data pre-processing, by removing daily, monthly, or other periodic means which are not of interest. Two quick methods are available: removing the mean and standardization. Note, this is not the optimal method in the statistical literature for de-seasonalization.

Usage

deSeasonalize(dates, X, type = "daily", method = "deMean")

Arguments

dates
vector of dates or IDs for the data, X. This vector must have the same length as X (or the same number of rows as X). A recognized R date format is required unless the method="custom" option is called. Missing values are not allowed. More than 1 replicate of the ID is recommended, as this is the criteria to remove the mean/standardize.
X
vector or matrix of all data to be de-seasonalized. Missing values are not allowed and the data should be numeric. The length, or number of rows, of X should match the length of dates. Thus, if X is a matrix, the columns of X contain the individual data series.
type
how often to de-seasonalize. Allowed values are "daily", "monthly", and "custom". The "daily" or "monthly" de-seasonalization options require that the dates vector be of a recognized R date format. The "custom" option allows for de-seasonalization at other rates (e.g. quarterly, hourly, etc.), or, more generally, standardization by an ID.
method
how de-seasonalization is implemented. Allowed values are "deMean" and "standardize". The "deMean" method removes the mean by dates. The "standardize" method standardizes (i.e. removes the mean and divides by the standard deviation) by dates.

Value

a vector or matrix of the same dimension as X which has been de-seasonalized appropriately.

Details

For a supplied matrix, X, the same dates -- ID criteria -- is used for de-seasonalization in each column. That is, each column of X is de-seasonalized by dates.

This is not an optimal de-seasonalization methodology. For users interested in a more robust method, please see the 'deseasonalize' R package.

See Also

R package 'deseasonalize', http://cran.r-project.org/package=deseasonalize

Examples

Run this code
ID <- as.Date(c("2014-05-14", "2013-06-20", "2013-05-14", "2012-06-20",
                "1999-09-09", "1998-09-08", "1998-09-09", "1982-05-14", 
                "2000-09-08"))
someData <- seq(1, 9)

deSeasonalize(dates=ID, X=someData, type="daily", method="deMean") 
deSeasonalize(dates=ID, X=someData, type="monthly", method="standardize")

Run the code above in your browser using DataLab