knitr::opts_chunk$set(echo = TRUE) library(forecast) library(ggplot2) options(width=50)
autoplot(USAccDeaths) + ylab("Total deaths") + xlab("Year")
ggseasonplot(USAccDeaths, year.labels=TRUE, year.labels.left=TRUE) + ylab("Total deaths")
ggseasonplot()
ggseasonplot(USAccDeaths, year.labels=TRUE, polar=TRUE) + ylab("Total deaths")
\only<2>{ \begin{textblock}{4}(8,4) \begin{alertblock}{} Only change is to switch to polar coordinates. \end{alertblock} \end{textblock} }
ggsubseriesplot(USAccDeaths) + ylab("Total deaths")
ggsubseriesplot()
gglagplot(USAccDeaths, lags=9)
gglagplot(USAccDeaths, lags=9, do.lines=FALSE)
\only<2>{ \begin{textblock}{4}(8.3,3) \begin{block}{} \begin{itemize}\tightlist \item Each graph shows $y_t$ plotted against $y_{t-k}$ for different values of $k$. \item Autocorrelations are correlations associated with these scatterplots. \end{itemize} \end{block} \end{textblock} }
We denote the sample autocovariance at lag $k$ by $c_k$ and the sample autocorrelation at lag $k$ by $r_k$. Then define
\begin{block}{} \begin{align} c_k &= \frac{1}{T}\sum_{t=k+1}^T (y_t-\bar{y})(y_{t-k}-\bar{y}) \[0.cm] \text{and}\qquad r_{k} &= c_k/c_0 \end{align} \end{block}\pause\small
Results for first 9 lags for USAccDeaths
data:
USAccDeathsacf <- matrix(acf(c(USAccDeaths), lag.max=9, plot=FALSE)$acf[-1,,1], nrow=1) colnames(USAccDeathsacf) <- paste("$r_",1:9,"$",sep="") knitr::kable(USAccDeathsacf, booktabs=TRUE, align="c", digits=3, format.args=list(nsmall=3))
ggAcf(USAccDeaths)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.