hdp_prior_init: Initialise a HDP structure incorporating prior knowledge

Description Usage Arguments Value See Also Examples

View source: R/hdp_prior_init.R

Description

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).

Usage

1
hdp_prior_init(prior_distn, prior_pseudoc, hh, alphaa, alphab)

Arguments

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.

Value

A hdpState object with one frozen node per prior component. See hdpState-class

See Also

hdp_init

Examples

 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))

nicolaroberts/hdp documentation built on May 23, 2019, 5:09 p.m.