Description Usage Arguments Value Examples
View source: R/gibbs_sampler.R
This is the main function of the package.
It runs the proposed Gibbs sampler
for a desired number of iterations, for a given vector of counts.
It generates a convex polytope at each iteration, in the form
of a matrix "eta".
Below the number of categories is denoted by K,
and corresponds to the length of the input vector 'counts'.
Each category k has count N_k, possibly equal to zero.
The zeros are removed from the counts when performing the Gibbs iterations,
and "added back" using extend_us
.
1 | gibbs_sampler(niterations, counts)
|
niterations |
a number of iterations to perform;
each iteration is a full sweep of Gibbs updates for each category.
For help on choosing the number of iterations to perform,
see the function |
counts |
a vector of non-negative integers containing the count data; its length defines K, the number of categories. It can include zeros. |
A list with the following entries:
"etas": an array of dimension niterations x K x K. For iteration 'iteration', etasiteration,, is a K x K matrix representing a convex polytope. The feasible set at that iteration, is the set of all vectors theta such that, theta_l/theta_k < etasiteration,k,l for all k,l in 1,...,K.
"Us": a list of K arrays. For iteration 'iteration', and category 'k' in 1,...,K, if N_k = 0 then Us[k] is NA. If N_k > 0 then Us[k]iteration,, is a matrix with N_k rows, and K columns, representing the auxiliary variables "U"'s generated at that iteration.
1 2 3 4 5 | ## Not run:
gibbs_results <- gibbs_sampler(niterations = 5, counts = c(1,2,0,3))
gibbs_results$etas[5,,]
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.