cl_agg  R Documentation 
This function aggregates S parameter draws that have been clustered into S_cl clusters by averaging across the draws that belong to the same cluster. This averaging can be done in a weighted fashion.
cl_agg( draws, cl = seq_len(nrow(draws)), wdraws = rep(1, nrow(draws)), eps_wdraws = 0 )
draws 
An S x P matrix of parameter draws, with P denoting the number of parameters. 
cl 
A numeric vector of length S, giving the cluster indices for
the draws. Draws that should be dropped (e.g., by thinning) need to have an

wdraws 
A numeric vector of length S, giving the weights of the
draws. It doesn't matter whether these are normalized (i.e., sum to 
eps_wdraws 
A positive numeric value (typically small) which will be
used to improve numerical stability: The weights of the draws within each
cluster are multiplied by 
An S_cl x P matrix of aggregated parameter draws.
set.seed(323) S < 100L P < 3L draws < matrix(rnorm(S * P), nrow = S, ncol = P) # Clustering example: S_cl < 10L cl_draws < sample.int(S_cl, size = S, replace = TRUE) draws_cl < cl_agg(draws, cl = cl_draws) # Clustering example with nonconstant `wdraws`: w_draws < rgamma(S, shape = 4) draws_cl < cl_agg(draws, cl = cl_draws, wdraws = w_draws) # Thinning example (implying constant `wdraws`): S_th < 50L idxs_thin < round(seq(1, S, length.out = S_th)) th_draws < rep(NA, S) th_draws[idxs_thin] < seq_len(S_th) draws_th < cl_agg(draws, cl = th_draws)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.