Description Usage Arguments Value Examples
View source: R/LDA_helper_functions.R
Pulls model results for the estimates of bin proportions per movement variable from the posterior distribution. This can be used for visualization of movement variable distribution for each behavior estimated.
1 | get_behav_hist(dat, nburn, ngibbs, nmaxclust, var.names)
|
dat |
The list object returned by the LDA model
( |
nburn |
numeric. The length of the burn-in phase. |
ngibbs |
numeric. The total number of iterations of the MCMC chain. |
nmaxclust |
numeric. The maximum number of clusters on which to attribute behaviors. |
var.names |
character. A vector of names used for each of the movement
variables. Must be in the same order as were listed within the data frame
returned by |
A data frame that contains columns for bin number, behavioral state,
proportion represented by a given bin, and movement variable name. This is
displayed in a long format, which is easier to visualize using
ggplot2
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #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)
#run function for clustered segments
behav.res<- get_behav_hist(dat = res, nburn = 500, ngibbs = 1000, nmaxclust = 7,
var.names = c("Step Length","Turning Angle"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.