subgroupAnalysis: Subgroup Analysis - Interactions and estimates

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

View source: R/subgroupAnalysis.R

Description

The function can examine Cox regression, logistic regression and Poisson regression (Poisson regression for survival analysis) where the effect of one variable is of particular interest. This function systematically checks for effect modification with a list of other variables.

In randomised studies the main regression analysis is often univariate and includes only the exposure of interest. In observational studies the main regression analysis can readily be adjusted for other variables including those which may modify the effect of the variable of interest.

Usage

1
2
subgroupAnalysis(object,data,treatment,
   subgroups, confint.method="default",factor.reference="extraline")

Arguments

object

- glm, coxph or cph object for which subgroups should be analyzed.

data

- Dataset including all relevant variables

treatment

- Must be numeric - 0/1

subgroups

- A vector of variable names presenting the factor variables where subgroups should be formed. These variables should all be "factors"

confint.method

"default" creates Wald type confidence interval, "robust", creates creates robust standard errors - see regressionTable function.

factor.reference

"extraline" creates an extraline for the reference, "inline" avoids this line.

Details

The function can only handle a bivariate treatment, which MUST coded as zero or one. The p-value for interaction is obtained with a likelihood ratio test comparing the main regression analysis with the interaction model.

There are plot and print functions available for the function see helppages for plot.subgroupAnalysis and print.subgroupAnalysis

Value

A data.frame with subsgroup specifications, number in each subgroup, parameter estimates and p-value for interaction. A forest plot can be obtained with "plotConfidence".

Author(s)

Christian Torp-Pedersen

See Also

coxph, glm, plotConfidence

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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#load libraries
library(data.table)
library(Publish)
library(survival)
data(traceR) #get dataframe traceR
data.table::setDT(traceR)
traceR[,':='(wmi2=factor(wallMotionIndex<0.9,levels=c(TRUE,FALSE), 
                labels=c("bad","good")),
             abd2=factor(abdominalCircumference<95, levels=c(TRUE,FALSE), 
                labels=c("slim","fat")))]
traceR[,sex:=as.factor(sex)] # all subgroup variables needs to be factor                
traceR[observationTime==0,observationTime:=1]
# remove missing covariate values
traceR=na.omit(traceR)
# univariate analysis of smoking in subgroups of age and sex
# Main regression analysis is a simple/univariate Cox regression
fit_cox <- coxph(Surv(observationTime,dead)~treatment,data=traceR)
sub_cox <- subgroupAnalysis(fit_cox,traceR,treatment="treatment", 
  subgroups=c("smoking","sex","wmi2","abd2"))
sub_cox

# to see how the results are obtained consider the variable: smoking
fit_cox_smoke <- coxph(Surv(observationTime,dead)~treatment*smoking,data=traceR)
# the last three rows of the following output:
publish(fit_cox_smoke)
# are included in the first 3 rows of the result of the sub group analysis:
sub_cox[1:3,]
# the p-value is obtained as:
fit_cox_smoke_add <- coxph(Surv(observationTime,dead)~treatment+smoking,data=traceR)
anova(fit_cox_smoke_add,fit_cox_smoke,test="Chisq")

# Note that a real subgroup analysis would be to subset the data
fit_cox1a <- coxph(Surv(observationTime,dead)~treatment,data=traceR[smoking=="never"])
fit_cox1b <- coxph(Surv(observationTime,dead)~treatment,data=traceR[smoking=="current"])
fit_cox1c <- coxph(Surv(observationTime,dead)~treatment,data=traceR[smoking=="prior"])


## when the main analysis is already adjusted 
fit_cox_adj <- coxph(Surv(observationTime,dead)~treatment+smoking+sex+wmi2+abd2,
                 data=traceR)
sub_cox_adj <- subgroupAnalysis(fit_cox_adj,traceR,treatment="treatment",
  subgroups=c("smoking","sex","wmi2","abd2")) # subgroups as character string
sub_cox_adj

# When both start and end are in the Surv statement:
traceR[,null:=0]
fit_cox2 <- coxph(Surv(null,observationTime,dead)~treatment+smoking+sex+wmi2+abd2,data=traceR)
summary(regressionTable(fit_cox))
sub_cox2 <- subgroupAnalysis(fit_cox2,traceR,treatment="treatment",
  subgroups=c("smoking","sex","wmi2","abd2")) 
# Analysis with Poisson - and the unrealistic assumption of constant hazard
# and adjusted for age in all subgroups
fit_p <- glm(dead~treatment+age+offset(log(observationTime)),family="poisson",
           data=traceR)
sub_pois <- subgroupAnalysis(fit_p,traceR,treatment="treatment",
  subgroups=~smoking+sex+wmi2+abd2) 
# Analysis with logistic regression - and very wrongly ignoring censoring
fit_log <- glm(dead~treatment+age,family="binomial",data=traceR)
sub_log <- subgroupAnalysis(fit_log,traceR,treatment="treatment",
   subgroups=~smoking+sex+wmi2+abd2, factor.reference="inline")

Example output

