Skip to contents

Estimate and make inference on the overall and component-wise restricted mean times in favor of treatment.

Usage

rmtfit(...)

# Default S3 method
rmtfit(id, time, status, trt, type = "multistate", ...)

# S3 method for class 'formula'
rmtfit(formula, data, ...)

Arguments

...

Further arguments.

id

A vector of id variable.

time

A vector of follow-up times.

status

For type="multistate", k = entering into state \(k\) (\(K+1\) represents death) and 0 = censoring; For type="recurrent", 1 = recurrent event, 2 = death, and 0 = censoring;

trt

A vector of binary variable for treatment group.

type

"multistate" = multistate data; "recurrent" = recurrent event data.

formula

A formula object. For multistate data, use ms(id,time,status)~trt; for recurrent event data, use rec(id,time,status)~trt.

data

A data frame, which contains the variables names in the formula.

Value

An object of class rmtfit. See rmtfit.object for details.

Methods (by class)

  • rmtfit(default): Default

  • rmtfit(formula): Formula

Examples

#######################
# Multistate outcome  #
#######################
# load the colon cancer trial data
library(rmt)
head(colon_lev)
#>   id      time status      rx sex age
#> 1  1 2.6502396      1 Lev+5FU   1  43
#> 2  1 4.1642710      2 Lev+5FU   1  43
#> 3  2 8.4517454      0 Lev+5FU   1  63
#> 4  3 1.4839151      1 Control   0  71
#> 5  3 2.6365503      2 Control   0  71
#> 6  4 0.6707734      1 Lev+5FU   0  66
# fit the data
obj=rmtfit(ms(id,time,status)~rx,data=colon_lev)
# print the event numbers by group
obj
#> Call:
#> rmtfit.formula(formula = ms(id, time, status) ~ rx, data = colon_lev)
#> 
#>           N State 1 Death Med follow-up time
#> Control 315     177   168           5.081451
#> Lev+5FU 304     119   123           5.749487
# summarize the inference results for tau=7.5 years
summary(obj,tau=7.5)
#> Call:
#> rmtfit.formula(formula = ms(id, time, status) ~ rx, data = colon_lev)
#> 
#> Restricted mean winning time by tau = 7.5:
#>           State 1 Survival  Overall
#> Control 0.2659633 1.130967 1.396930
#> Lev+5FU 0.6120146 1.750924 2.362938
#> 
#> Restricted mean time in favor of group "Lev+5FU" by time tau = 7.5:
#>          Estimate  Std.Err Z value  Pr(>|z|)    
#> State 1  0.346051 0.072066  4.8018 1.572e-06 ***
#> Survival 0.619957 0.213610  2.9023  0.003704 ** 
#> Overall  0.966008 0.252585  3.8245  0.000131 ***
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

############################
# Recurrent event outcome  #
############################
# load the HF-ACTION trial data
library(rmt)
head(hfaction)
#>        patid       time status trt_ab age60
#> 1 HFACT00001 0.60506502      1      0     1
#> 2 HFACT00001 1.04859685      0      0     1
#> 3 HFACT00002 0.06297057      1      0     1
#> 4 HFACT00002 0.35865845      1      0     1
#> 5 HFACT00002 0.39698836      1      0     1
#> 6 HFACT00002 3.83299110      0      0     1
# fit the data
obj=rmtfit(rec(patid,time,status)~trt_ab,data=hfaction)
# print the event numbers by group
obj
#> Call:
#> rmtfit.formula(formula = rec(patid, time, status) ~ trt_ab, data = hfaction)
#> 
#>     N Event 1 Event 2 Event 3 Event 4 Event 5 Event 6 Event 7 Event 8 Event 9
#> 0 221     170     117      86      56      33      23      15      13      13
#> 1 205     145      89      55      43      32      21      15      11       7
#>   Event 10 Event 11 Event 12 Event 13 Event 14 Event 15 Event 16 Event 17
#> 0       11        7        6        6        5        3        2        2
#> 1        5        4        3        2        2        2        2        2
#>   Event 18 Event 19 Event 20 Event 21 Event 22 Event 23 Event 24 Event 25
#> 0        2        1        0        0        0        0        0        0
#> 1        2        2        1        1        1        1        1        1
#>   Event 26 Death Med follow-up time
#> 0        0    57           2.390144
#> 1        1    36           2.302533
# summarize the inference results for tau=3.5 years
summary(obj,tau=3.5,Kmax=4) # aggregating results for recurrent-event
#> Call:
#> rmtfit.formula(formula = rec(patid, time, status) ~ trt_ab, data = hfaction)
#> 
#> Restricted mean winning time by tau = 3.5:
#>     Event 1   Event 2    Event 3    Event 4    Event 5    Event 6    Event 7
#> 0 0.2461459 0.1797341 0.07400189 0.05705096 0.06778913 0.03229824 0.02901336
#> 1 0.2606647 0.2246581 0.18911776 0.07928876 0.05043218 0.04036515 0.01434557
#>      Event 8    Event 9    Event 10    Event 11    Event 12     Event 13
#> 0 0.02467620 0.01351584 0.007900133 0.001056981 0.007932054 0.0006445581
#> 1 0.01169075 0.01232759 0.009301100 0.004563094 0.001627585 0.0024747931
#>       Event 14     Event 15     Event 16     Event 17     Event 18     Event 19
#> 0 0.0007787642 0.0003834044 0.0003137311 0.0001010352 0.0001123888 0.0004848228
#> 1 0.0077805017 0.0019915287 0.0007116988 0.0003040931 0.0003580146 0.0001079202
#>       Event 20     Event 21     Event 22     Event 23    Event 24     Event 25
#> 0 0.0001781611 0.0007311137 0.0003162343 0.0005731831 0.001192464 0.0002290646
#> 1 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.000000000 0.0000000000
#>      Event 26  Survival  Overall
#> 0 0.004352256 0.2967478 1.048254
#> 1 0.000000000 0.4958881 1.407999
#> 
#> Restricted mean time in favor of group "1" by time tau = 3.5:
#>           Estimate   Std.Err Z value Pr(>|z|)   
#> Event 1   0.014519  0.047535  0.3054 0.760034   
#> Event 2   0.044924  0.045661  0.9839 0.325185   
#> Event 3   0.115116  0.035992  3.1984 0.001382 **
#> Event 4+ -0.013954  0.049358 -0.2827 0.777403   
#> Survival  0.199140  0.093300  2.1344 0.032810 * 
#> Overall   0.359745  0.154062  2.3351 0.019540 * 
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# frequency >=4.