Skip to contents

This function estimates the lower and upper 80% and 95% forecasts of the Model. The final values are within the lower and upper limits of the base data. Used in conjunction with <scaled_logit> and <inv_scaled_logit> functions, they are adapted from Hyndman & Athanasopoulos (2021) and modified for independent use rather than be restricted to be used with a particular package.

Usage

constrainedforecast(Model, lower, upper)

Arguments

Model

This is the exponential values from the invscaledlogit function.

lower

The lower limit of the forecast

upper

The upper limit of the forecast

Value

A list of forecast values within 80% and 95% confidence band. The values are:

Lower 80%

Forecast at lower 80% confidence level.

Upper 80%

Forecast at upper 80% confidence level.

Lower 95%

Forecast at lower 95% confidence level.

Upper 95%

Forecast at upper 95% confidence level.

Examples

library(Dyn4cast)
library(splines)
library(forecast)
lower <- 1
upper <- 37
Model   <- lm(states ~ bs(sequence, knots = c(30, 115)), data = Data)
FitModel <- scaledlogit(x = fitted.values(Model), lower = lower,
 upper = upper)
ForecastModel <- forecast(FitModel, h = length(200))
ForecastValues <- constrainedforecast(Model = ForecastModel, lower, upper)