EVOLUTION-MANAGER
Edit File: Nile.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Flow of the River Nile</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for Nile {datasets}"><tr><td>Nile {datasets}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Flow of the River Nile</h2> <h3>Description</h3> <p>Measurements of the annual flow of the river Nile at Aswan (formerly <code>Assuan</code>), 1871–1970, in <i>10^8 m^3</i>, “with apparent changepoint near 1898” (Cobb(1978), Table 1, p.249). </p> <h3>Usage</h3> <pre>Nile</pre> <h3>Format</h3> <p>A time series of length 100. </p> <h3>Source</h3> <p>Durbin, J. and Koopman, S. J. (2001). <em>Time Series Analysis by State Space Methods</em>. Oxford University Press. <a href="http://www.ssfpack.com/DKbook.html">http://www.ssfpack.com/DKbook.html</a> </p> <h3>References</h3> <p>Balke, N. S. (1993). Detecting level shifts in time series. <em>Journal of Business and Economic Statistics</em>, <b>11</b>, 81–92. doi: <a href="https://doi.org/10.2307/1391308">10.2307/1391308</a>. </p> <p>Cobb, G. W. (1978). The problem of the Nile: conditional solution to a change-point problem. <em>Biometrika</em> <b>65</b>, 243–51. doi: <a href="https://doi.org/10.2307/2335202">10.2307/2335202</a>. </p> <h3>Examples</h3> <pre> require(stats); require(graphics) par(mfrow = c(2, 2)) plot(Nile) acf(Nile) pacf(Nile) ar(Nile) # selects order 2 cpgram(ar(Nile)$resid) par(mfrow = c(1, 1)) arima(Nile, c(2, 0, 0)) ## Now consider missing values, following Durbin & Koopman NileNA <- Nile NileNA[c(21:40, 61:80)] <- NA arima(NileNA, c(2, 0, 0)) plot(NileNA) pred <- predict(arima(window(NileNA, 1871, 1890), c(2, 0, 0)), n.ahead = 20) lines(pred$pred, lty = 3, col = "red") lines(pred$pred + 2*pred$se, lty = 2, col = "blue") lines(pred$pred - 2*pred$se, lty = 2, col = "blue") pred <- predict(arima(window(NileNA, 1871, 1930), c(2, 0, 0)), n.ahead = 20) lines(pred$pred, lty = 3, col = "red") lines(pred$pred + 2*pred$se, lty = 2, col = "blue") lines(pred$pred - 2*pred$se, lty = 2, col = "blue") ## Structural time series models par(mfrow = c(3, 1)) plot(Nile) ## local level model (fit <- StructTS(Nile, type = "level")) lines(fitted(fit), lty = 2) # contemporaneous smoothing lines(tsSmooth(fit), lty = 2, col = 4) # fixed-interval smoothing plot(residuals(fit)); abline(h = 0, lty = 3) ## local trend model (fit2 <- StructTS(Nile, type = "trend")) ## constant trend fitted pred <- predict(fit, n.ahead = 30) ## with 50% confidence interval ts.plot(Nile, pred$pred, pred$pred + 0.67*pred$se, pred$pred -0.67*pred$se) ## Now consider missing values plot(NileNA) (fit3 <- StructTS(NileNA, type = "level")) lines(fitted(fit3), lty = 2) lines(tsSmooth(fit3), lty = 3) plot(residuals(fit3)); abline(h = 0, lty = 3) </pre> <hr /><div style="text-align: center;">[Package <em>datasets</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>