wpd: computes wpd for one harmony or harmony table chooses...

View source: R/wpd.R

wpdR Documentation

computes wpd for one harmony or harmony table chooses compute_pairwise_norm for smaller levels (<=5) chooses compute_pairwise_norm_scalar for higher levels (>5)

Description

computes wpd for one harmony or harmony table chooses compute_pairwise_norm for smaller levels (<=5) chooses compute_pairwise_norm_scalar for higher levels (>5)

Usage

wpd(
  .data,
  harmony_tbl = NULL,
  response = NULL,
  quantile_prob = seq(0.01, 0.99, 0.01),
  dist_ordered = TRUE,
  lambda = 0.67,
  nperm = 20,
  use_perm = TRUE,
  create_harmony_data = TRUE
)

Arguments

.data

a tsibble or data with already computed categories

harmony_tbl

A tibble containing one or more harmonies with facet_variable, x_variable, facet_levels and x_levels

response

the response variable

quantile_prob

numeric vector of probabilities with value in [0,1] whose sample quantiles are wanted. Default is set to percentiles

dist_ordered

if categories are ordered

lambda

value of tuning parameter

nperm

number of permutations for normalization

use_perm

should permutation approach for normalization be used

create_harmony_data

a logical value indicating if data corresponding to harmonies to be created or not

Examples

library(parallel)
library(dplyr)
library(tidyr)
sm <- smart_meter10 %>% dplyr::filter(customer_id %in% c("10006414"))
harmonies <- sm %>%
  harmony(
    ugran = "year",
    filter_in = "wknd_wday",
    filter_out = c("hhour", "fortnight", "quarter", "semester")
  )
all_harmony <- wpd(sm,
  harmony_tbl = harmonies,
  response = general_supply_kwh
)
harmonies1 <- harmonies %>% dplyr::mutate(facet_variable = NA)

h <- harmonies1 %>%
  select(-facet_levels) %>%
  distinct() %>%
  mutate(facet_levels = NA)
all_harmony <- wpd(sm,
  harmony_tbl = h,
  response = general_supply_kwh, nperm = 200, use_perm = TRUE
)

Sayani07/gravitas documentation built on June 18, 2022, 2:40 a.m.