extract_prop: Extract behavior proportion estimates for each track segment

Description Usage Arguments Value Examples

View source: R/LDA_helper_functions.R

Description

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.

Usage

1
extract_prop(res, ngibbs, nburn, nmaxclust)

Arguments

res

A list of results returned by cluster_segments. Element theta stores estimate for behavior proportions for all time segments.

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.

Value

A matrix that stores the proportions of each state/cluster (columns) per track segment (rows).

Examples

 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)

bayesmove documentation built on Oct. 22, 2021, 9:08 a.m.