[R] Lineair regression modelling between time series //correlation analysis

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Mar 4 12:21:08 CET 2004


On Thu, 4 Mar 2004, Jan Verbesselt wrote:

> Dear R specialists,
> 
> I'm working with time series and want to investigate the relationship
> between two time series by correlation analysis or by fitting a gen.
> lineair model to the plot of x(timeserie1) and y(timeserie2).
> 
> Lin1 <- data.frame(
>         Nr = c(1:lengte),
>         NDII = window(ts.mNDII,c(1998,10),c(2003,11)),
>         InvERC = window(Inv.ERC,c(1998,10),c(2003,11))
>         )
> 
> summary(glm(NDII ~ InvERC, data=Lin1, family=gaussian(link ="identity")))

Why are you using glm to do linear regression?  lm() is the preferred 
function.

> Error in "storage.mode<-"(`*tmp*`, value = "double") : 
>         invalid time series parameters specified
> 
> How can I solve this error?

We would need to be able to reproduce it to be able to help you.  A quick 
attempt

library(MASS)
Lin1 <- data.frame(male=mdeaths, female=fdeaths)
summary(glm(female ~ male, data=Lin1, family=gaussian(link ="identity")))

works, as there is no technical problem with having time series in such a
fit (although the result may be statistically invalid).

> Are there specific functions which I can use to investigate the
> relationship between two time series? (object ts is ok) 

Many, including lm().

>....Does somebody
> has some examples of how to solve this statistical problem? ARIMA, AR,
> ACF of the package "ts" for time series analysis

What is your statistical problem, precisely?  Using the regression 
capabilities on arima() or function gls() in package nlme spring to mind, 
and ccf() and spectrum() can display cross-correlations and ar() can fit a 
joint AR model.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list