cluster_segments {bayesmove}R Documentation

Cluster time segments into behavioral states

Description

This function performs a Gibbs sampler within the Latent Dirichlet Allocation (LDA) model to estimate proportions of each behavioral state for all time segments generated by segment_behavior. This is the second stage of the two-stage Bayesian model that estimates proportions of behavioral states by first segmenting individual tracks into relatively homogeneous segments of movement.

Usage

cluster_segments(dat, gamma1, alpha, ngibbs, nmaxclust, nburn, ndata.types)

Arguments

dat

A data frame returned by summarize_tsegs that summarizes the counts of observations per bin and movement variable for all animal IDs.

gamma1

numeric. A hyperparameter for the truncated stick-breaking prior for estimating the theta matrix.

alpha

numeric. A hyperparameter for the Dirichlet distribution when estimating the phi matrix.

ngibbs

numeric. The total number of iterations of the MCMC chain.

nmaxclust

numeric. A single number indicating the maximum number of clusters to test.

nburn

numeric. The length of the burn-in phase.

ndata.types

numeric. A vector of the number of bins used to discretize each movement variable. These must be in the same order as the columns within dat.

Details

The LDA model analyzes all animal IDs pooled together, thereby providing population-level estimates of behavioral states.

Value

A list of model results is returned where elements include the phi matrix for each data stream, theta matrix, log likelihood estimates for each iteration of the MCMC chain loglikel, and matrices of the latent cluster estimates for each data stream z.agg.

Examples


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



[Package bayesmove version 0.2.0 Index]