int.approx: Approximation of a Cox likelihood intergral

View source: R/helpers.R

int.approxR Documentation

Approximation of a Cox likelihood intergral

Description

The function approximates the integral \int_0^t exp(u B(s) \alpha) ds) which appears in the (full) Cox likelihood if the covariate u has a time-varying effect \beta(t), which is expanded in B-splines, i.e. \beta(t) = B(t) \alpha.

Usage

int.approx(z,time.grid,B,nbasis,alpha)

Arguments

z

a vector which contains at the first component a time point up to which it should be integrated and the covariates u in the remaining components.

time.grid

an equally-spaced time grid on which the B-spline design matrix B has been generated. The maximal value of the time grid should usually be the maximal upper integral border that is of interest.

B

a B-spline design matrix, which has been created with the function bs.design on the full time grid time.grid.

nbasis

number of basis functions used when the B-spline design matrix B has been generated.

alpha

vector of B-spline coefficients.

Value

The B-spline design matrix is returned.

Author(s)

Andreas Groll groll@math.lmu.de

See Also

pencoxfrail

Examples

## generate time grid and corresponding B-spline design matrix
time.grid <- seq(0,200,by=1)
B <- bs.design(x=time.grid, xl=min(time.grid), xr=max(time.grid), spline.degree=3, nbasis=5)

## specify spline coefficients and covariate vector (with upper integral bound as first component)
alpha <- c(0.1,0.2,0.05,0.1,0.15)
z <- c(time=100,age=25)

## calculate intergal from 0 to 100
int.approx(z=z,time.grid=time.grid,B=B,nbasis=5,alpha=alpha)

PenCoxFrail documentation built on Sept. 11, 2024, 7:12 p.m.