# NOT RUN {
# acf
result <- acf(lh, plot=FALSE)
tidy(result)
# ccf
result <- ccf(mdeaths, fdeaths, plot=FALSE)
tidy(result)
# pcf
result <- pacf(lh, plot=FALSE)
tidy(result)
# lag plot
library(ggplot2)
result <- tidy(acf(lh, plot=FALSE))
p <- ggplot(result, aes(x=lag, y=acf)) +
geom_bar(stat='identity', width=0.1) +
theme_bw()
p
# with confidence intervals
conf.level <- 0.95
# from \code{plot.acf} method
len.data <- length(lh) # same as acf$n.used
conf.int <- qnorm((1 + conf.level) / 2) / sqrt(len.data)
p + geom_hline(yintercept = c(-conf.int, conf.int),
color='blue', linetype='dashed')
# }
Run the code above in your browser using DataLab