[R] Regression of a time series on its Quarters
Len Vir
lenvir at gmail.com
Thu Mar 18 17:30:08 CET 2010
# Dear List,
# I want to characterize a time series according to its Quarter components.
# My data ("a.ts":
http://docs.google.com/View?id=dfvvwzr2_478cr9k4cdb) look like:
# Qtr1 Qtr2 Qtr3 Qtr4
# 1948 -0.0714961837 0.0101747827 0.0654816569 -0.0227830729
# 1949 -0.1175517556 0.1151378692 0.1015777858 -0.1971535900
# 1950 0.0716002123 0.2551020416 0.0977574743 -0.0739337411
# ...
# The time series is 216 long
# The easiest way I could figure out, is to create
# Quarter dummies:
Q1 <- rep(c(1,0,0,0),54)
Q2 <- rep(c(0,1,0,0),54)
Q3 <- rep(c(0,0,1,0),54)
Q4 <- rep(c(0,0,0,1),54)
qtr <- cbind(Q1,Q2,Q3,Q4)
# and then regress my data on the dummies.
summary(lm(a.ts ~ qtr - 1))
# The regression on 'Quarters' works fine.
# It does exactly what I want it to do.
# But! Surely there must be a more elegant way
# to accomplish the same thing ?!
# I have looked at the following packages (amongst others):
# tseries, timeSeries, TSA, AER, fSeries, vars, FinTS, xts, fArma,
# fRegression, tsfa, uroot, urca, ...
# without finding anything more convenient (simpler, nicer!).
# Any suggestion?
# Thank you.
# Len Vir
More information about the R-help
mailing list