R/forestcox.R
TableSubgroupMultiCox.Rd
Multiple sub-group analysis table for Cox/svycox model.
TableSubgroupMultiCox( formula, var_subgroups = NULL, var_cov = NULL, data, time_eventrate = 3 * 365, decimal.hr = 2, decimal.percent = 1, decimal.pvalue = 3, line = F, cluster = NULL, strata = NULL, weights = NULL, event = FALSE, count_by = NULL, labeldata = NULL )
formula | formula with survival analysis. |
---|---|
var_subgroups | Multiple sub-group variables for analysis, Default: NULL |
var_cov | Variables for additional adjust, Default: NULL |
data | Data or svydesign in survey package. |
time_eventrate | Time for kaplan-meier based event rate calculation, Default = 365 * 3 |
decimal.hr | Decimal for hazard ratio, Default: 2 |
decimal.percent | Decimal for percent, Default: 1 |
decimal.pvalue | Decimal for pvalue, Default: 3 |
line | Include new-line between sub-group variables, Default: F |
cluster | Cluster variable for coxph, Default: NULL |
strata | Strata variable for coxph, Default: NULL |
weights | Weights variable for coxph, Default: NULL |
event | Show number and rates of event in survival analysis default:F |
count_by | Select variables to count by subgroup, Default: NULL |
labeldata | Label info, made by `mk.lev` function, Default: NULL |
Multiple sub-group analysis table.
This result is used to make forestplot.
library(survival) library(dplyr) lung %>% mutate( status = as.integer(status == 1), sex = factor(sex), kk = factor(as.integer(pat.karno >= 70)), kk1 = factor(as.integer(pat.karno >= 60)) ) -> lung TableSubgroupMultiCox(Surv(time, status) ~ sex, var_subgroups = c("kk", "kk1"), data = lung, time_eventrate = 100, line = TRUE )#> Warning: Loglik converged before variable 1,2,3 ; coefficient may be infinite.#> Variable Count Percent Point Estimate Lower Upper sex=1 sex=2 P value #> sex Overall 228 100 1.91 1.14 3.2 0 1.2 0.014 #> 1 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> #> 2 kk <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> #> 3 0 38 16.9 2.88 0.31 26.49 0 0 0.35 #> 4 1 187 83.1 1.84 1.08 3.14 0 1.5 0.026 #> 5 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> #> 6 kk1 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> #> 7 0 8 3.6 <NA> <NA> <NA> 0 0 <NA> #> 8 1 217 96.4 1.88 1.12 3.17 0 1.3 0.018 #> P for interaction #> sex <NA> #> 1 <NA> #> 2 0.525 #> 3 <NA> #> 4 <NA> #> 5 <NA> #> 6 0.997 #> 7 <NA> #> 8 <NA>#> Warning: No weights or probabilities supplied, assuming equal probabilityTableSubgroupMultiCox(Surv(time, status) ~ sex, var_subgroups = c("kk", "kk1"), data = data.design, time_eventrate = 100 )#> Independent Sampling design (with replacement) #> svydesign(id = ~1, data = lung) #> Independent Sampling design (with replacement) #> svydesign(id = ~1, data = lung)#>#> Independent Sampling design (with replacement) #> subset(data, get(var_subgroup) == .) #> Independent Sampling design (with replacement) #> subset(data, get(var_subgroup) == .)#> Warning: Loglik converged before variable 1,2,3 ; coefficient may be infinite.#> Independent Sampling design (with replacement) #> svydesign(id = ~1, data = lung)#> Warning: Loglik converged before variable 1,2,3 ; coefficient may be infinite.#>#> Independent Sampling design (with replacement) #> subset(data, get(var_subgroup) == .)#> Variable Count Percent Point Estimate Lower Upper sex=1 sex=2 P value #> sex Overall 228 100 1.91 1.14 3.19 0 1.2 0.013 #> 1 kk <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> #> 2 0 38 16.9 2.88 0.31 27.1 0 0 0.355 #> 3 1 187 83.1 1.84 1.08 3.11 0 2.9 0.024 #> 4 kk1 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> #> 5 0 <NA> <NA> <NA> <NA> <NA> 0 0 <NA> #> 6 1 217 <NA> 1.88 1.12 3.15 0 1.3 0.017 #> P for interaction #> sex <NA> #> 1 0.523 #> 2 <NA> #> 3 <NA> #> 4 <0.001 #> 5 <NA> #> 6 <NA>