Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

BGweights

Bates-Granger model weights


Description

Computes empirical weights based on out of sample forecast variances, following Bates and Granger (1969).

Usage

BGWeights(object, ..., data, force.update = FALSE)

Arguments

object, ...

two or more fitted glm objects, or a list of such, or an "averaging" object.

data

a data frame containing the variables in the model.

force.update

if TRUE, the much less efficient method of updating glm function will be used rather than directly via glm.fit. This only applies to glms, in case of other model types update is always used.

Details

Bates-Granger model weights are calculated using prediction covariance. To get the estimate of prediction covariance, the models are fitted to randomly selected half of data and prediction is done on the remaining half. These predictions are then used to compute the variance-covariance between models, Σ. Model weights are then calculated as w_BG = (1' Σ⁻¹ 1)⁻¹ 1 Σ⁻¹ , where 1 a vector of 1-s.

Bates-Granger model weights may be outside of the [0,1] range, which may cause the averaged variances to be negative. Apparently this method works best when data is large.

Value

The function returns a numeric vector of model weights.

Note

For matrix inversion, ginv from package MASS is more stable near singularities than solve. It will be used as a fallback if solve fails and MASS is available.

Author(s)

Carsten Dormann, Kamil Bartoń

References

Bates, J. M. & Granger, C. W. J. (1969) The combination of forecasts. Journal of the Operational Research Society, 20: 451-468.

See Also

Examples

fm <- glm(Prop ~ mortality + dose, family = binomial, Beetle, na.action = na.fail)
models <- lapply(dredge(fm, evaluate = FALSE), eval)
ma <- model.avg(models)

# this produces warnings because of negative variances:
set.seed(78)
Weights(ma) <- BGWeights(ma, data = Beetle)
coefTable(ma, full = TRUE)

# SE for prediction is not reliable if some or none of coefficient's SE
# are available
predict(ma, data = test.data, se.fit = TRUE)
coefTable(ma, full = TRUE)

MuMIn

Multi-Model Inference

v1.43.17
GPL-2
Authors
Kamil Bartoń
Initial release
2020-04-14

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.