# NOT RUN {
library(dplyr)
library(ggplot2)
library(lvplot)
# Search for granularities
smart_meter10 %>%
search_gran(highest_unit = "week")
# Screen harmonies from the search list
# }
# NOT RUN {
smart_meter10 %>%
harmony(
ugran = "day",
filter_in = "wknd_wday"
)
# }
# NOT RUN {
# visualize probability distribution of
# the harmony pair (wknd_wday, hour_day)
smart_meter10 %>%
dplyr::filter(customer_id == "10017936") %>%
prob_plot(
gran1 = "wknd_wday",
gran2 = "hour_day",
response = "general_supply_kwh",
plot_type = "quantile",
quantile_prob = c(0.1, 0.25, 0.5, 0.75, 0.9)
) +
scale_y_sqrt()
#' # Compute granularities for non-temporal data
library(tsibble)
cricket_tsibble <- cricket %>%
mutate(data_index = row_number()) %>%
as_tsibble(index = data_index)
hierarchy_model <- tibble::tibble(
units = c("index", "over", "inning", "match"),
convert_fct = c(1, 20, 2, 1)
)
cricket_tsibble %>%
create_gran(
"over_inning",
hierarchy_model
)
cricket_tsibble %>%
filter(batting_team %in% c("Mumbai Indians",
"Chennai Super Kings"))%>%
prob_plot("inning", "over",
hierarchy_model,
response = "runs_per_over",
plot_type = "lv")
# Validate if given column in the data set
# equals computed granularity
validate_gran(cricket_tsibble,
gran = "over_inning",
hierarchy_tbl = hierarchy_model,
validate_col = "over"
)
# }
Run the code above in your browser using DataLab