[R] Linear model and time series

John C Frain frainj at gmail.com
Sun Apr 1 18:20:23 CEST 2007


This question is not as simple as might appear.  As the data are time
series one should be very concerned about the distribution of the
residuals,   Are the series stationary and if not are they integrated
of the same order and cointegrated.  The danger of spurious results is
a very live issue. As an example the attached data file contains two
series.   The file cpi.csv contains data on the log of the Irish CPI
for the period 1957 Quarter 1 to 2006 Quarter 2.  It also contains
data on a variable c which has been proposed as an indicator of the
level of the CPI.  If you complete the regression using lm() you will
get an apparently good answer.  In effect the variable c is cumulative
rainfall in Armagh from 1857 Quarter 1 to 1906 Quarter 2.  Despite the
favourable regression results there is obviously no relationship
between the variables.

My recommendation to Andre would be to study a good book on
time-series analysis.  One is not doing him a favour by recommending a
procedure to him that may lead to spurious results when not applied
properly.

Best Regards

John Frain

On 31/03/07, Achim Zeileis <Achim.Zeileis at wu-wien.ac.at> wrote:
> On Sat, 31 Mar 2007, Andre Jung wrote:
>
> > Dear all,
> >
> > I have three timeseries Uts, Vts, Wts. The relation between the time
> > series can be expressed as
> >
> > Uts = x Vts + y Wts + residuals
> >
> > How would I feed this to lm() to evaluate the unknowns x and y?
>
> If the time series are aligned (and univariate) you can just do
> lm(Uts ~ Vts + Wts)
> If not, have a look at the "dynlm" and/or "dyn" packages.
> Z
>
> > Thanks,
> > andre
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> >
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
John C Frain
Trinity College Dublin
Dublin 2
Ireland
www.tcd.ie/Economics/staff/frainj/home.html
mailto:frainj at tcd.ie
mailto:frainj at gmail.com


More information about the R-help mailing list