       Re: computation of autocovariance

• To: mathgroup at smc.vnet.net
• Subject: [mg46190] Re: computation of autocovariance
• From: Mariusz Jankowski<mjankowski at usm.maine.edu>
• Date: Tue, 10 Feb 2004 00:06:08 -0500 (EST)
• Organization: University of Southern Maine
• References: <c04ehe\$gbr\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Paolo, you must define/initialize autoconvS, for example

autoconV = Table[0,{60}].

and then your code should work. However, it is always be better to use
built-in functions. The same should be calculated as follows:

Method 1: if x is not very, very long you can do

tmp = ListCorrelate[x, x, 1, 0];

then

autoconvS = Take[tmp,60];

Method 2: Best approach is to use (see docs on ListCorrelate)

autoconvS = ListCorrelate[x, x, {1, Length[x] - 59}, 0]

Bye, Mariusz

>>> paolo<tarpanelli at libero.it> 2/7/2004 11:39:10 PM >>>
I am computing the autocovariance, with temporal lags from 1 to 60, of a
time serie but my procedure does not works.
Can you help me?

x={timeserie}

For[j=1,j<61,j++,
autocovS[[j]]=1/Length[x]-j  +
Sum[(x[[i]]-Mean[x])*(x[[i+j]]-Mean[x]),{i,1,Length[x]-j-1,1}]]

when i evaluate the procedure, Mathematica reply

"Part specification autocovS?j? is longer than depth of object."

thanks

Paolo Tarpanelli

```

• Prev by Date: Re: extracting a list to a list, help please
• Next by Date: Re: Algebraic Manipulation
• Previous by thread: computation of autocovariance
• Next by thread: Re: computation of autocovariance