BPS_weights: Compute the BPS weights by convex optimization

View source: R/RcppExports.R

BPS_weightsR Documentation

Compute the BPS weights by convex optimization

Description

Compute the BPS weights by convex optimization

Usage

BPS_weights(data, priors, coords, hyperpar, K)

Arguments

data

list two elements: first named Y, second named X

priors

list priors: named \mu_b,V_b,a,b

coords

matrix sample coordinates for X and Y

hyperpar

list two elemets: first named \delta, second named \phi

K

integer number of folds

Value

matrix posterior predictive density evaluations (each columns represent a different model)

Examples

## Generate subsets of data
n <- 100
p <- 3
X <- matrix(rnorm(n*p), nrow = n, ncol = p)
Y <- matrix(rnorm(n), nrow = n)
crd <- matrix(runif(n*2), nrow = n, ncol = 2)

## Select competitive set of values for hyperparameters
delta_seq <- c(0.1, 0.2, 0.3)
phi_seq <- c(3, 4, 5)

## Perform Bayesian Predictive Stacking within subsets
bps <- spBPS::BPS_weights(data = list(Y = Y, X = X),
                               priors = list(mu_b = matrix(rep(0, p)),
                                             V_b = diag(10, p),
                                             a = 2,
                                             b = 2), coords = crd,
                                             hyperpar = list(delta = delta_seq,
                                                             phi = phi_seq),
                                             K = 5)


spBPS documentation built on Oct. 25, 2024, 5:07 p.m.