time_weights: Compute a normalized weighting vector based on a vector of sampling times.
Description
This function takes a vector of sampling times, \(t = (t_1, t_2, \ldots, t_I)\)
and computes a normalized vector which can be used to weight each sample based on
the time between the subsequent and the preceding samples. The weighting vector \(w\)
is defined such that each entry, \(w_i = d_i / 2T\), where \(T=t_I - t_1\) and
\(d_i = t_{i+1} - t_{i-1}\) for \(i\) not equal to 1 or I. \(d_1 = t_2-t_1\) and \(d_I = t_I-t_{I-1}\).
Usage
time_weights(times, group = NULL)
Value
A numeric vector. Each entry provides a weight for each entry in the
provided times vector. If group is not specified, the vector sums to 1. If
group is specified, the vector sums to the number of distinct groups.
Arguments
times
A numeric vector of sampling times. Each entry must be
greater than the previous entry.
group
Optional; a character vector specifying the group identity of each
sampling time. Use if there are samples from multiple replicates or subjects
in one dataset.