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 t_1,...,t_K
and marker values m_1,...,m_J
at different time points t^m_1,...,t^m_J
, the function calculates a linear interpolation f
with f(t^m_i) = m_i
at the time points t_1,...,t_K
for all indicated individuals. Returned are then (f(t_1),...,f(t_K))
. Note that the first value is always observed at time point 0
and the function f
is extrapolated constantly after the last observed marker value.
Value
A matrix with columns (f(t_1),...,f(t_K))
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)