Learn R Programming

DrBats (version 0.1.3)

postdens: Calculate the unnormalized posterior density of the model

Description

Calculate the unnormalized posterior density of the model

Usage

postdens(mcmc.output, Y, D, chain = 1)

Arguments

mcmc.output
an mcmc list as produced by clean.mcmc
Y
the data matrix
D
the number of latent factors
chain
the chain to plot (default = 1)

Value

  • post a vector containing the posterior density at each iteration##' @examples

Examples

Run this code
require(DrBats)
data("toydata")
data("stanfit")
codafit <- coda.obj(stanfit)
Y <- toydata$Y.simul$Y
N = nrow(Y)
D = toydata$wlu$D
P = ncol(Y)
## PCA in the histogram basis
obs <- toydata$X
times <- toydata$t
pca.data <- pca.Deville(obs, times, t.range = c(min(times), max(times)), breaks = 15)
## Post-processing landmark information
rotation <- toydata$wlu$Q # rotation matrix
real.W <- toydata$wlu$W # PCA-determined latent factors
real.B <- t(pca.data$Cp[, 1:(toydata$wlu$D)]) # PCA-determined scores
mcmc.output <- clean.mcmc(N, P, D, codafit, rotation, real.W, real.B)
post <- postdens(mcmc.output, Y, D, chain = 1)

## plot the density
hist(post)

Run the code above in your browser using DataLab