Learn R Programming

cbass (version 0.1)

pred.cbass: Generate chain of latent normal random variables for a given X, for values saved in 'mod'

Description

Generate chain of latent normal random variables for a given X, for values saved in 'mod'

Usage

pred.cbass(mod, X, nburn = 0, nsub = NULL)

Value

An array of latent variables, nsub by nrow(X) by d

Arguments

mod

CBASS model list

X

matrix of covariates of same size / makeup as that used to create mod. If matrix not scaled to the unit interval, then it will be

nburn

Number of samples to burn from the chain in mod, default 0

nsub

Number of samples to subset to, default to those stored in mod

Examples

Run this code
set.seed(1)
n <- 100;  d <- 3
X <- matrix(runif(n*2, 0, 1), ncol=2)
mu <- scale(X)
bound <- qnorm(1/d^(1/(d-1)))
mu <- cbind(bound, mu)
z <- mu
z[,-1] <- rnorm(length(mu[,-1]), mu[,-1], 1)
y <- apply(z, 1, which.max)
mod <- fit.cbass(X, y, max.int=1, max.basis=10, nmcmc=1e3, nburn=500, nthin=10)
pred.chain <- pred.cbass(mod, X)
mu.hat <- apply(pred.chain, 2:3, mean)
round(p.mu(mu.hat[1,]), 3)

Run the code above in your browser using DataLab