In this little presention, I plot the Nile dataset in the {datasets} package using the {plotly} package.
This plot is also a glimpse of the time series analysis.
24/07/2020
In this little presention, I plot the Nile dataset in the {datasets} package using the {plotly} package.
This plot is also a glimpse of the time series analysis.
Measurements of the annual flow of the river Nile at Aswan (formerly Assuan), 1871–1970, in 10^8 m^3, “with apparent changepoint near 1898” (Cobb(1978), Table 1, p.249).
A time series of length 100.
Durbin, J. and Koopman, S. J. (2001). Time Series Analysis by State Space Methods. Oxford University Press. http://www.ssfpack.com/DKbook.html
Balke, N. S. (1993). Detecting level shifts in time series. Journal of Business and Economic Statistics, 11, 81–92. doi: 10.2307/1391308.
Cobb, G. W. (1978). The problem of the Nile: conditional solution to a change-point problem. Biometrika 65, 243–51. doi: 10.2307/2335202.
library(datasets)
library(plotly)
library(forecast)
nileFc <- as.ts(forecast(Nile, h = 20, level = 95))
colnames(nileFc) <- make.names(colnames(nileFc))
plot_ly() %>%
add_lines(x = time(Nile), y = Nile, name = "Flow") %>%
add_lines(x = time(nileFc), y = nileFc[, "Point.Forecast"],
type="surface", name = "Est. Median", color = I("green")) %>%
add_lines(x = time(nileFc), y = nileFc[, "Lo.95"],
type="surface", name = "Lower/Upper 95%",
color = I("brown")) %>%
add_lines(x = time(nileFc), y = nileFc[, "Hi.95"],
type="surface", name = "Lower/Upper 95%", color = I("brown"),
showlegend = F) %>%
layout(title = "Annual Flow of the River Nile at Aswan",
xaxis = list(title = "Year"), yaxis = list(title = "Flow"))