# NOT RUN {
# }
# NOT RUN {
#load original and segmented data
data(tracks)
data(tracks.seg)
#convert segmented dataset into list
tracks.list<- df_to_list(dat = tracks.seg, ind = "id")
#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))
#Run function
dat.out<- assign_behavior(dat.orig = tracks, dat.seg.list = tracks.list,
theta.estim.long = theta.estim.long,
behav.names = c("Encamped","ARS","Transit"))
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab