[R] Comparison of two time series using R

Thomas Lumley tlumley at u.washington.edu
Tue Jul 30 17:11:12 CEST 2002


On Tue, 30 Jul 2002, Tim Churches wrote:

> We have two time series: the first is a series of weekly counts of
> isolates of RSV (respiratory syncytial virus) by pathology laboratories,
> and the second is a series of weekly counts of cases of bronchiolitis in
> young children presenting to hospital emergency departments.
> Bronchiolitis in young children is usually caused by RSV infection, and
> simple visual inspection reveals a very close correspondence between the
> two series, both of which show strong seasonality and also corresponding
> variation from year to year.
>
<snip>
> Is this a reasonable approach to our question? Hints on how to proceed
> are most welcome, and/or references to papers or texts which might
> render us a bit less clueless wrt this problem.

This is similar to the air pollution epidemiology question of whether eg
particulate air pollution causes myocardial infarction. There are very
strong season patterns, year-to-year variation, and weather effects, and a
very small (but non-zero) residual association.

I would fit a loglinear model with spline terms to remove the seasonal
effects
eg

model <- glm(bronchiolitis~RSV+ns(week,df)+temperature,family=quasipoisson)

where df is chosen to remove seasonal-scale variability (eg 4-6 df/year of
data)

If there is substantial autocorrelation in the pearson residuals

   acf(resid(model,"pearson"))

then you need some other sort of standard error calculation.  One method
(which was my PhD dissertation) is available for R at
   http://faculty.washington.edu/tlumley/weave.html

However, in air pollution epi there usually isn't much autocorrelation
after season and weather are removed.



This will tell you how well RSV prevalence predicts bronchiolitis over and
above seasonal variation.


You might also try adding a sine/cosine term to the model to represent the
predictable part of seasonal variation.  This would allow you to say how
much of the seasonal variation is stable from year to year, which would be
useful in assessing prediction.


	-thomas




-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list