Learn R Programming

greybox (version 0.3.3)

predict.alm: Forecasting using greybox functions

Description

predict is a function for predictions from various model fitting functions. The function invokes particular method, corresponding to the class of the first argument.

Usage

# S3 method for alm
predict(object, newdata = NULL, interval = c("none",
  "confidence", "prediction"), level = 0.95, side = c("both", "upper",
  "lower"), ...)

# S3 method for greybox predict(object, newdata = NULL, interval = c("none", "confidence", "prediction"), level = 0.95, side = c("both", "upper", "lower"), ...)

Arguments

object

Time series model for which forecasts are required.

newdata

Forecast horizon

interval

Type of intervals to construct: either "confidence" or "prediction". Can be abbreviated

level

Confidence level. Defines width of prediction interval.

side

What type of interval to produce: "both" - produces both lower and upper bounds of the interval, "upper" - upper only, "lower" - respectively lower only. In the "both" case the probability is split into two parts: ((1-level)/2, (1+level)/2). When "upper" is specified, then the intervals for (0, level) are constructed Finally, with "lower" the interval for (1-level, 1) is returned.

...

Other arguments.

Value

predict.greybox() returns object of class "predict.greybox", which contains:

  • model - the estimated model.

  • mean - the expected values.

  • fitted - fitted values of the model.

  • lower - lower bound of prediction / confidence intervals.

  • upper - upper bound of prediction / confidence intervals.

  • level - confidence level.

  • newdata - the data provided in the call to the function.

  • variances - conditional variance for the holdout sample. In case of interval="prediction" includes variance of the error.

predict.alm() is based on predict.greybox() and returns object of class "predict.alm", which in addition contains:

  • location - the location parameter of the distribution.

  • scale - the scale parameter of the distribution.

  • distribution - name of the fitted distribution.

Details

Although this function is called "forecast", it has functionality similar to "predict" function.

See Also

predict.lm

Examples

Run this code
# NOT RUN {
xreg <- cbind(rlaplace(100,10,3),rnorm(100,50,5))
xreg <- cbind(100+0.5*xreg[,1]-0.75*xreg[,2]+rlaplace(100,0,3),xreg,rnorm(100,300,10))
colnames(xreg) <- c("y","x1","x2","Noise")
inSample <- xreg[1:80,]
outSample <- xreg[-c(1:80),]

ourModel <- alm(y~x1+x2, inSample, distribution="dlaplace")

predict(ourModel,outSample)
predict(ourModel,outSample,interval="c")
plot(predict(ourModel,outSample,interval="p"))

# }

Run the code above in your browser using DataLab