Package 'NPCox'

Title: Nonparametric and Semiparametric Proportional Hazards Model
Description: An estimation procedure for the analysis of nonparametric proportional hazards model (e.g. h(t) = h0(t)exp(b(t)'Z)), providing estimation of b(t) and its pointwise standard errors, and semiparametric proportional hazards model (e.g. h(t) = h0(t)exp(b(t)'Z1 + c*Z2)), providing estimation of b(t), c and their standard errors. More details can be found in Lu Tian et al. (2005) <doi:10.1198/016214504000000845>.
Authors: Qi Yang [aut, cre], Kuan Yang [aut], Xiaoxuan Liu [ctb], Xinyuan Song [ctb]
Maintainer: Qi Yang <[email protected]>
License: GPL-3
Version: 1.3
Built: 2025-02-12 05:11:10 UTC
Source: https://github.com/cran/NPCox

Help Index


Bandwidth selection function for 'npcox' and 'spcox'.

Description

The embeded bandwidth selection function in 'npcox' and 'spcox' together with prediction error calculation.

Usage

bandselect(cva, delta, obstime, bandwidth = FALSE)

Arguments

cva

Covariate Z in h(t) = h0(t)exp(b(t)'Z)

delta

Right censoring indicator for the model

obstime

The observed time = min(censoring time, observed failure time)

bandwidth

Bandwidth for kernel function, which can be specified. The default value is FALSE and can be selected through least prediction error over all subjects.

Details

This is some description of this function.

'bandwidth_selection' function can provide the prediction error calculation with given bandwidth, or produce the optimal bandwidth based on an arithmetic progression of bandwidths.

Value

Prediction error on given bandwidth or list that contains the optimal bandwidth, an arithmetic progression of bandwidths with corresponding prediction error.

Examples

data(pbc)
dta  = na.omit(pbc[,c('time', 'status', 'age', "edema")])
dta  = dta[dta$time>600 & dta$time<2000,]
dta[,'status'] = sign(dta[,'status'])
colnames(dta) = c('time', 'status', 'age',  "edema")
res = bandselect(cva = dta[,3:4], delta = dta$status, obstime = dta$time, bandwidth = 700)

Nonparametric and semiparametric Cox regression model.

Description

Estimation of proportional hazards (PH) model with time-varying coefficients. Users should anticipate a significant increase in estimation time when using the 'SE = TRUE' option. Both the number of covariates and the sample size can lead to estimation time increasing quadratically.

Usage

npcox(cva, delta, obstime, SE = FALSE, bandwidth = FALSE, resamp = 100)

Arguments

cva

Covariate Z in h(t) = h0(t)exp(b(t)'Z)

delta

Right censoring indicator for the model

obstime

The observed time = min(censoring time, observed failure time)

SE

Whether or not the estimation of standard error through resampling method will be done. The default value is FALSE.

bandwidth

Bandwidth for kernel function, which can be specified. The default value is FALSE and can be selected through least prediction error over all subjects.

resamp

Number of resampling for estimation of pointwise standard error. The default value is 100.

Details

This is some description of this function.

'npcox' function is designed for PH model with time-varying coefficients, h(t) = h0(t)exp(b(t)'Z), providing estimation of b(t) and its pointwise standard errors on [bandwidth, max(obstime)-badwidth].

Value

a list that contain the estimation result of temporal coefficients, standard error estimation, selected or predesigned bandwidth, dataset, unconverged time points.

Examples

data(pbc)
pbc = pbc[(pbc$time < 3000) & (pbc$time > 800), ]
Z   = pbc[,c("age","edema")]
colnames(Z) = c("age","edema")
del = sign(pbc$status)
tim = pbc$time
res = npcox(cva = Z,delta = del, obstime = tim, bandwidth = 500)

Nonparametric and semiparametric Cox regression model.

Description

Plot of time-varying coefficient estimated through function 'npcox' or 'spcox'.

Usage

npplot(temp, xrange = NULL, CIlevel = 0.95)

Arguments

temp

Estimation result from function 'npcox' or 'spcox'.

xrange

Illustration range for x-axis.

CIlevel

The default confidence level stands at 0.95.

Details

This is some description of this function.

This is the plot function for

Value

The plot of nonparametric coefficients function 'npcox' or 'spcox'.

Examples

data(pbc)
pbc = pbc[(pbc$time < 3000) & (pbc$time > 800), ] 
Z   = pbc[,c("age","edema")]
colnames(Z) = c("age","edema")
del = sign(pbc$status)
tim = pbc$time
res = npcox(cva = Z,delta = del, obstime = tim, bandwidth = 500)
op  = par(mfrow = c(1,2))
npplot(res)
par(op)

Simulation data generation of PH model with time-varying coefficients.

Description

An example of data generation for nonparametric PH model.

Usage

npsimu(n, cenpara = NULL)

Arguments

n

The number of sample size, which can be self-determined.

cenpara

Censoring parameter, which is supposed to be positive, for adjustment of censoring rate.

Details

This is some description of this function.

'npsimu' is designed for PH model with time-varying coefficients, h(t) = h0(t)exp(b(t)'Z), generating the covariates, observed time and censoring indicator.

Value

a list that contain covariates, observed time and censoring indicator.

Examples

data = npsimu(200)

Mayo Clinic Primary Biliary Cholangitis Data

Description

Primary biliary cholangitis is an autoimmune disease leading to destruction of the small bile ducts in the liver. Progression is slow but inexhortable, eventually leading to cirrhosis and liver decompensation. The condition has been recognised since at least 1851 and was named "primary biliary cirrhosis" in 1949. Because cirrhosis is a feature only of advanced disease, a change of its name to "primary biliary cholangitis" was proposed by patient advocacy groups in 2014.

This data is from the Mayo Clinic trial in PBC conducted between 1974 and 1984. A total of 424 PBC patients, referred to Mayo Clinic during that ten-year interval, met eligibility criteria for the randomized placebo controlled trial of the drug D-penicillamine. The first 312 cases in the data set participated in the randomized trial and contain largely complete data. The additional 112 cases did not participate in the clinical trial, but consented to have basic measurements recorded and to be followed for survival. Six of those cases were lost to follow-up shortly after diagnosis, so the data here are on an additional 106 cases as well as the 312 randomized participants.

A nearly identical data set found in appendix D of Fleming and Harrington; this version has fewer missing values.

Usage

pbc
data(pbc, package="NPCox")

Format

age: in years
albumin: serum albumin (g/dl)
alk.phos: alkaline phosphotase (U/liter)
ascites: presence of ascites
ast: aspartate aminotransferase, once called SGOT (U/ml)
bili: serum bilirunbin (mg/dl)
chol: serum cholesterol (mg/dl)
copper: urine copper (ug/day)
edema: 0 no edema, 0.5 untreated or successfully treated
1 edema despite diuretic therapy
hepato: presence of hepatomegaly or enlarged liver
id: case number
platelet: platelet count
protime: standardised blood clotting time
sex: m/f
spiders: blood vessel malformations in the skin
stage: histologic stage of disease (needs biopsy)
status: status at endpoint, 0/1/2 for censored, transplant, dead
time: number of days between registration and the earlier of death,
transplantion, or study analysis in July, 1986
trt: 1/2/NA for D-penicillmain, placebo, not randomised
trig: triglycerides (mg/dl)

Source

T Therneau and P Grambsch (2000), Modeling Survival Data: Extending the Cox Model, Springer-Verlag, New York. ISBN: 0-387-98784-3.


Nonparametric and semiparametric Cox regression model.

Description

Estimation of proportional hazards (PH) model with time-varying coefficients and constant coefficients. Users should anticipate a significant increase in estimation time when using the 'SE = TRUE' option. Both the number of covariates and the sample size can lead to estimation time increasing quadratically.

Usage

spcox(
  cva_cons,
  cva_time,
  delta,
  obstime,
  SE = FALSE,
  bandwidth = FALSE,
  resamp = 100
)

Arguments

cva_cons

Covariate Z1 with constant coefficeint c in h(t) = h0(t)exp(c'Z1 + b(t)'Z2)

cva_time

Covariate Z2 with time-varying coefficeint b(t) in h(t) = h0(t)exp(c'Z1 + b(t)'Z2)

delta

Right censoring indicator for the model

obstime

The observed time = min(censoring time, observed failure time)

SE

Whether or not the estimation of standard error through resampling method will be done. The default value is FALSE.

bandwidth

Bandwidth for kernel function, which can be specified. The default value is FALSE and can be selected through least prediction error over all subjects.

resamp

Number of resampling for estimation of pointwise standard error. The default value is 100.

Details

This is some description of this function.

'spcox' is designed for PH model with both time-varying and constant coefficients, h(t) = h0(t)exp(b(t)'Z1 + c*Z2), providing estimation of b(t), c and their standard errors.

Value

a list that contain the estimation result of both temporal and constant coefficients, standard error estimation, selected or predesigned bandwidth, dataset, unconverged time points.

Examples

data(pbc)
pbc = pbc[(pbc$time < 3000) & (pbc$time > 800), ]
Z1  = as.matrix(pbc[,5])
Z2  = as.matrix(pbc[,c('albumin')])
colnames(Z1) = c('age')
colnames(Z2) = c('albumin')
del = sign(pbc$status)
tim = pbc$time
res1 = spcox(cva_cons = Z1, cva_time = Z2, delta = del, obstime = tim, bandwidth = 500)