Skip to contents

Out of sample forecast (or simulated out of sample)

Usage

oos_prev(model, date = 28, period = 1, ...)

# S3 method for class 'lm'
oos_prev(model, date = 28, period = 1, data = NULL, ...)

# S3 method for class 'piece_reg'
oos_prev(model, date = 28, period = 1, ...)

# S3 method for class 'tvlm'
oos_prev(
  model,
  date = 28,
  period = 1,
  data_est = NULL,
  fixed_bw = FALSE,
  bw = NULL,
  end = numeric(),
  frequency = 1,
  ...
)

# S3 method for class 'bp_lm'
oos_prev(
  model,
  date = 28,
  period = 1,
  data_est = NULL,
  data,
  fixed_bw = FALSE,
  bw = NULL,
  ...
)

# S3 method for class 'piece_reg'
oos_prev(model, date = 28, period = 1, ...)

Arguments

model

an object used to select a method

date

choose when we want to start the revision process after the start date. By default set to 28 periods.

period

choose by how many values we want to move forward. By default set to 1.

...

other arguments

data

a ts object containing the variables in the model. Necessary only when x is a formula.

data_est, end, frequency

optional arguments to specify the data used to estimate the model, the last date and the frequency

fixed_bw

logical, by default set to FALSE. Indicates if the bandwidth has to be computed again in the forecast model, or if it takes the value of the bandwidth of the tvlm model.

bw

bandwidth of the local regression (when tvlm = TRUE).

Value

oos_prev returns an object of class revision, only for models of class lm and tvlm. For an object of class bplm it returns the same forecasts and residuals as below. An object of class revision is a list containing the following elements:

model

all models used to forecast

debut

same as date chosen earlier

intervalle

same as period chosen earlier

end_dates

a vector of all end date of each models

frequency

the frequency of the data

forecast

the forecast

residuals

the errors of the forecast

Examples

data_gdp <- window(gdp, start = 1980, end = c(2019, 4))
reg_lin <- lm(
  formula = growth_gdp ~ bc_fr_m1 + diff_bc_fr_m1,
  data = data_gdp
)
oos <- oos_prev(reg_lin)