hdp_setdata: Assign data to DP nodes in a hdpState object

Description Usage Arguments Value See Also Examples

View source: R/hdp_setdata.R

Description

Assign data to 'heldout' (state is 0) DP nodes in a hdpState object. 'Heldout' DPs are not available for posterior sampling, and will need to be activated (see dp_activate). The posterior sampling process (a Gibbs sampler) is run via hdp_posterior.

Usage

1
hdp_setdata(hdp, dpindex, data)

Arguments

hdp

A hdpState object

dpindex

Indices of the DPs to assign data to (in same order as rows of data)

data

A data.frame or matrix of counts with one row for every sample (same order as dpindex) and one column for every data category.

Value

A hdpState object updated with the new data. See hdpState-class

See Also

hdp_init, hdp_adddp, dp_activate, hdp_posterior

Examples

1
2
3
4
5
6
example_data_hdp
my_hdp <- hdp_init(ppindex=0, cpindex=1, hh=rep(1, 6), alphaa=rep(1, 3), alphab=rep(2, 3))
my_hdp <- hdp_adddp(my_hdp, 2, 1, 2)
my_hdp <- hdp_adddp(my_hdp, 10, c(rep(2, 5), rep(3, 5)), 3)
my_hdp <- hdp_setdata(my_hdp, 4:13, example_data_hdp)
dp(my_hdp)

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