if (rlang::is_installed("stats")) {
# this example is not a true posterior estimation, but is used for illustration
n <- 32
p <- 10
s <- 21
x <- matrix( stats::rnorm(n*p), nrow = n, ncol = p )
beta <- (1:10)/10
y <- x %*% beta + stats::rnorm(n)
post_beta <- matrix(beta, nrow=p, ncol=s) +
matrix(rnorm(p*s), p, s) # not a true posterior
post_mu <- x %*% post_beta
fit <- WpProj(X=x, eta=post_mu, power = 2.0)
out <- WPR2(predictions = post_mu, projected_model = fit,
base = rowMeans(post_mu) # same as intercept only projection
)
}
Run the code above in your browser using DataLab