Last data update: 2014.03.03

R: Model terms for time series models
ModelTermsR Documentation

Model terms for time series models

Description

Tools for creating model/formula terms in time series models

Usage

Lag(v, k, group = NULL)
runMean(v, lags = 0, group = NULL, filter = NULL)
harmonic(x, nfreq, period, intercept = FALSE)

Arguments

v,x

a numeric vector

k,lags

an integer vector giving lag numbers

group

a factor or a list of factors defining groups of observations

filter

a vector specifying a linear filter

nfreq

number of sine/cosine pairs to include

period

period

intercept

should basis matrix include a column of 1s?

Value

Lag returns a length(v) by length(k) matrix of lagged variables. runMean returns a numeric vector of length length(v). harmonic returns a matrix of sine/cosine basis functions.

Author(s)

Roger D. Peng

Examples

## Ten day "time series"
x <- rnorm(10)

## Lag 1 of `x'
Lag(x, 1)

## Lag 0, 1, and 2 of `x'
Lag(x, 0:2)

## Running mean of lag 0, 1, and 2
runMean(x, 0:2)

Results