Calculate the index of the first observation of each track based on an ID variable
Calculate the index of the first observation of each track based on an ID variable
Function to conveniently calculate the trackInd variable that is needed internally when fitting a model to longitudinal data with multiple tracks.
calc_trackInd(ID)
Arguments
ID: ID variable of track IDs that is of the same length as the data to be analysed
Returns
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