Description Usage Arguments Value Examples
View source: R/LDA_helper_functions.R
Expand behavior estimates from track segments to observations
1 | expand_behavior(dat, theta.estim, obs, nbehav, behav.names, behav.order)
|
dat |
A data frame of the animal ID, track segment labels, and all other data per observation. Animal ID, date, track segment, and observation number columns must be labeled id, date, tseg, and time1, respectively. |
theta.estim |
A matrix (returned by |
obs |
A data frame summarizing the number of observations within each
bin per movement variable that is returned by
|
nbehav |
numeric. The number of behavioral states that will be retained in 1 to nmaxclust. |
behav.names |
character. A vector of names to label each state (in order). |
behav.order |
numeric. A vector that identifies the order in which the user would like to rearrange the behavioral states. If satisfied with order returned by the LDA model, this still must be specified. |
A new data frame that expands behavior proportions for each
observation within all track segments, including the columns labeled
time1 and date from the original dat
data frame.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #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)
#Create augmented matrix by replicating rows (tsegs) according to obs per tseg
theta.estim.long<- expand_behavior(dat = tracks.seg, theta.estim = theta.estim, obs = obs,
nbehav = 3, behav.names = c("Encamped","ARS","Transit"),
behav.order = c(1,2,3))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.