PlotMC.event: A plot function for time series events

View source: R/PlotMC.analysis.R

PlotMC.eventR Documentation

A plot function for time series events

Description

This is an internal function invoked by MC.analysis function to generate an event plot of the time series under analysis. A event means a time series with length lower to one month i.e. sub-montly time series.

Usage

PlotMC.event(summ, summ1, obs, det.var, det.var1, namePlot, ylab, ylab1, ntick, qUpper)

Arguments

summ

A data.frame with n observations of m variables as is provided by the output of function MC.summary.agg for the first variable to be plotted.

summ1

A data.frame with n observations of m variables as is provided by the output of function MC.summary.agg for the second variable to be plotted.

obs

A numeric value equal to 0. used for internal use.

det.var

A character string defining the name of the first variable from summ object to be plotted.

det.var1

A character string defining the name of the second variable from summ object to be plotted.

namePlot

A character string defining the name of the plot. The file created with the plot has this name.

ylab

A character string to define the label of the axes y for the first variable sub-plot.

ylab1

A character string to define the label of the axes y for the second variable sub-plot.

ntick

A numeric value integer which defines the number of tick marks in the axis x of the sub-plots.

qUpper

A character string that defines the upper percentile to plot the confidence band of results, several options are possible "q999" the 99.9th percentile, "q995" the 99.5th percentile, "q99" the 99th percentile, "q95" the 95th percentile, "q50" the 50th percentile. The lower boundary of the confidence band (showed in gray in the output plots) is the 5th percentile in all cases.

Value

The function creates the plot in the current working directory. The format of the plot is pdf.

Author(s)

J.A. Torres-Matallana

Examples

library(stUPscales)
library(EmiStatR)

# definition of the first summary.agg object
data("P1")
P1 <- P1[1:1100,]

new_data <- matrix(data = NA, nrow = nrow(P1), ncol = 55)
for(i in 1:55){
  new_data[,i] <- matrix(data = rnorm(nrow(P1), 45, 15), 
                         nrow = nrow(P1), ncol = 1)
}
new_data <- t(new_data)

new_summary <- MC.summary(p1 = P1, data = new_data)

# deterministic simulation
det <- rnorm(nrow(P1), 45, 15)
det <- cbind(det, rnorm(nrow(P1), 55, 23))
colnames(det) <- c("det1", "det2")

# level of aggregation
delta <- 60*2 # 2 hours

new_summary_agg <- MC.summary.agg(summ = new_summary, det, delta,
                                  func.agg = mean, func.agg.p = sum)

# definition of the second summary.agg object
new_data1 <- matrix(data = NA, nrow = nrow(P1), ncol = 55)
for(i in 1:55){
  new_data1[,i] <- matrix(data = rnorm(nrow(P1), 55, 23), 
                         nrow = nrow(P1), ncol = 1)
}
new_data1 <- t(new_data1)

new_summary1 <- MC.summary(p1 = P1, data = new_data1)
new_summary_agg1 <- MC.summary.agg(summ = new_summary1, det, delta, 
                                   func.agg = mean, func.agg.p = sum)

## not run
## creating the plot for the event (uncomment to run)
#PlotMC.event(summ = new_summary_agg, summ1 = new_summary_agg1, obs = 0, 
#             det.var = "det1", det.var1 = "det2", namePlot = "ExamplePlot", 
#             ylab = "Variable 1 [units]", ylab1 = "Variable 2 [units]", 
#             ntick=10, qUpper= "q95")
#

stUPscales documentation built on Sept. 18, 2023, 9:07 a.m.