Summaries of relationships between and within time series.
library("dplyr")
library("tsibbledata")
library("feasts")
library("tidyr")
library("lubridate")
library("ggplot2")
library("stringr")
theme_set(theme_minimal())
vic_2014 <- vic_elec %>%
filter(year(Time) == 2014)
vic_2014 %>%
pivot_longer(Demand:Temperature) %>%
ggplot(aes(x = Time, y = value)) +
geom_line() +
facet_wrap(~ name, scales = "free_y")
A scatterplot clarifies that, while electricity demand generally goes up in the cooler months, the very highest demand happens during high heat days.
ggplot(vic_2014, aes(x = Temperature, y = Demand)) +
geom_point(alpha = 0.6, size = 0.7)
lagged <- rbind(vic_2014[-1, ], NA) %>%
setNames(str_c("lagged_", colnames(vic_2014)))
ggplot(bind_cols(vic_2014, lagged), aes(x = Temperature, y = Demand)) +
geom_point(alpha = 0.6, size = 0.7) +
geom_segment(
aes(xend = lagged_Temperature, yend = lagged_Demand),
size = .4, alpha = 0.5
)
cor(vic_2014$Temperature, vic_2014$Demand)
[1] 0.2797854
recent_production <- aus_production %>%
filter(year(Quarter) > 2000)
gg_lag(recent_production, Beer, geom = "point")
Indeed, we can confirm this by looking at the original data.
ggplot(as_tsibble(a10), aes(x = time(index), y = value)) +
geom_line()
acf_data <- ACF(as_tsibble(a10), lag_max = 100)
autoplot(acf_data)