get_stacking_weights {spStack} | R Documentation |
Optimal stacking weights
Description
Obtains optimal stacking weights given leave-one-out predictive densities for each candidate model.
Usage
get_stacking_weights(log_loopd, solver = "ECOS")
Arguments
log_loopd |
an |
solver |
specifies the solver to use for obtaining optimal weights.
Default is |
Value
A list of length 2.
weights
optimal stacking weights as a numeric vector of length
M
status
solver status, returns
"optimal"
if solver succeeded.
Author(s)
Soumyakanti Pan span18@ucla.edu,
Sudipto Banerjee sudipto@ucla.edu
References
Yao Y, Vehtari A, Simpson D, Gelman A (2018). "Using Stacking to Average Bayesian Predictive Distributions (with Discussion)." Bayesian Analysis, 13(3), 917-1007. doi:10.1214/17-BA1091.
See Also
CVXR::psolve()
, spLMstack()
, spGLMstack()
Examples
set.seed(1234)
data(simGaussian)
dat <- simGaussian[1:100, ]
mod1 <- spLMstack(y ~ x1, data = dat,
coords = as.matrix(dat[, c("s1", "s2")]),
cor.fn = "matern",
params.list = list(phi = c(1.5, 3),
nu = c(0.5, 1),
noise_sp_ratio = c(1)),
n.samples = 1000, loopd.method = "exact",
parallel = FALSE, solver = "ECOS", verbose = TRUE)
loopd_mat <- do.call('cbind', mod1$loopd)
w_hat <- get_stacking_weights(loopd_mat)
print(round(w_hat$weights, 4))
print(w_hat$status)