R/plot_hierarchical.R
, R/plot_single.R
plot.Rd
Produces a dygraph (see the
online documentation for more detail)
for objects of class persephone.
In case of persephoneSingle
objects,
the function generates an interactive time series plot
of the original series, the seasonally adjusted (SA) series and the trend as
well as one year forecasts with prediction intervals of the original series.
For perHts()
objects, the function plots the original
aggregate series
as well as the directly and indirectly seasonally adjusted aggregate series.
# S3 method for hierarchicalTimeSeries
plot(
x,
main = NULL,
rangeSelector = TRUE,
drawPoints = FALSE,
annualComparison = NULL,
...
)
# S3 method for persephoneSingle
plot(
x,
main = NULL,
forecasts = TRUE,
showOutliers = TRUE,
rangeSelector = TRUE,
drawPoints = FALSE,
annualComparison = NULL,
...
)
an object of class persephone.
plot title
logical flag specifying if a range selector should be included in the plot
logical flag indicating if a small dot should be drawn at each point, in addition to a line going through the point.
integer corresponding to the month or quarter which should be highlighted in the plot for every year.
other plotting parameters to affect the plot. Not currently used.
logical flag indicating if forecasts should be plotted
logical flag specifying if outliers should be highlighted in the plot
Returns an object of class dygraphs
.
If no run has been performed on the persephone object, only the original (aggregate) time series is plotted.
# Plotting hierarchicalTimeSeries objects
# Monthly data
data(AirPassengers, package = "datasets")
# Generate two persephoneSingle objects, in this case two tramoseatsSingle
# objects
tsAir1 <- perTramo(AirPassengers, "RSA1")
tsAir2 <- perTramo(AirPassengers, "RSA1")
# Generate a hierarchicalTimeSeries object
htAir <- perHts(tsAir1=tsAir1, tsAir1=tsAir1)
# Plot before run of persephone object
plot(htAir, drawPoints = TRUE)
htAir$run()
# Plot after run
plot(htAir, drawPoints=TRUE)
# Quarterly data
data(UKgas, package = "datasets")
tsUKgas1 <- perTramo(UKgas, "RSA3")
tsUKgas2 <- perTramo(UKgas, "RSA3")
htUKgas <- perHts(tsUKgas1=tsUKgas1, tsUKgas2=tsUKgas2)
plot(htUKgas)
htUKgas$run()
plot(htUKgas)
# Plotting persephoneSingle objects
# Monthly data
data(AirPassengers, package = "datasets")
# Generate a persephoneSingle object, in this case an x13Single object
obj <- perX13(AirPassengers, "RSA1")
# Plot before run of persephoneSingle object
plot(obj, drawPoints = TRUE)
obj$run()
# Plot after run
plot(obj, drawPoints=TRUE)
#> Error in dySeries(., c("lowerci", "ppm_y_f", "upperci"), label = "Forecasts", strokePattern = "dashed", drawPoints = drawPoints): One or more of the specified series were not found. Valid series names are: y, t, sa, otl[[1]], ppm_y_f, lowerci
# Update some parameters of the persephoneSingle object
# (randomly specify some outliers for illustrative purposes only)
obj$updateParams(usrdef.outliersEnabled = TRUE,
usrdef.outliersType = c("AO","LS","LS"),
usrdef.outliersDate=c("1950-01-01","1955-04-01",
"1959-10-01"))
# Perform run to make updateParams take effect
obj$run()
plot(obj)
# Quarterly data
data(UKgas, package = "datasets")
obj2 <- perX13(UKgas, "RSA3")
plot(obj2)
obj2$run()
plot(obj2)
# Generate a persephoneSingle object, in this case a tramoseatsSingle object
obj3 <- perTramo(UKgas, "RSA3")
plot(obj3)
obj3$run()
plot(obj3)