#' Removes mean-differences between weekdays
#' @param dates vector of dates of TS
#' @param values vector of values of TS
#' @param type character indicating whether value.ds = (value - bias) or value.ds = (value/bias)
#' @return vector with residuals of auto.arima fit
#' @export
remove_weekday_dummy_fit <- function(dates, values, type = "additive"){
if(type == "additive"){
values.ds <- data.frame(Date = dates, Value = scale(values)) %>% mutate(weekday = wday(Date)) %>% group_by(weekday) %>%
mutate(Value.deseasonalized = scale(Value)) %>% pull(Value.deseasonalized)
return(values.ds*sd(values, na.rm = TRUE) + mean(values, na.rm = TRUE))
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.