Learn R Programming

HQM (version 0.1.1)

get_h_xll: Local linear future conditional hazard rate estimator

Description

Calculates the local linear future hazard rate function, conditional on a marker value x, across a set of time values t.

Usage

get_h_xll(data, marker_name, event_time_name, time_name, event_name, x, b)

Value

A vector of \(\hat h_x(t)\) for a grid of possible time values \(t\).

Arguments

data

A data frame of time dependent data points. Missing values are allowed.

marker_name

The column name of the marker values in the data frame data.

event_time_name

The column name of the event times in the data frame data.

time_name

The column name of the times the marker values were observed in the data frame data.

event_name

The column name of the events in the data frame data.

x

Numeric value of the last observed marker value.

b

Bandwidth parameter.

Details

The function get_h_xll implements the local linear future conditional hazard estimator $$\hat{h}_x(t) = \frac{\sum_{i=1}^n \int_0^T\hat{\alpha}_i(X_i(t+s))Z_i(t+s)Z_i(s)K_{b}(x-X_i(s))\mathrm {d}s}{\sum_{i=1}^n\int_0^TZ_i(t+s)Z_i(s)K_{b}(x-X_i(s))\mathrm {d}s},$$ across a grid of possible time values \(t\), where \(X\) is the marker, \(Z\) is the exposure and \(\alpha(z)\) is the marker-only hazard, see get_alpha for more details.

See Also

get_alpha, h_xt

Examples

Run this code
library(survival)
b = 10
x = 3
Landmark <- 2
pbcT1 <- pbc2[which(pbc2$year< Landmark  & pbc2$years> Landmark),]
b=0.9

arg1ll<-get_h_xll(pbcT1, 'albumin', event_time_name = 'years', time_name = 'year',
                  event_name = 'status2', 2, 0.9) 
arg1lc<-get_h_x(pbcT1, 'albumin', event_time_name = 'years', time_name = 'year',
                event_name = 'status2', 2, 0.9) 

#Caclulate the local contant and local linear survival functions
br_s  = seq(Landmark, 14,  length=99)
sfalb2ll<- make_sf(    (br_s[2]-br_s[1])/4 , arg1ll)
sfalb2lc<- make_sf(    (br_s[2]-br_s[1])/4 , arg1lc)

#For comparison, also calculate the Kaplan-Meier
kma2<- survfit(Surv(years , status2) ~ 1, data = pbcT1)

#Plot the survival functions:
plot(br_s, sfalb2ll,  type="l", col=1, lwd=2, ylab="Survival probability", xlab="Marker level")
lines(br_s, sfalb2lc,  lty=2, lwd=2, col=2)
lines(kma2$time, kma2$surv, type="s",  lty=2, lwd=2, col=3)

legend("topright", c(  "Local linear HQM", "Local constant HQM", "Kaplan-Meier"), 
        lty=c(1, 2, 2), col=1:3, lwd=2, cex=1.7)

Run the code above in your browser using DataLab