# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#' @title cand_dgamma
#' @description The function \code{cand_dgamma} is meant for computing the matrix
#' as the input for the function \code{sample_pos_z} where the family of densities
#' are gamma. See also \code{sample_pos_z}.
#' @param x a vector of values at which the gamma densities are evaluated.
#' @param s a vector of shape parameters.
#' @param r a vector of rate parameters.
#' @return A matrix with (i,j) component equals the j-th gamma density evaluated
#' at x_i.
#' @examples
#' N <- 500
#' alpha <- c(2.928, 2.979, 2.754)
#' beta <- c(0.124, 0.238, 0.045)
#' theta <- rgamma(N, shape=2.6, rate=0.3)
#' d.ordinates <- mydgamma(theta, alpha, beta)
#' @export
cand_dgamma <- function(x, s, r) {
.Call('_bcdd_cand_dgamma', PACKAGE = 'bcdd', x, s, r)
}
#' @title sample_pos_z
#' @description The function \code{sample_pos_z} is used to update/sample the
#' indicators z_1, ..., z_n. The core function is the basic sample function. The
#' component probability equals a density evaluated at the latent variable coexisting
#' with z and a probability that is associated with the (latent) true prior of
#' these component probability.
#' @param K a value that gives the total category that z varies from.
#' @param ord a matrix with (i,j) component equals the prespecified density evaluated
#' at the latent variable coexisting with z_i.
#' @param pvec a vector of probabilities that is associated with the (latent)
#' true prior of these component probability.
#' @return A vector containing the posterior samples z_1,...,z_n.
#' @examples
#' set.seed(123)
#' N <- 500
#' K <- 3
#' alpha <- c(2.928, 2.979, 2.754)
#' beta <- c(0.124, 0.238, 0.045)
#' p <- c(0.069, 0.758, 0.173)
#' theta <- rgamma(N, shape=2.6, rate=0.3)
#' d.ordinates <- matrix(0, nrow=N, ncol=K)
#' for(jj in 1:K){
#' d.ordinates[,jj] <- dgamma(theta, shape=alpha[jj], rate=beta[jj])
#' }
#' z <- sample_pos_z(1:K, d.ordinates, p)
#' @export
sample_pos_z <- function(K, ord, pvec) {
.Call('_bcdd_sample_pos_z', PACKAGE = 'bcdd', K, ord, pvec)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.