plot_sf_mean: Plot of factor means

View source: R/plot_sf_mean.r

plot_sf_meanR Documentation

Plot of factor means

Description

Generates a plot of the means of factors

Usage

plot_sf_mean(
  this_factor = NULL,
  this_period = NULL,
  this_col = "green",
  y_limit = range(this_factor),
  this_freq,
  this_trans = TRUE,
  this_title = "Mean of Seasonal Factors",
  forecast = 0,
  this_type = "Seasonal",
  add_line = FALSE
)

Arguments

this_factor

tis object of the factors from a weekly seasonal adjustment

this_period

Integer scalar; vector with period number of the observations.

this_col

Character scalar; color used for factor plots. Default is green.

y_limit

Numeric vector of length 2; Range of values you wish the plot to be plotted over. Default is range of the seasonal factors.

this_freq

integer scalar; time series frequency.

this_trans

Logical scalar; indicates if the adjustment was done with a log transform. Default is TRUE.

this_title

Character string; main title of plot. Default is 'Mean of Seasonal Factors'.

forecast

Integer scalar; Number of forecasts appended to the factors. Default is 0.

this_type

Character string; type of factors plotted. Default is 'seasonal'.

add_line

Logical scalar; indicates if this line is being added to an existing plot. Default is FALSE.

Value

Generate plot of the means of factors by period, or add a line to an existing plot. If factors not specified, print out error message and return NULL.

Examples

ic_sf_range <- range(ic_sf, ic_sf_auto, ic_sf_auto_ljung, ic_sf_tc)
this_color <- c("#4682B4", "#7846B4", "#B47846", "#82B446")
plot_sf_mean(ic_sf, 
             this_period = ic_week, 
             this_col = this_color[1], 
             y_limit = ic_sf_range,
             this_freq = 53, 
             this_type = 'Combined', 
             this_trans = FALSE,
             this_title = 'Initial Claims (Weekly Combined Factors)')
plot_sf_mean(ic_sf_auto, 
             this_period = ic_week, 
             this_col = this_color[2], 
             this_freq = 53, 
             this_trans = FALSE,
             add_line = TRUE)
plot_sf_mean(ic_sf_auto_ljung, 
             this_period = ic_week, 
             this_col = this_color[3], 
             this_freq = 53, 
             this_trans = FALSE,
             add_line = TRUE)
plot_sf_mean(ic_sf_tc, 
             this_period = ic_week, 
             this_col = this_color[4], 
             this_freq = 53, 
             this_trans = FALSE,
             add_line = TRUE)
legend('topright', 
       legend=c('ic (default)', 'ic (auto outliers)', 'ic (auto, ljung cv)', 'ic (auto tc)'),
       col=this_color, 
       lty=rep(1,4), 
       cex=0.75)

bcmonsell/airutilities documentation built on May 16, 2022, 3:23 p.m.