Description Usage Arguments Value Examples
View source: R/LDA_helper_functions.R
Calculates the mean of the posterior for the proportions of each behavior within track segments. These results can be explored to determine the optimal number of latent behavioral states.
1 | extract_prop(res, ngibbs, nburn, nmaxclust)
|
res |
A list of results returned by |
ngibbs |
numeric. The total number of iterations of the MCMC chain. |
nburn |
numeric. The length of the burn-in phase. |
nmaxclust |
numeric. A single number indicating the maximum number of clusters to test. |
A matrix that stores the proportions of each state/cluster (columns) per track segment (rows).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #load data
data(tracks.seg)
#select only id, tseg, SL, and TA columns
tracks.seg2<- tracks.seg[,c("id","tseg","SL","TA")]
#summarize data by track segment
obs<- summarize_tsegs(dat = tracks.seg2, nbins = c(5,8))
#cluster data with LDA
res<- cluster_segments(dat = obs, gamma1 = 0.1, alpha = 0.1, ngibbs = 1000,
nburn = 500, nmaxclust = 7, ndata.types = 2)
#Extract proportions of behaviors per track segment
theta.estim<- extract_prop(res = res, ngibbs = 1000, nburn = 500, nmaxclust = 7)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.