bb.plot {bbdetection} | R Documentation |
Plots the log of prices and highlight bear states
Description
This function plots the log of prices and highlights bear states
Usage
bb.plot(price, bull, dates, price.name=NULL, log.scale=TRUE)
Arguments
price |
a numeric vector of price values |
bull |
a logical vector that contains the states of the market. This vector
is returned by function |
dates |
a vector of dates in Date format |
price.name |
the name of the time-series of prices that will appear on the y-axis of the plot |
log.scale |
a logical variable that specifies whether to use log scale along the y-axis |
Value
None
Examples
{
library(zoo)
library(xtable)
library(ggplot2)
price <- as.vector(coredata(sp500m)) # retrieve monthly prices
dates <- index(sp500m) # retrieve dates from zoo-object
setpar_dating_alg(4, 6, 5, 15, 20) # parameters for monthly data
bull <- run_dating_alg(price) # detect bull-bear states
bb.plot(price, bull, dates, "S&P 500") # plot the result
}
[Package bbdetection version 1.0 Index]