# [R] This is supposed to predict a time series?!

John Stollberg coffeevore at hotmail.com
Wed Mar 9 22:02:04 CET 2011

```
There does seem to be something odd about StructTS, or perhaps the methodology. Try:

> data(AirPassengers)
> ap <- log10(AirPassengers)-2

> (fit <- StructTS(ts(ap[1:138], freq=12), type="BSM"))
Call:
StructTS(x = ts(ap[1:138], freq = 12), type = "BSM")
Variances:
level      slope       seas    epsilon
0.000e+00  4.346e-04  6.813e-05  0.000e+00
> (fit <- StructTS(ts(ap[1:139], freq=12), type="BSM"))

Call:
StructTS(x = ts(ap[1:139], freq = 12), type = "BSM")
Variances:
level      slope       seas    epsilon
0.000e+00  4.363e-04  6.705e-05  0.000e+00

> (fit <- StructTS(ts(ap[1:140], freq=12), type="BSM"))

Call:
StructTS(x = ts(ap[1:140], freq = 12), type = "BSM")
Variances:
level      slope       seas    epsilon
0.0001521  0.0000000  0.0002667  0.0000000

> (fit <- StructTS(ts(ap[1:141], freq=12), type="BSM"))
Call:
StructTS(x = ts(ap[1:141], freq = 12), type = "BSM")
Variances:
level      slope       seas    epsilon
0.0001511  0.0000000  0.0002649  0.0000000

The fitted model parameters change fairly dramatically as one increases the length of this time series from 139 to 140. As I recall there was a post about this last month.

John

>On 2011-03-07 20:27, Ben Simpkins wrote:
>> Hello,
>>
>> I just ran the predict.StructTS function using the AirPassengers data
>> and got a ridiculous result. Here's what I ended up with:
>> http://24.210.155.111/PredictWhat!.pdf
>>
>> Who wrote this? Am I seriously supposed to think this function would
>> accurately predict a time series?
>If you knew how to use the function correctly, I suppose that
>it would be reasonable to expect you to trust its output, at
>least within the limits of uncertainty.
>Perhaps you could post the code that led you to be so
>scornful about the efforts of whoever did create the
>function.
>It's been my experience that users are often quick to
>blame the software for their own faulty code.
>I had no problem obtaining reasonable predicted values
>for the data.
>>
>> -AnalogKid
>Ah, well, perhaps it's just youthful braggadocio.
>Peter Ehlers
```