R/RcppExports.R

# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

check_vprofile <- function(ydraw, V, R, I, qvote, pvote, qweights, pweights) {
    .Call('consilium_check_vprofile', PACKAGE = 'consilium', ydraw, V, R, I, qvote, pvote, qweights, pweights)
}

#' Random Draws of Bernoulli Variables Subject to Global Constraints 
#'
#' \code{rbern_constr_v} draws a vector of Bernoulli variables subject to global constraints such as 
#' the number of 1's in each draw.
#'
#'  
#'
#' @param x (required) the vector of probabilities. 
#' @param R (required) how many 1's does the the final draw have to have? 
#' @param V (required) how many of the first \code{V} entries of a draw have the be 1?
#' @param z (required) if \code{z==1} all constrains are obeyed, if \code{z==0} all constraints are not.
#' @param qweights (required) integer numbers. The first weights attached to a draw. 
#' @param pweights (required) integer numbers. The second weights attached to a draw. 
#' @param qvote (required) the smallest sum of \code{qweights} for all entries that are non-zero 
#'		in a draw before the draw is accepted. If \code{qvote=0} the \code{pweights} are ignored. 	
#' @param pvote (required) the smallest sum of \code{pweights} for all entries that are non-zero 
#'		in a draw before the draw is accepted. If \code{qvote=pvote} the \code{pweights} are ignored. 	
#' @param adapt (required) 0 deactivates adaption algorithm 2 in Marbach (2016), 1 enables it. 
#' @param rate (required) schedule for the adaption with algorithm 2 
#' @param step (required) \eqn{\epsilon}-parameter in algorithm 2 
#' @param verbose (required) use \code{0} for no output; use any positive natural number to report progress at each \code{verbose}-th iteration.
#'
#' @details 
#' The function is part of the Gibbs sampler used for \code{BayesPMP()}. The function runs in \code{C++}.
#' The function draws a random vector of Bernoulli variables and checks the global constraints. 
#' If the draw does not obey the constraints  a new draw is obtained until the constraints are met. 
#' 
#' @return \code{vector} of draws. 
#'  
#' @examples 
#'  \dontrun{
#'  # Can be used to simulate vote choices of 3-member committee that has passed a proposal with majority rule
#'  
#'  # Vote choice probabilities 
#'  p <- c(0.2,0.3,0.4)
#'  R <- 2
#'  V <- 0 
#'  z <- 1 
#'  pweights <- qweights <- rep(1,3)
#'  qvote <- pvote <- 0
#'  adapt <- 1
#'  rate <- 200 
#'  step <- 0.05
#'  verbose <- 0
#'  
#'  rbern_constr_v(x=p, R=R, V=V, z=z, qweights=qweights, pweights=pweights, qvote=qvote, 
#'	   pvote=pvote, adapt=adapt, rate=rate, step=step, verbose=verbose)
#'  }
#'  
#'
#' @export
rbern_constr_v <- function(x, R, V, z, qweights, pweights, qvote, pvote, adapt, rate, step, verbose) {
    .Call('consilium_rbern_constr_v', PACKAGE = 'consilium', x, R, V, z, qweights, pweights, qvote, pvote, adapt, rate, step, verbose)
}

#' @export
consiliumcA <- function(X, y, z, K, Is, J, Rs, Vs, qweights, pweights, qvote, pvote, pslct, qslct, miss, NGIBBS, NTHIN, NBURN, VERBOSE, adapt, rate, step, VERBOSE2, invB0, b0, betastart, omegastart, G, alpha_idx, nG, e0, f0) {
    .Call('consilium_consiliumcA', PACKAGE = 'consilium', X, y, z, K, Is, J, Rs, Vs, qweights, pweights, qvote, pvote, pslct, qslct, miss, NGIBBS, NTHIN, NBURN, VERBOSE, adapt, rate, step, VERBOSE2, invB0, b0, betastart, omegastart, G, alpha_idx, nG, e0, f0)
}

#' @export
consiliumppc <- function(posterior, X, Rs, Vs, Is, qvote, pvote, qweights, pweights, pslct, qslct, J, K, NSAMP, SIM, VERBOSE) {
    .Call('consilium_consiliumppc', PACKAGE = 'consilium', posterior, X, Rs, Vs, Is, qvote, pvote, qweights, pweights, pslct, qslct, J, K, NSAMP, SIM, VERBOSE)
}
sumtxt/consilium documentation built on May 30, 2019, 8:38 p.m.