7

2

I have 50 data points that I would like to represent as an AR(4) process. I'd like to over-plot the behaivor of the estimated process model with that of the original (raw) data before I use the model to predict 10 days into the future.

```
Remove[a1, a2, a3, a4, v]
processdata = {{1, 5.0}, {2, 9.0}, {3, 8.0}, {4, 10.0}, {5, 6.1}, {6,
10.4}, {7, 9.1}, {8, 11.6}, {9, 7.5}, {10, 12.1}, {11, 10.4}, {12,
13.5}, {13, 9.0}, {14, 14.1}, {15, 11.9}, {16, 15.7}, {17,
10.8}, {18, 16.4}, {19, 13.7}, {20, 18.3}, {21, 12.9}, {22,
19.0}, {23, 15.8}, {24, 21.2}, {25, 15.3}, {26, 22.1}, {27,
18.3}, {28, 24.6}, {29, 18.1}, {30, 25.8}, {31, 21.2}, {32,
28.6}, {33, 21.4}, {34, 30.0}, {35, 24.6}, {36, 33.2}, {37,
25.2}, {38, 35.0}, {39, 28.6}, {40, 38.5}, {41, 29.6}, {42,
40.7}, {43, 33.3}, {44, 44.7}, {45, 34.8}, {46, 47.4}, {47,
38.8}, {48, 52.0}, {49, 40.9}, {50, 55.2}};
plot1 = ListPlot[processdata, Joined -> True, Frame -> True,
FrameLabel -> {"Time (days)", "Temperature"}, AxesOrigin -> {0, 0},
PlotRange -> All, PlotStyle -> {Thick, Red},
PlotLabel -> "Plot 1: Raw Process Data"]
```

Here I use FindProcessParameters to estimate the four coefficients and the variance. Then I use these values to see how well the model matches the raw data.

```
params = FindProcessParameters[processdata,
ARProcess[{a1, a2, a3, a4}, v]]
a1 = params[[1, 2]];
a2 = params[[2, 2]];
a3 = params[[3, 2]];
a4 = params[[4, 2]];
v = params[[5, 2]];
sigma = Sqrt[v];
y = Table[0, {50}];
y[[1]] = 5.0;
y[[2]] = 9.0;
y[[3]] = 8.0;
y[[4]] = 10.0;
dist = NormalDistribution[0, sigma];
t = 4;
Do[{
t = t + 1,
If[t > 50, Break[]],
whitenoise = RandomVariate[dist],
y[[t]] = whitenoise/(
1 - (a1*y[[t - 1]]) - (a2*y[[t - 2]]) - (a3*y[[t - 3]]) - (a4*
y[[t - 4]]))},
{100}];
modeldata = Transpose[{Range[Length[y]], y}];
plot2 = ListPlot[modeldata, Joined -> True, Frame -> True,
FrameLabel -> {"Time (days)", "Temperature"},
AxesOrigin -> {0, -40}, PlotRange -> All,
PlotStyle -> {Thin, Black}, PlotLabel -> "Plot 2: Model Data"];
plot3 = Show[plot1, plot2,
PlotLabel -> "Plot 3: Raw Process Data(Red) vs AR Model(Black)",
AxesOrigin -> {0, -80}]
```

The above model performance is not very good. Am I doing something wrong here ? I then tried specifying MaximumLikelihood as the process estimator in the hope of getting better parameter estimates but get a FindArgMax error message which I also don't understand.

```
Remove[a1, a2, a3, a4, v]
params = FindProcessParameters[processdata,
ARProcess[{a1, a2, a3, a4}, v],
ProcessEstimator -> "MaximumLikelihood"]
```

FindArgMax::nrnum: "The function value {-Log[PDF[ARProcess[{0.746727,0.814726, . . .

I'm not a Mathematica power user or time-series expert so relatively gentle answers would be much appreciated. Thanks.

Edit 1: Now that I have more than 10 reputation points (I'm a first time stackexchange user) I'm now able to show a plot of the AR model performance.

Since the AR model has a probabilistic component (the white noise), a plot that you may generate will in all likelihood look different than above, nonethless I would expect the fit to still be poor. The question is why ?

many thanks for your comments, you've given me a lot to think about. – Steve – 2013-01-15T14:17:20.773