Learn R Programming

RTL (version 0.1.6)

chart_zscore: chart_zscore

Description

Supports analytics and display of seasonal data. Z-Score is computed on residuals conditional on their seasonal period. Beware that most seasonal charts in industry e.g. (NG Storage) is not detrended so results once you apply an STL decompostion will vary from the unajusted seasonal plot.

Usage

chart_zscore(
  df = df,
  title = "NG Storage Z Score",
  per = "yearweek",
  output = "zscore",
  chart = "seasons"
)

Arguments

df

Long data frame with columns series, date and value

title

Default is a blank space returning the unique value in df$series.

per

Frequency of seasonality "yearweek" (DEFAULT). "yearmonth", "yearquarter"

output

"stl" for STL decomposition chart, "stats" for STL fitted statistics. "res" for STL fitted data. "zscore" for residuals Z-score, "seasonal" for standard seasonal chart.

chart

"seasons" for feasts::gg_season() (DEFAULT) "series" for feasts::gg_subseries()

Value

Time series of STL decomposition residuals Z-Scores, or standard seasonal chart with feast package.

Examples

Run this code
# NOT RUN {
df <- eiaStocks %>% dplyr::filter(series == "NGLower48")
title <- "NGLower48"
chart_zscore(df = df, title = " ",per = "yearweek", output = "stl", chart = "seasons")
chart_zscore(df = df, title = " ",per = "yearweek", output = "stats", chart = "seasons")
chart_zscore(df = df, title = " ",per = "yearweek", output = "res", chart = "seasons")
chart_zscore(df = df, title = " ",per = "yearweek", output = "zscore", chart = "seasons")
chart_zscore(df = df, title = " ",per = "yearweek", output = "seasonal", chart = "seasons")
# }

Run the code above in your browser using DataLab