pred_bayesMvLMconjugate {spBPS} | R Documentation |
Predictive sampler for Conjugate Bayesian Multivariate Linear Models
Description
Predictive sampler for Conjugate Bayesian Multivariate Linear Models
Usage
pred_bayesMvLMconjugate(X_new, B_samples, Sigma_samples)
Arguments
X_new |
matrix |
B_samples |
array of posterior sample for |
Sigma_samples |
array of posterior samples for |
Value
Y_pred matrix of posterior mean for response matrix Y predictions
Y_pred_samples array of posterior predictive sample for response matrix Y
Examples
## Generate data
n <- 100
p <- 3
q <- 2
Y <- matrix(rnorm(n*q), nrow = n, ncol = q)
X <- matrix(rnorm(n*p), nrow = n, ncol = p)
## Prior parameters
mu_B <- matrix(0, p, q)
V_B <- diag(10, p)
nu <- 3
Psi <- diag(q)
## Samples from posteriors
n_iter <- 1000
burn_in <- 500
set.seed(1234)
samples <- spBPS::bayesMvLMconjugate(Y, X, mu_B, V_B, nu, Psi, n_iter, burn_in)
## Extract posterior samples
B_samples <- samples$B_samples
Sigma_samples <- samples$Sigma_samples
## Samples from predictive posterior (based posterior samples)
m <- 50
X_new <- matrix(rnorm(m*p), nrow = m, ncol = p)
pred <- spBPS::pred_bayesMvLMconjugate(X_new, B_samples, Sigma_samples)
[Package spBPS version 0.0-4 Index]