Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

StickBreakingFunction

The Stick Breaking Function


Description

Computes probabilities based on stick breaking construction.

Usage

stick_breaking(z, log = 0)

Arguments

z

vector argument.

log

logical; if TRUE, weights are returned on the log scale.

Details

The stick breaking function produces a vector of probabilities that add up to one, based on a series of individual probabilities in z, which define the breaking points relative to the remaining stick length. The first element of z determines the first probability based on breaking a proportion z[1] from a stick of length one. The second element of z determines the second probability based on breaking a proportion z[2] from the remaining stick (of length 1-z[1]), and so forth. Each element of z should be in (0,1). The returned vector has length equal to the length of z plus 1. If z[k] is equal to 1 for any k, then the returned vector has length smaller than z. If one of the components is smaller than 0 or greater than 1, NaNs are returned.

Author(s)

Claudia Wehrhahn

References

Sethuraman, J. (1994). A constructive definition of Dirichlet priors. Statistica Sinica, 639-650.

Examples

z <- rbeta(5, 1, 1)
stick_breaking(z)

## Not run: 
cstick_breaking <- compileNimble(stick_breaking)
cstick_breaking(z)

## End(Not run)

nimble

MCMC, Particle Filtering, and Programmable Hierarchical Modeling

v0.11.0
BSD_3_clause + file LICENSE | GPL (>= 2)
Authors
Perry de Valpine [aut], Christopher Paciorek [aut, cre], Daniel Turek [aut], Nick Michaud [aut], Cliff Anderson-Bergman [aut], Fritz Obermeyer [aut], Claudia Wehrhahn Cortes [aut] (Bayesian nonparametrics system), Abel Rodrìguez [aut] (Bayesian nonparametrics system), Duncan Temple Lang [aut] (packaging configuration), Sally Paganin [aut] (reversible jump MCMC), Jagadish Babu [ctb] (code for the compilation system for an early version of NIMBLE), Lauren Ponisio [ctb] (contributions to the cross-validation code), Peter Sujan [ctb] (multivariate t distribution code)
Initial release
2021-04-16

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.