predict.alm {greybox} | R Documentation |
Forecasting using greybox functions
Description
The functions allow producing forecasts based on the provided model and newdata.
Usage
## S3 method for class 'alm'
predict(object, newdata = NULL, interval = c("none",
"confidence", "prediction"), level = 0.95, side = c("both", "upper",
"lower"), occurrence = NULL, ...)
## S3 method for class 'greybox'
predict(object, newdata = NULL, interval = c("none",
"confidence", "prediction"), level = 0.95, side = c("both", "upper",
"lower"), ...)
## S3 method for class 'scale'
predict(object, newdata = NULL, interval = c("none",
"confidence", "prediction"), level = 0.95, side = c("both", "upper",
"lower"), ...)
## S3 method for class 'greybox'
forecast(object, newdata = NULL, h = NULL, ...)
## S3 method for class 'alm'
forecast(object, newdata = NULL, h = NULL, ...)
Arguments
object |
Time series model for which forecasts are required. |
newdata |
The new data needed in order to produce forecasts. |
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: |
occurrence |
If occurrence was provided, then a user can provide a vector of future values via this variable. |
... |
Other arguments passed to |
h |
The forecast horizon. |
Details
predict
produces predictions for the provided model and newdata
. If
newdata
is not provided, then the data from the model is extracted and the
fitted values are reproduced. This might be useful when confidence / prediction
intervals are needed for the in-sample values.
forecast
function produces forecasts for h
steps ahead. There are four
scenarios in this function:
If the
newdata
is not provided, then it will produce forecasts of the explanatory variables to the horizonh
(usinges
from smooth package or using Naive ifsmooth
is not installed) and use them asnewdata
.If
h
andnewdata
are provided, then the number of rows to use will be regulated byh
.If
h
isNULL
, then it is set equal to the number of rows innewdata
.If both
h
andnewdata
are not provided, then it will use the data from the model itself, reproducing the fitted values.
After forming the newdata
the forecast
function calls for
predict
, so you can provide parameters interval
, level
and
side
in the call for forecast
.
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 ofinterval="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.
forecast()
functions return the same "predict.alm" and
"predict.greybox" classes, with the same set of output variables.
Author(s)
Ivan Svetunkov, ivan@svetunkov.ru
See Also
Examples
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"))
plot(forecast(ourModel,h=10,interval="p"))