surv_calc_scores_stats: surv_calc_scores_stats

Description Usage Arguments Value Examples

View source: R/surv_calc_scores_stats.R

Description

An adaptation of GBJ::calc_scores_stats() to survival context. Wrapper of sGBJ_scores() function.

Usage

1
surv_calc_scores_stats(null_model, factor_matrix, nperm = 300)

Arguments

null_model

An R cox model fitted with survival::coxph().

factor_matrix

An n x p matrix with each factor as one column. There should be no missing data.

nperm

Number of permutations (default is 300)

Value

A list with the elements:

test_stats

The p score test statistics.

cor_mat

The p x p matrix giving the pairwise correlation of every test statistic pairs.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
n <- 100
surv_data <- data.frame(Time = runif(n = n, min = 0, max = 100),
                        event = rbinom(n = n, size = 1, prob = 0.5))
surv <- survival::Surv(time = surv_data$Time, event = surv_data$event)

factor_matrix <- data.frame(P1 = rnorm(n = n),
                             P2 = rnorm(n = n))

covariates <- data.frame(age = runif(n = n, 60, 90))

null_model <- survival::coxph(surv ~ age, data = covariates, x = TRUE)
surv_reg_stats <- surv_calc_scores_stats(null_model = null_model,
                                         factor_matrix = factor_matrix,
                                         nperm = 2)#nperm = 300)

GBJ::GBJ(test_stats=surv_reg_stats$test_stats, cor_mat=surv_reg_stats$cor_mat)

sGBJ documentation built on Sept. 16, 2021, 1:07 a.m.