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

Description Usage Arguments Details Value Author(s) See Also Examples

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

1
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.

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.

Value

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

Author(s)

Megan Heyman

See Also

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

Examples

1
2
3
4
5
6
7
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")

Example output

[1] -3.0 -1.0 -1.0  1.0 -1.0 -1.5  1.0  4.0  1.5
[1] -0.8320503 -0.7071068 -0.2773501  0.7071068 -1.0246951 -0.4391550  0.1463850
[8]  1.1094004  1.3174651

WiSEBoot documentation built on May 2, 2019, 12:35 p.m.