Learn R Programming

VBV (version 0.6.2)

moving.decomposition: moving.decomposition -- decompose a times series into locally estimated trend and season figures

Description

moving.decomposition -- decompose a times series into locally estimated trend and season figures

Usage

moving.decomposition(n, p, q.vec, m, base.period, lambda1, lambda2)

Value

list with the following components:

  • W1nxn matrix of weights. Trend is estimated as W1 %% y, if y is the data vector W2nxn matrix of weights. Season is estimated as W2 %% y, if y is the data vector

Arguments

n

number of observation points (must be odd!). Internally this will be transformed to seq( -(n-1)/2, (n-1)/2, 1)

p

maximum exponent in polynomial for trend

q.vec

vector containing frequencies to use for seasonal component, given as integers, i.e. c(1, 3, 5) for 1/2pi, 3/2pi, 5/2*pi (times length of base period)

m

width of moving window

base.period

base period in number of observations, i.e. 12 for monthly data with yearly oscillations

lambda1

penalty weight for smoothness of trend

lambda2

penalty weight for smoothness of seasonal component

Examples

Run this code
### Usage of moving.decomposition

t <- 1:121 # equidistant time points, i.e. 5 days

m <- 11

p <- 2     # maximally quadratic
q <- c(1, 3, 5)   # 'seasonal' components within the base period
base.period <- 24 # i.e. hourly data with daily cycles
l1 <- 1    
l2 <- 1

m.dec <- moving.decomposition( length(t), p, q, m, base.period, l1, l2)

Run the code above in your browser using DataLab