Вопрос

I have a periodic time series, of air temperature over several years, and I want to be able to predict future values for it.

I've calculated the average over the available years of the value at each hour of the year, which works ok, but it's clearly quite noisy, since I only have 4 years data.

  • One way forward could be to do gaussian smoothing, but a better option might be to fit a spline to it.
  • I searched and found lm.circular, which looks like a feasible solution candidate.
    • It doesn't have any way of specifying a formula, so no way of asking it to fit a spline.
    • I tried lm.circular using a 1-order polynomial, but a practical problem arose: it ran out of memory. Note that a standard lm is almost instantaneous, and uses no noticeable memory, on the same data
    • I also tried asking it to fit a Von Mises (type='c-l'), and it asked me for an 'init' parameter, and I couldn't really understand from the description what I was supposed to put into 'init'?
  • Using the normal lm is not really an option, since it gives terrible results at either end of the period.
  • I suppose another possibility is to use ets/HoltWinters, with a timeseries frequency equal to the number of hours in the year?

I'm not quite sure which way is the best way forward, but I suspect that this is a pretty common problem, and there are probably very standard ways of dealing with it?

Это было полезно?

Решение

Ok, I found a super-easy way in the end. You don't need any fancy packages, you simply use standard lm and apply cosine and sine to the timeline:

model <- lm( y ~ I(sin(x/periodlength*2*pi) * I(cos(x/periodlength*2*pi)), trainingdata )

... .then you can tweak this formula to your heart's content.

(Edit: oh yeah, and it's super fast and doesn't use much memory).

Другие советы

I used ARIMA for predicting future values

It is like this

fit <- auto.arima(values)//for getting order of ARIMA
//here values-> time series data

future.values<-predict(fit,n.ahead=24)//used for predicting future values
//n.ahead-> u can give the maximum number of values you want to predict

The following link will help you to understand more details

http://www.jstatsoft.org/v27/i03/paper

Note: The "values" must be a time series data.if not we can convert to a time series data like values.ts<-ts(values,frequency= )

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top