Description Usage Arguments Details Value Examples
rbern_constr_v
draws a vector of Bernoulli variables subject to global constraints such as
the number of 1's in each draw.
1 2 | rbern_constr_v(x, R, V, z, qweights, pweights, qvote, pvote, adapt, rate, step,
verbose)
|
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 |
z |
(required) if |
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 |
pvote |
(required) the smallest sum of |
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 |
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.
vector
of draws.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.