weighted_model | R Documentation |
Constructs a weighted consensus model formed as a weighted average of a set of models. The consensus model combines the input models according to their respective weights.
weighted_model(
fits,
names = 1:length(fits),
weights = rep(1/length(fits), length(fits))
)
fits |
A list of model fits to be combined. |
names |
An optional list of names, one per model fit (default: numeric indices). |
weights |
A vector of weights, one per model fit, that sum up to 1 (default: equal weights for all models). |
An object of class weighted_model
, containing the list of model fits, their names, and the assigned weights. The object is also assigned a class 'list'.
# Create two sample model fits
fit1 <- list(model = "model1", y = c(0, 1), fit = "fit1")
fit2 <- list(model = "model2", y = c(1, 0), fit = "fit2")
# Combine the model fits into a weighted consensus model
w_model <- weighted_model(fits = list(fit1, fit2), names = c("model1", "model2"), weights = c(0.6, 0.4))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.