lm_decomp {deseats}R Documentation

Decomposition of Time Series Using Linear Regression

Description

Trend and seasonality are simultaneously modelled by considering a polynomial for the trend and a polynomial in the seasonality (via dummy variables and their interactions with time) for the different time units (e.g. months).

Usage

lm_decomp(yt, order_poly = 1, order_poly_s = 1, season = NULL)

Arguments

yt

a time series object of class "ts" or an object that can be transformed to that class using as.ts.

order_poly

the order of the polynomial considered for the trend; the default is order_poly = 1.

order_poly_s

the order of the polynomial considered for the seasonality; the default is order_poly_s = 1.

season

the seasonal period in yt; by default, the seasonal period is obtained automatically from yt.

Details

Apply ordinary least squares to estimate trend and seasonality simultaneously in a given time series. This a global approach in contrast to for example deseats, which is a local estimation method.

Value

An S4 object with the following elements is returned.

decomp

an object of class "mts" that consists of the decomposed time series data.

ts_name

the object name of the initially provided time series object.

frequency

the frequency of the time series.

regression_output

an object of class "lm", i.e. basic regression output; the time variable t used in the regression is encoded as seq_along(yt); the dummy variable S2 encodes the first observation time point (and the yearly corresponding time points) as -1 and the second observation time point (and the yearly corresponding time points) as 1, the dummy variable S3 does the same but has instead for the third observation time point (and the yearly corresponding time points) a 1, and so on.

Author(s)

Examples

est <- lm_decomp(log(EXPENDITURES), order_poly = 3, order_poly_s = 2)
est


[Package deseats version 1.1.0 Index]