byGroupHR: Calculate Cox regression by groups

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/LOScalcFns.R

Description

Batch calculate all the Cox regressions for each group in turn. Can select which type of hazard ratio to calculate.

Usage

1
byGroupHR(survData.list, naive = T, causespec = T, subdist = T, tofile = FALSE)

Arguments

survData.list

List of survData arrays

naive

Time-independent regression.

causespec

Cause-specific Cox regression.

subdist

Fine & Grey subdistribution Cox regression.

tofile

Should the output be sent to file.

Details

The time-independent regression does not account for time of infection (or generally the timing of an intermediate event); the cause-specific Cox regression considers the competing risks to be censored times and the Fine & Grey subdistribution approach retains the competing risk in the risk set.

Value

For each element in the list returns

timeindnaive

Time-independent model

timedeptcausespec

Time-dependent cause-specific model

timedeptsubdistn

Time-dependent Fine & Grey subdistribution model

Within timeindnaive,

fit.disch

Cox regression results with discharge alive event of interest

fit.dead

Cox regression results with death in-hospital event of interest

fit.both

Cox regression results with combined event of interest

Within timedeptcausespec and timedeptsubdistn

fit.alive.timeonly

Discharge alive as event of interest; only time of infection as covariate

fit.alive.full

Discharge alive as event of interest; time of infection and other risk factors as covariates

fit.dead.timeonly

Death in hospital as event of interest; only time of infection as covariate

fit.dead.full

Death in hospital as event of interest; time of infection and other risk factors as covariates

fit.both.timeonly

Combined event of interest; only time of infection as covariate

fit.both.full

Combined event of interest; time of infection and other risk factors as covariates

Within each of these, coxph return values.

Author(s)

N Green

See Also

hr.naive, hr.tv.causespecific, hr.tv.subdistribution, coxph, byGroupHR.boxplot, HRboxplot.batch

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require(survival)
data(survDataByGender)
foo <- byGroupHR(survDataByGender)
foo$Male$timedeptcausespec$fit.alive.full


## The function is currently defined as
function (survData.list, naive = T, causespec = T, subdist = T, 
    tofile = FALSE) 
{
    startTime <- Sys.time()
    namesGroup <- names(survData.list)
    results <- list()
    progressbar <- txtProgressBar(min = 0, max = length(namesGroup), 
        style = 3)
    counter = 0
    for (i in namesGroup) {
        counter = counter + 1
        setTxtProgressBar(progressbar, counter)
        timeindnaive <- timedeptcausespec <- timedeptsubdistn <- NA
        if (naive == T) {
            timeindnaive = hr.naive(survData.list[[i]])
        }
        if (causespec == T) {
            timedeptcausespec = hr.tv.causespecific(survData.list[[i]])
        }
        if (subdist == T) {
            timedeptsubdistn = hr.tv.subdistribution(survData.list[[i]])
        }
        results[[i]] <- list(timeindnaive = timeindnaive, timedeptcausespec = timedeptcausespec, 
            timedeptsubdistn = timedeptsubdistn)
    }
    close(progressbar)
    cat(Sys.time() - startTime)
    if (tofile == TRUE) {
        sink(".\output\byOrgamismHR.txt")
        results
        sink()
    }
    results
  }

n8thangreen/HESmanip documentation built on March 21, 2020, 12:20 a.m.