7

I'm trying to create a function that calculates and plots the sample variogram for a time series. It should take two arguments: data, a time series, essentially a list of reals; k, an integer greater than 0. It should produce a `ListLinePlot`

with $k$ on the horizontal axis and $\hat{G_k}$ on the vertical axis.

The plotting and such isn't really the problem. The problem is getting the mathematical formulas, which are below, into Mathematica formulas.

$\hat{G_k}$ is essentially a ratio of variance at lag $k$ over the variance at lag $1$:

$\hat{G_k}=\frac{s^2_k}{s^2_1},k=1,2,...$

$s^2_k=\frac{\sum_{t=1}^{n-k}(d^k_t-\bar{d}^k)^2}{n-k-1}$

$\bar{d}^k=(n-k)^{-1}\sum{}d^k_t$

$d^k_t=z_{t+k}-z_t$

$z_t$ is the time series of the length $n$.

I've been beating my head against this for a while now. Any help would be appreciated.

**Edit:** A variogram is statistical tool to assess whether a time series is stationary or not. For a stationary it starts out at $1$ for $k=1$ and then increases until it starts to hover around a certain value. The theory and formulas I have here is from Time Series Analysis and Forecasting by Example. You might be able to use the Search Inside at Amazon to have a look at it.

**Edit2:** Here is a demoplot based on dummydata as to how the end result should look for a stationary time series.

1What's a variogram? Can you provide a link? – rcollyer – 2012-02-28T19:02:52.733

rcollyer: It's a version of a correlogram and can be directly computed with ListConvolve, ListCorrelate,

et al.– whuber – 2012-02-28T19:39:55.843As

`ListPlot`

can do the same thing as`ListLinePlot`

, I removed the version-8 tag. – rcollyer – 2012-02-28T19:42:45.603@rcollyer

`ListLinePlot`

was "New in 6" -- not a problemeven for me;-) – Mr.Wizard – 2012-02-28T20:38:11.433@Mr.Wizard I swore it was new in 8. – rcollyer – 2012-02-28T22:33:38.060

@rcollyer That's OK, even I have trouble keeping versions straight sometimes... – Brett Champion – 2012-02-29T04:29:39.957

@BrettChampion that's actually comforting to know. Either way, the v.8 tag did not belong. – rcollyer – 2012-02-29T04:40:26.900

This question is practically a duplicate of http://mathematica.stackexchange.com/questions/2197/function-for-autocorrelation, which has much simpler answers.

– whuber – 2012-03-06T00:08:10.900You have some programs to calculate variogram of a time eerie or an image, in Fractal Geography by A. Dauphiné, 2012, Wiley.

– Dauphine – 2012-02-29T07:04:55.020