practically we have to pass all these stages:
he did it today with a similar case, where there is non trend, but a
seasonality.
I've to modify this data for canadian lynx and i know how to do it.
the problem is to chose the correct p q d P Q D and comment the results for
the graphs and the reasons of my graphs...

rm(list=ls())
N = length(nottem)
max_lag = 20
plot(nottem)
par(ask=TRUE)
diff_12 = diff(nottem,lag=12)
plot(diff_12)
N = length(diff_12)
max_lag = 36
acf(diff_12,max_lag)
pacf(diff_12,max_lag)
res = arima(diff_12, order = c(1, 0, 0), seasonal = list(order = c(1, 0, 1),
period = 12))
residui = res$residuals
acf_r = acf(residui,max_lag,type="corr")
acf_res = acf_r$acf
Q = N * sum(acf_res[2:max_lag]^2)
p_val = 1 - pchisq(Q, max_lag - 2)
print(p_val)
readline()

# Forecasting: (1) Holt Winters

m <- HoltWinters(nottem, seasonal = "add")
p1 <- predict(m, 6, prediction.interval = TRUE)
plot(m)
par(ask=TRUE)
plot(fitted(m))
print(p1)

# 2. SARIMA

p2 = predict(arima(nottem, order = c(1, 0, 0), seasonal = list(order = c(1,
1, 1), period = 12)), n.ahead = 12)
p3 = p2$pred
p3 = ts(p3,start=1940,frequency=12)

# plotting both the observed series and the forecasts

final = c(nottem,p3)
final = ts(final,start=1920,frequency=12)
plot(final,type="b")
lines(p3,type="b",col="red")














#p2 = predict(res, n.ahead = 6)
#x = log(AirPassengers)
#n = length(x)
#p2_level1 = exp(x[n-11] + (x[n] - x[n-12]) - p2$pred[1])
#h = 6
#p2_level = rep(0,h)
#x = c(x,rep(0,h))
#for (i in 1:h)
#{
#    p2_level[i] = exp(x[n-12+i] + (x[n-1+i] - x[n-12+(i-1)]) - p2$pred[i])
#    x[n+i] = log(p2_level[i])
#}    
-- 
View this message in context: 
http://r.789695.n4.nabble.com/HELPPPPPP-tp3063358p3064637.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to