lin_interpolate {HQM} | R Documentation |
Linear interpolation
Description
Implements a linear interpolation between observered marker values.
Usage
lin_interpolate(t, i, data_id, data_marker, data_time)
Arguments
t |
A vector of time values where the function should be evaluated. |
i |
A vector of ids of individuals for whom the marker values should be interpolated. |
data_id |
The vector of ids from a data frame of time dependent variables. |
data_marker |
The vector of marker values from a data frame of time dependent variables. |
data_time |
The vector of time values from a data frame of time dependent variables. |
Details
Given time points and marker values
at different time points
, the function calculates a linear interpolation
with
at the time points
for all indicated individuals. Returned are then
. Note that the first value is always observed at time point
and the function
is extrapolated constantly after the last observed marker value.
Value
A matrix with columns as described above for every individual in the vector
i
.
Examples
size_s_grid <- 100
X = pbc2$serBilir
s = pbc2$year
br_s = seq(0, max(s), max(s)/( size_s_grid-1))
pbc2_id = to_id(pbc2)
X_lin = lin_interpolate(br_s, pbc2_id$id, pbc2$id, X, s)