calc_trackInd {LaMa} | R Documentation |
Calculate the index of the first observation of each track based on an ID variable
Description
Function to conveniently calculate the trackInd variable that is needed when fitting a model to longitudinal data with multiple tracks.
Usage
calc_trackInd(ID)
Arguments
ID |
ID variable of track IDs that is of the same length as the data to be analyzed |
Details
Preferably, this function should not be used inside the likelihood function, as it may slow down the computation speed. Instead, it can be called once and the result can then be passed as an argument to the likelihood function.
Value
A vector of indices of the first observation of each track which can be passed to the forward and forward_g to sum likelihood contributions of each track
Examples
uniqueID = c("Animal1", "Animal2", "Animal3")
ID = rep(uniqueID, c(100, 200, 300))
trackInd = calc_trackInd(ID)
[Package LaMa version 1.0.0 Index]