update_weights: Updating the weights of base models

Description Usage Arguments Note See Also Examples

Description

Update the weights of base models of a ADE-class or DETS-class ensemble. This is accomplished by using computing the loss of the base models in new recent observations.

Usage

1
2
3
4
5
6
7
update_weights(object, newdata)

## S4 method for signature 'ADE'
update_weights(object, newdata)

## S4 method for signature 'DETS'
update_weights(object, newdata)

Arguments

object

a ADE-class or DETS-class model object;

newdata

new data used to update the most recent observations of the time series. At prediction time these observations are used to compute the weights of the base models

Note

Updating the weights of an ensemble is only necessary between different calls of the functions predict or forecast. Otherwise, if consecutive know observations are predicted (e.g. a validation/test set) the updating is automatically done internally.

See Also

update_weights for the weight updating method for an ADE model, and update_weights for the same method for a DETS model

Other updating models: update_ade_meta(), update_ade()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
data("water_consumption")
dataset <- embed_timeseries(water_consumption, 5)

# toy size for checks
train <- dataset[1:300,]
test <- dataset[301:305, ]

specs <- model_specs(c("bm_ppr","bm_glm","bm_mars"), NULL)
## same with model <- DETS(target ~., train, specs)
model <- ADE(target ~., train, specs)

# if consecutive know observations are predicted (e.g. a validation/test set)
# the updating is automatically done internally.
predictions1 <- predict(model, test)@y_hat

# otherwise, the models need to be updated
predictions <- numeric(nrow(test))
# predict new data and update the weights of the model
for (i in seq_along(predictions)) {
  predictions[i] <- predict(model, test[i, ])@y_hat

  model <- update_weights(model, test[i, ])
}

#all.equal(predictions1, predictions)

tsensembler documentation built on Oct. 27, 2020, 5:07 p.m.