Hi Vincy,

Take a look on the material bellow, maybe they can help you:

http://www.statoek.wiso.uni-goettingen.de/veranstaltungen/zeitreihen/sommer03/ts_r_intro.pdf

http://www.maths.bris.ac.uk/~mazlc/TSA/r-ts.pdf

http://www.stat.pitt.edu/stoffer/tsa2/R_time_series_quick_fix.htm

On Thu, Aug 25, 2011 at 7:18 AM, Vincy Pyne <vincy_p...@yahoo.ca> wrote:

> Dear R list
>
> As suggested by Prof Brian Ripley, I have tried to read acf literature. The
> main problem is I am not the statistician and hence have some problem in
> understanding the concepts immediately. I came across one literature (
> http://www.stat.nus.edu.sg/~staxyc/REG32.pdf) on auto-correlation giving
> the methodology. As per that literature, the auto-correlation is arrived at
> as per following.
>
> y =
> c(15.91,9.80,17.16,16.68,15.53,22.66,31.01,8.62,45.82,10.97,45.46,28.69,36.75,37.75,
> 41.18,42.67,46.05, 43.70,53.08,47.56)
>
> t = c(1:20) # defining time variable.
>
> Fitting y = a + bt + e, I get the estimates of a and b as a = 9.12 and b =
> 2.07. So using these estimates I obtain
>
> y_fit =
> c(11.19,13.26,15.33,17.40,19.47,21.54,23.61,25.68,27.75,29.82,31.89,33.96,
> 36.03,38.10, 40.17,42.24,44.31,46.38,48.45,50.52)  # these are fitted
> values.
>
>
> e_t = (y - y_fit)   # dif between the observed y and fitted value of
> corresponding y
>
> > e_t
>  [1]   4.72  -3.46   1.83  -0.72  -3.94   1.12   7.40
>  [8] -17.06  18.07 -18.85  13.57  -5.27   0.72  -0.35
> [15]
>  1.01   0.43   1.74  -2.68   4.63  -2.96
>
> # We define
>
> e_t1 =
> c(-3.46,1.83,-0.72,-3.94,1.12,7.40,-17.06,18.07,-18.85,13.57,-5.27,0.72,-0.35,1.01,
> 0.43,1.74,-2.68,4.63,-2.96)   # 1 st element of e_t deleted
>
> e_t2 =
> c(4.72,-3.46,1.83,-0.72,-3.94,1.12,7.40,-17.06,18.07,-18.85,13.57,-5.27,0.72,-0.35,
> 1.01, 0.43,1.74,-2.68,4.63)     # Original series with last element deleted
>
>
> cor(e_t1, e_t2)
>
> > cor(e_t1, e_t2)
> [1] -0.8732316
>
>
> However, if I use
>
> acf(y, 1)
>
> Autocorrelations of series ‘y’, by lag
>
>     0     1
> 1.000 0.343
>
> I am simply not able to figure out how acf is used?
>
> Thanking you in advance.
>
> Regards
>
> Vincy
>
> --- On Wed, 8/24/11, Prof Brian Ripley <rip...@stats.ox.ac.uk> wrote:
>
> From: Prof Brian Ripley <rip...@stats.ox.ac.uk>
> Subject: Re: [R] Autocorrelation using library(tseries)
> To: "Vincy Pyne" <vincy_p...@yahoo.ca>
> Cc: r-help@r-project.org
> Received:
>  Wednesday, August 24, 2011, 9:08 AM
>
> Your understanding is wrong.  For a start, there is no function acf() in
> package tseries: it is in stats.
>
> And the autocorrelation at lag one is not the correlation omitting the
> first and last values: it uses the mean and variance estimated from the
> whole series and divisor n.
>
> Have you looked at the reference given on ?acf ?  As the help says
>
>      (This contains the exact definitions used.)
>
> Neither the R help pages nor R-help are intended as tutorials in
> statistics.
>
> On Wed, 24 Aug 2011, Vincy Pyne wrote:
>
> > Dear R list
> >
> > I am trying to understand the auto-correlation concept. Auto-correlation
> is the self-correlation of random variable X with a certain time lag of say
> t.
> >
> > The article "
> http://www.mit.tut.fi/MIT-3010/luentokalvot/lk10-11/MDA_lecture16_11.pdf";
> (Page no. 9 and 10) gives the methodology as under.
>
> But that is not the definitive reference, and no, it doesn't (and what it
> does give is not the conventional definition in the time series literature).
>
> > Suppose you have a time series observations as say
> >
> > X = c(44,41,46,49,49,50,40,44,49,41)
> >
> > # For autocorrelation with time lag of 1 we define
> >
> > A = c(41,46,49,49,50,40,44,49,41)?? # first element of X not considered
> > B = c(44,41,46,49,49,50,40,44,49) # Last element of X not considered
> >
> >> cor(A,B)
> > [1] -0.02581234
> >
> > However, if I try the acf command using library tseries I get
> >
> > acf(X, 1)
> >
> > Autocorrelations of series ???X???, by
> > lag
> >
> > ???????? 0?????????? 1
> > ??1.000 -0.019
> >
> > So
>  by usual correlation command (where same random variable X is converted
> into two series with a time lag of 1), I obtain auto-correlation as
> -0.02581234 and by acf command I get auto-correlation = -0.019 (for time lag
> of 1).
> >
> > I am not able to figure out where I am going wrong or is it my
> understanding of auto-correlation procedure is wrong?
> >
> > Will be grateful if someone guides .
> >
> > Vincy
> >
> >
> >
> >     [[alternative HTML version deleted]]
> >
> >
>
> -- Brian D. Ripley,                  rip...@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
>
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help@r-project.org 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.
>
>


-- 
Atenciosamente,

Raphael Saldanha
saldanha.plan...@gmail.com

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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.

Reply via email to