Вы находитесь на странице: 1из 2

library(fpp)

# take a look at the usgdp time series in expsmooth package

help(usgdp)

str(usgdp)

plot(usgdp)

gdp<- window(usgdp, start=1990)

gdp

# compute a forecast

hfc.1 <- holt(gdp, alpha = .1, beta = .6, initial = "simple", h=15)

summary(hfc.1)

# plot the forecast values

plot(hfc.1, PI=FALSE, ylab="US GDP", xlab="Time", main="", fcol="white", lwd=3)

lines(fitted(hfc.1), col="blue", lwd=3)

lines(hfc.1$mean, col="blue", type="o")

hfc.2 <- holt(gdp, alpha = .1, beta = .6, initial = "simple", exponential=TRUE, h=15)

summary(hfc.2)

# plot the forecast values

lines(fitted(hfc.2), col="red", lwd=3)

lines(hfc.2$mean, col="red", type="o")

hfc.3 <- holt(gdp, damped=TRUE, h=15)


summary(hfc.3)

lines(fitted(hfc.3), col="green", lwd=3)

lines(hfc.3$mean, col="green", type="o")

hfc.4 <- holt(gdp, exponential=TRUE, damped=TRUE, h=15)

summary(hfc.4)

lines(fitted(hfc.4), col="orange", lwd=3)

lines(hfc.4$mean, col="orange", type="o")

Вам также может понравиться