# [R] Odp: : Question about correlation between data.

Petr PIKAL petr.pikal at precheza.cz
Mon Oct 19 08:31:38 CEST 2009

```David Scott <d.scott at auckland.ac.nz> napsal dne 17.10.2009 03:01:35:

> Petr PIKAL wrote:
> > Hi
> >
> > r-help-bounces at r-project.org napsal dne 16.10.2009 15:24:05:
> >
> >> hi everybody, I'm a student, and I'm new using R!
> >> I'm looking for statistical
> >> help hoping somebody can answer me!
> >>
> >> This is my problem:
> >> I have 2 temporal
> >> series. The firstone is a series of mesured data (height of
monitorated
> >> points), the second is a series of temperature (in Celsius degree).
> >>
> >> Using
> >> Matlab I have built  the two graphs (Measured Data - Time &
Temperature
> > -
> >> Time).
> >>
> >> Looking those graphs I can surely say that there is a clear
> >> correlation beetween theme, and also that the measured data are
surely
> >> influenced by the variations of temperature.
> >>
> >> Unfortunately my statistical
> >> knowledges are not that large so using R seems quite difficult to me.

> >>
> >> My
> >> question is: is there a code already written the can compare the 2
> > temporal
> >> series and can find the correlation between the data???
> >
> > If the relationship is linear than
> >
> > lm(values~temperature, ...)
> >
> > shall suffice
> >
> > if it is nonlinear than you can look e.g. to
> >
> > ?nls
> >
> >> And also: is there a
> >> code that can correct the Measured Data from the influence of
> > temperature and
> >> return a clean data???
> >
> > maybe ?predict.
> >
> > Regards
> > Petr
> >
> >
>
> This sounds a little dangerous to me. Antonio is wanting to determine
> correlations between *time series* if I understand correctly.

Hm, I understood he measured some value and at the same time he recorded a
temperature. He wants to know if there is a relationship between value and
temperature. If he is monitoring some continuous process and there is no
wave or drift of both values with time (the series are stationery) he can
use simple lm. I agree that when the values are drifting or fluctuating
with some time pattern than he shall adjust for it.

Regards
Petr

>
> The time series need to be prewhitened or the correlations between
> successive observations modeled in some way. Just using lm can be very
> misleading because of the violation of the independence assumption.
>
> If Antonio does not understand these comments he needs to consult a
> local statistician.
>
> David Scott
>
>
>
> --
> _________________________________________________________________
> David Scott   Department of Statistics
>       The University of Auckland, PB 92019
>       Auckland 1142,    NEW ZEALAND
> Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
> Email:   d.scott at auckland.ac.nz,  Fax: +64 9 373 7018
>
> Director of Consulting, Department of Statistics
>

```