rbern_constr_v: Random Draws of Bernoulli Variables Subject to Global...

Description Usage Arguments Details Value Examples

Description

rbern_constr_v draws a vector of Bernoulli variables subject to global constraints such as the number of 1's in each draw.

Usage

1
2
rbern_constr_v(x, R, V, z, qweights, pweights, qvote, pvote, adapt, rate, step,
  verbose)

Arguments

x

(required) the vector of probabilities.

R

(required) how many 1's does the the final draw have to have?

V

(required) how many of the first V entries of a draw have the be 1?

z

(required) if z==1 all constrains are obeyed, if z==0 all constraints are not.

qweights

(required) integer numbers. The first weights attached to a draw.

pweights

(required) integer numbers. The second weights attached to a draw.

qvote

(required) the smallest sum of qweights for all entries that are non-zero in a draw before the draw is accepted. If qvote=0 the pweights are ignored.

pvote

(required) the smallest sum of pweights for all entries that are non-zero in a draw before the draw is accepted. If qvote=pvote the pweights are ignored.

adapt

(required) 0 deactivates adaption algorithm 2 in Marbach (2016), 1 enables it.

rate

(required) schedule for the adaption with algorithm 2

step

(required) ε-parameter in algorithm 2

verbose

(required) use 0 for no output; use any positive natural number to report progress at each verbose-th iteration.

Details

The function is part of the Gibbs sampler used for BayesPMP(). The function runs in 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.

Value

vector of draws.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
 ## Not run: 
 # 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)
 
## End(Not run)
 

sumtxt/consilium documentation built on May 30, 2019, 8:38 p.m.