R/lpmlp.R

Defines functions lpmlp

lpmlp <-
function(y, X, res, nsim, nburn) {
	n <- length(y)
	aux <- matrix(0,nrow=n,ncol=nsim-nburn)
	cpoinv <- numeric(n)

	for(k in 1:(nsim-nburn)) {
		aux[,k] <- dnorm(y, mean = X%*%res[[1]][k+nburn,], sd = sqrt(res[[2]][k+nburn]))
	}
	cpoinv <- apply(aux, 1, function(x) mean(1/x))  
	cpo <- 1/cpoinv
	lpml <- sum(log(cpo))

	res <- list()
	res$cpo <- cpo
	res$lpml <- lpml
	res 
}

Try the AROC package in your browser

Any scripts or data that you put into this service are public.

AROC documentation built on March 18, 2022, 5:22 p.m.