make_N, make_Ni, make_Y, make_Yi {HQM} | R Documentation |
Occurance and Exposure on grids
Description
Auxiliary functions that help automate the process of calculating integrals with occurances or exposure processes.
Usage
make_N(data, data.id, breaks_X, breaks_s, ss, XX, delta)
make_Ni(breaks_s, size_s_grid, ss, delta, n)
make_Y(data, data.id, X_lin, breaks_X, breaks_s,
size_s_grid, size_X_grid, int_s, int_X, event_time = 'years', n)
make_Yi(data, data.id, X_lin, breaks_X, breaks_s,
size_s_grid, size_X_grid, int_s,int_X, event_time = 'years', n)
Arguments
data |
A data frame of time dependent data points. Missing values are allowed. |
data.id |
An id data frame obtained from |
breaks_X |
Marker value grid points where the function will be evaluated. |
breaks_s |
Time value grid points where the function will be evaluated. |
ss |
Vector with event times. |
XX |
Vector of last observed marker values. |
delta |
0-1 vector of whether events happened. |
size_s_grid |
Size of the time grid. |
size_X_grid |
Size of the marker grid. |
n |
Number of individuals. |
X_lin |
Linear interpolation of observed marker values evaluated on the marker grid. |
int_s |
Position of the observed time values on the time grid. |
int_X |
Position of the linear interpolated marker values on the marker grid. |
event_time |
String of the column name with the event times. |
Details
Implements matrices for the computation of integrals with occurences and exposures of the form
\int f(s)Z(s)Z(s+t)ds, \int f(s) Z(s)ds, \int f(s) dN(s).
where N
is a 0-1 counting process, Z
the exposure and f
an arbitrary function.
Value
The functions make_N
and make_Y
return a matrix on the time grid and marker grid for occurence and exposure, respectively, while make_Ni
and make_Yi
return a matrix on the time grid for evey individual again for occurence and exposure, respectively.
See Also
Examples
pbc2_id = to_id(pbc2)
size_s_grid <- size_X_grid <- 100
n = max(as.numeric(pbc2$id))
s = pbc2$year
X = pbc2$serBilir
XX = pbc2_id$serBilir
ss <- pbc2_id$years
delta <- pbc2_id$status2
br_s = seq(0, max(s), max(s)/( size_s_grid-1))
br_X = seq(min(X), max(X), (max(X)-min(X))/( size_X_grid-1))
X_lin = lin_interpolate(br_s, pbc2_id$id, pbc2$id, X, s)
int_X <- findInterval(X_lin, br_X)
int_s = rep(1:length(br_s), n)
N <- make_N(pbc2, pbc2_id, br_X, br_s, ss, XX, delta)
Y <- make_Y(pbc2, pbc2_id, X_lin, br_X, br_s,
size_s_grid, size_X_grid, int_s, int_X, event_time = 'years', n)
Yi <- make_Yi(pbc2, pbc2_id, X_lin, br_X, br_s,
size_s_grid, size_X_grid, int_s, int_X, event_time = 'years', n)
Ni <- make_Ni(br_s, size_s_grid, ss, delta, n)