Description Usage Arguments Value See Also Examples
View source: R/hdp_prior_init.R
Initialise a hdpState object incorporating prior knowlegde of some components (categorical data distributions). The structure has one top parent DP node with no associated data ('active' and available for posterior sampling), and one child DP node per prior component ('frozen' and held out from posterior sampling).
1 | hdp_prior_init(prior_distn, prior_pseudoc, hh, alphaa, alphab)
|
prior_distn |
Matrix of prior distributions (columns must each sum to 1, number of rows matches number of data categories) |
prior_pseudoc |
Vector of pseudocounts contributed by each prior distribution |
hh |
Parameters of the base Dirichlet distribution. Must be a vector with length equal to the number of data item categories. |
alphaa |
Shape hyperparameters for the gamma priors over the DP concentration parameters. |
alphab |
Rate hyperparameters for the gamma priors over the DP concentration parameters. |
A hdpState object with one frozen node per prior component. See hdpState-class
1 2 3 4 5 6 7 8 9 10 11 12 13 | # example dataset with 10 data categories, and 100 samples.
# Two components are known a priori.
hdp <- hdp_prior_init(example_known_priors, rep(1000, 2), hh=rep(1, 10),
alphaa=c(1,1), alphab=c(1,1))
hdp <- hdp_addconparam(hdp, alphaa=c(1,1), alphab=c(1,1))
hdp <- hdp_adddp(hdp, 101, c(1, rep(4, 100)), c(3, rep(4, 100)))
hdp <- hdp_setdata(hdp, 5:104, example_data_hdp_prior)
hdp <- dp_activate(hdp, 4:104, initcc=4, seed=81479)
hdp <- hdp_posterior(hdp, burnin=2000, n=50, space=50, cpiter=3, seed=1e6)
hdp_ex <- hdp_extract_components(hdp)
plot_comp_size(hdp_ex)
plot_comp_distn(hdp_ex)
plot_dp_comp_exposure(hdp_ex, 5:104, col_comp=rainbow(5))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.