Loading required package: prodlim
   subgroups   level sample_placebo sample_trandolapril event_placebo
1:   smoking   never            206                 206           164
2:   smoking   prior            206                 216           166
3:   smoking current            401                 381           274
4:       sex       0            231                 226           182
5:       sex       1            582                 577           422
6:      wmi2     bad            150                 133           137
7:      wmi2    good            663                 670           467
8:      abd2    slim            415                 377           313
9:      abd2     fat            398                 426           291
   event_trandolapril time_placebo time_trandolapril HazardRatio pinteraction
1:                153       380823            411589   0.8719450        0.465
2:                164       335716            438489   0.7875090        0.465
3:                260       866841            887834   0.9365131        0.465
4:                166       405152            458892   0.8207237        0.411
5:                411      1178228           1279020   0.9115126        0.411
6:                122       175054            182457   0.8930333        0.993
7:                455      1408326           1555455   0.8919334        0.993
8:                264       799866            826926   0.8305838        0.292
9:                313       783514            910986   0.9391738        0.292
   subgroup Lower     confint
1:     <NA> 0.700 0.700-1.087
2:     <NA> 0.635 0.635-0.977
3:     <NA> 0.790 0.790-1.110
4:     <NA> 0.665 0.665-1.013
5:     <NA> 0.796 0.796-1.044
6:     <NA> 0.700 0.700-1.140
7:     <NA> 0.784 0.784-1.015
8:     <NA> 0.705 0.705-0.978
9:     <NA> 0.801 0.801-1.102
                                             Variable Units HazardRatio       CI.95   p-value 
          treatment(placebo): smoking(prior vs never)              1.12 [0.91;1.39]   0.29116 
        treatment(placebo): smoking(current vs never)              0.75 [0.62;0.91]   0.00421 
     treatment(trandolapril): smoking(prior vs never)              1.01 [0.81;1.26]   0.89809 
   treatment(trandolapril): smoking(current vs never)              0.81 [0.66;0.99]   0.03823 
   smoking(never): treatment(trandolapril vs placebo)              0.87 [0.70;1.09]   0.22284 
   smoking(prior): treatment(trandolapril vs placebo)              0.79 [0.63;0.98]   0.03013 
 smoking(current): treatment(trandolapril vs placebo)              0.94 [0.79;1.11]   0.44874 
   subgroups   level sample_placebo sample_trandolapril event_placebo
1:   smoking   never            206                 206           164
2:   smoking   prior            206                 216           166
3:   smoking current            401                 381           274
   event_trandolapril time_placebo time_trandolapril HazardRatio pinteraction
1:                153       380823            411589   0.8719450        0.465
2:                164       335716            438489   0.7875090        0.465
3:                260       866841            887834   0.9365131        0.465
   subgroup Lower     confint
1:     <NA> 0.700 0.700-1.087
2:     <NA> 0.635 0.635-0.977
3:     <NA> 0.790 0.790-1.110
Analysis of Deviance Table
 Cox model: response is  Surv(observationTime, dead)
 Model 1: ~ treatment + smoking
 Model 2: ~ treatment * smoking
   loglik  Chisq Df P(>|Chi|)
1 -8083.9                    
2 -8083.1 1.5304  2    0.4652
   subgroups   level sample_placebo sample_trandolapril event_placebo
1:   smoking   never            206                 206           164
2:   smoking   prior            206                 216           166
3:   smoking current            401                 381           274
4:       sex       0            231                 226           182
5:       sex       1            582                 577           422
6:      wmi2     bad            150                 133           137
7:      wmi2    good            663                 670           467
8:      abd2    slim            415                 377           313
9:      abd2     fat            398                 426           291
   event_trandolapril time_placebo time_trandolapril HazardRatio pinteraction
1:                153       380823            411589   0.9030010        0.578
2:                164       335716            438489   0.8044101        0.578
3:                260       866841            887834   0.9293655        0.578
4:                166       405152            458892   0.8737219        0.881
5:                411      1178228           1279020   0.8907051        0.881
6:                122       175054            182457   0.9101620        0.805
7:                455      1408326           1555455   0.8789697        0.805
8:                264       799866            826926   0.8308516        0.289
9:                313       783514            910986   0.9410475        0.289
   subgroup Lower     confint
1:     <NA> 0.724 0.724-1.126
2:     <NA> 0.648 0.648-0.999
3:     <NA> 0.784 0.784-1.101
4:     <NA> 0.707 0.707-1.080
5:     <NA> 0.777 0.777-1.021
6:     <NA> 0.713 0.713-1.162
7:     <NA> 0.772 0.772-1.000
8:     <NA> 0.705 0.705-0.980
9:     <NA> 0.802 0.802-1.104
   Variable        Units HazardRatio       CI.95  p-value
1 treatment      placebo         Ref                     
2           trandolapril        0.88 [0.79;0.99]   0.0358
   Variable        Units HazardRatio       CI.95  p-value
1 treatment      placebo         Ref                     
2           trandolapril        0.88 [0.79;0.99]   0.0358

Publish documentation built on Jan. 8, 2021, 5:37 p.m.