plot.bHP: Plot method for class 'bHP'

View source: R/plot.bHP.R

plot.bHPR Documentation

Plot method for class bHP

Description

plot method for a bHP object

Usage

## S3 method for class 'bHP'
plot(
  x,
  plot_type = "dynamic",
  interval_t = 0.3,
  ylab = "",
  col_raw = "#2D5375",
  col_trend_h = "#FBB545",
  col_trend_f = "red",
  col_pvalue_BIC = "red",
  raw_alpha = 255,
  trend_h_alpha = 75,
  trend_f_alpha = 255,
  pvalue_BIC_alpha = 255,
  legend_location = "upleft",
  iteration_location = "downright",
  cex_text = 1.7,
  cex_legend = 1.5,
  main = paste0("Figure of ", x$stopping, " bHP (", plot_type, ")")
)

Arguments

x

an object of class bHP

plot_type

a character string specifies the style of plot.'static' for static figure, 'JS' for plotly.js, a web-based interactive charting library, 'dynamic' for dynamic figure showing history of iterated process.

interval_t

a positive number to set the time interval of the animation (unit in seconds); default to be 0.3.

ylab

a title for the y axis: see 'title' in package 'graphics'.

col_raw

A specification for the default plotting color of raw data. See section ‘Color Specification’.

col_trend_h

A specification for the default plotting color of trend history. See section ‘Color Specification’.

col_trend_f

A specification for the default plotting color of final trend component. See section ‘Color Specification’.

col_pvalue_BIC

A specification for the default plotting color of p-value of BIC. See section ‘Color Specification’.

raw_alpha

a numeric vector from 0 to 255 modifying color transparency of plotting raw data. The smaller the number, the more transparent.

trend_h_alpha

a numeric vector from 0 to 255 modifying color transparency of plotting trend history. The smaller the number, the more transparent.

trend_f_alpha

a numeric vector from 0 to 255 modifying color transparency of plotting final trend component. The smaller the number, the more transparent.

pvalue_BIC_alpha

a numeric vector from 0 to 255 modifying color transparency of plotting p-value or BIC. The smaller the number, the more transparent.

legend_location

a character string or a pair of numeric vector specifying the location of legend. The choice set of the character sting are: upleft, downleft, upright, downright.

iteration_location

a character string or a pair of numeric vector specifying the location of 'iteration time'. The choice set of the character sting are: upleft, downleft, upright, downright.

cex_text

The magnification to be used for showing 'iteration time' relative to the current setting of cex.

cex_legend

The magnification to be used for legend relative to the current setting of cex.

main

an overall title for the plot: see 'title' in package 'graphics'.

Value

X-Y Plotting method for class 'bHP'

Examples


lam <- 100 # tuning parameter for the annual data

## Not run: 
data(IRE) # load the data 'IRE'

# raw HP filter
bx_HP <- BoostedHP(IRE, lambda = lam, iter= FALSE)

# by BIC
bx_BIC <- BoostedHP(IRE, lambda = lam, iter= TRUE, stopping = "BIC")

# by ADF
bx_ADF <- BoostedHP(IRE, lambda = lam, iter= TRUE, stopping = "adf")

# by nonstop test type
# Iterated HP filter until Max_Iter and keep the path of BIC.

bx_nonstop <- BoostedHP(IRE, lambda = lam, iter= TRUE, stopping = "nonstop")

#--------- start to plot the content of bHP -----------------


#--------- for dynamic style (default)--------
plot(bx_ADF)

plot(bx_ADF, iteration_location = "upright") # change the location of text

plot(bx_ADF, iteration_location = c(30,12)) # assign the location of text by x-y co-ordinates

plot(bx_BIC, interval_t = 0.8 ) # change the time interval of animation

plot(bx_nonstop, cex_legend = 2, cex_text = 3) # change the magnification of legend and text

# change the color
plot(bx_ADF,main = "dynamic graph with new color",col_raw = "#685F74", col_trend_h = "#39A1A8", col_trend_f = "#DD4B4F", col_pvalue_BIC = "#E96145")

# change the transparency
plot(bx_ADF,main = "dynamic graph with new transparency setting",raw_alpha = 200, trend_h_alpha = 55, trend_f_alpha = 250, pvalue_BIC_alpha = 250)

# Note: 'nonstop' bHP doesn't have dynamic figure
plot(bx_HP)
# Error in plot.bHP(bx_HP) :
#'nonstop-iter' bHP doesn't have dynamic picture: returning NA

#--------- for JS style ----------

plot(bx_ADF,plot_type = "JS")

# change the color
plot(bx_ADF,plot_type = "JS",main = "Js graph with new color", col_raw = "#685F74", col_trend_f = "#DD4B4F", col_pvalue_BIC = "#39A1A8")

plot(bx_BIC,plot_type = "JS")

plot(bx_nonstop,plot_type = "JS")

plot(bx_HP,plot_type = "JS")

#--------- for static style ----------

plot(bx_ADF,plot_type = "static",cex_legend = 0.7, cex_text = 0.8 )

plot(bx_HP,plot_type = "static")

plot(bx_BIC,plot_type = "static",cex_legend = 0.7, cex_text = 0.8 )

plot(bx_nonstop,plot_type = "static",cex_legend = 0.8, cex_text = 0.8 )

## End(Not run)


chenyang45/BoostedHP documentation built on Nov. 12, 2022, 11:36 a.m.