View source: R/fpredinterval.R
fpredinterval | R Documentation |
Calculate the bootstrap prediction interval for functional singular
spectrum analysis (FSSA) forecasting predictions of univariate functional
time series (funts
) observed over a one-dimensional domain.
fpredinterval(
Y,
O = floor(Y$N * 0.7),
L = floor((Y$N * 0.7)/12),
ntriples = 10,
Bt = 100,
h = 1,
alpha = 0.05,
method = "recurrent",
tol = 10^-3
)
Y |
an object of class |
O |
a positive integer specifying the training set size. |
L |
a positive integer specifying the window length. |
ntriples |
the number of eigentriples to use for forecasts. |
Bt |
a positive integer specifying the number of bootstrap samples. |
h |
an integer specifying the forecast horizon. |
alpha |
a double (0 < alpha < 1) specifying the significance level. |
method |
a character string: "recurrent" or "vector" forecasting. |
tol |
a double specifying tolerated error in the approximation. |
a list of numeric vectors: point forecast, lower, and upper bounds.
## Not run:
data("Callcenter")
pred_interval <- fpredinterval(
Y = Callcenter, O = 310,
L = 28, ntriples = 7, Bt = 10000, h = 3
)
# Plot the forecast and prediction interval using ggplot
df <- data.frame(
x = 1:240,
y = pred_interval$forecast,
lower = pred_interval$lower,
upper = pred_interval$upper
)
require(ggplot2)
# Create the ggplot
ggplot(df, aes(x = x, y = y)) +
geom_line(linewidth = 1.2) +
scale_x_continuous(
name = "Time",
breaks = c(1, 60, 120, 180, 240),
labels = c("00:00", "06:00", "12:00", "18:00", "24:00"),
) +
scale_y_continuous(name = "Sqrt of Call Numbers") +
ggtitle("Prediction Intervals for Jan. 3, 2000") +
geom_ribbon(aes(ymin = lower, ymax = upper), fill = "darkolivegreen3", alpha = 0.3) +
theme_minimal()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.