graphmaker: Linear graph construction function

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/graphmaker.R

Description

The function makes a standard linear graph using the provided actuals and forecasts.

Usage

1
2
3
graphmaker(actuals, forecast, fitted = NULL, lower = NULL,
  upper = NULL, level = NULL, legend = TRUE, cumulative = FALSE,
  vline = TRUE, parReset = TRUE, ...)

Arguments

actuals

The vector of actual values

forecast

The vector of forecasts. Should be ts object that starts at the end of fitted values.

fitted

The vector of fitted values.

lower

The vector of lower bound values of a prediction interval. Should be ts object that start at the end of fitted values.

upper

The vector of upper bound values of a prediction interval. Should be ts object that start at the end of fitted values.

level

The width of the prediction interval.

legend

If TRUE, the legend is drawn.

cumulative

If TRUE, then the forecast is treated as cumulative and value per period is plotted.

vline

Whether to draw the vertical line, splitting the in-sample and the holdout sample.

parReset

Whether to reset par() after plotting things or not. If FALSE then you can add elements to the plot (e.g. additional lines).

...

Other parameters passed to plot() function.

Details

Function uses the provided data to construct a linear graph. It is strongly advised to use ts objects to define the start of each of the vectors. Otherwise the data may be plotted incorrectly.

Value

Function does not return anything.

Author(s)

Ivan Svetunkov

See Also

ts

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
x <- rnorm(100,0,1)
values <- forecast(arima(x),h=10,level=0.95)

graphmaker(x,values$mean,fitted(values))
graphmaker(x,values$mean,fitted(values),legend=FALSE)
graphmaker(x,values$mean,fitted(values),values$lower,values$upper,level=0.95)
graphmaker(x,values$mean,fitted(values),values$lower,values$upper,level=0.95,legend=FALSE)

# Produce the necessary ts objects from an arbitrary vectors
actuals <- ts(c(1:10), start=c(2000,1), frequency=4)
forecast <- ts(c(11:15),start=end(actuals)[1]+end(actuals)[2]*deltat(actuals),
               frequency=frequency(actuals))
graphmaker(actuals,forecast)

# This should work as well
graphmaker(c(1:10),c(11:15))

# This way you can add additional elements to the plot
graphmaker(c(1:10),c(11:15), parReset=FALSE)
points(c(1:15))
# But don't forget to do dev.off() in order to reset the plotting area afterwards

greybox documentation built on Dec. 11, 2019, 1:08 a.m.