Two-Stage Randomization for for Competing risks and Survival outcomes

Under two-stage randomization we can estimate the average treatment effect \(E(Y(i,\bar k))\) of treatment regime \((i,\bar k)\).

  • treatment A0=i and
    • for all responses, randomization A1 = (k_1), so treatment k_1
    • response*A1 = (k_1, k_2), so treatment k_1 if response 1, and treatment k_2 if response 2.

The estimator can be agumented in different ways: using the two randomizations and the dynamic censoring augmentatation.

Estimating \(\mu_{i,\bar k} = P(Y(i,\bar k,\epsilon=v) <= t)\), restricted mean \(E( \min(Y(i,\bar k),\tau))\) or years lost \(E( I(\epsilon=v) \cdot (\tau - \min(Y(i,\bar k),\tau)))\) using IPCW weighted estimating equations : \

The solved estimating eqution is \[\begin{align*} \sum_i \frac{I(min(T_i,t) < G_i)}{G_c(min(T_i ,t))} I(T \leq t, \epsilon=1 ) - AUG_0 - AUG_1 + AUG_C - p(i,j)) = 0 \end{align*}\] using the covariates from augmentR0 to augment with \[\begin{align*} AUG_0 = \frac{A_0(i) - \pi_0(i)}{ \pi_0(i)} X_0 \gamma_0 \end{align*}\] and using the covariates from augmentR1 to augment with \[\begin{align*} AUG_1 = \frac{A_0(i)}{\pi_0(i)} \frac{A_1(j) - \pi_1(j)}{ \pi_1(j)} X_1 \gamma_1 \end{align*}\] and censoring augmenting with \[\begin{align*} AUG_C = \int_0^t \gamma_c(s)^T (e(s) - \bar e(s)) \frac{1}{G_c(s) } dM_c(s) \end{align*}\] where \(\gamma_c(s)\) is chosen to minimize the variance given the dynamic covariates specified by augmentC.

  • The treatment’s must be given as factors.
  • Treatment for 2nd randomization may depend on response.
    • Treatment probabilities are estimated by default and uncertainty from this adjusted for.
  • Randomization augmentation for 1’st and 2’nd randomization possible.
  • Censoring model possibly stratified on observed covariates (at time 0).
  • Censoring augmentation done dynamically over time with time-dependent covariates.

Standard errors are estimated using the influence function of all estimators and tests of differences can therefore be computed subsequently.

Data must be given on start,stop,status survival format with

  • one code of status indicating response, that is 2nd randomization
  • other codes defines the outcome of interest
library(mets) 
set.seed(100)

n <- 200
ddf <- mets:::gsim(n,covs=1,null=0,cens=1,ce=1,betac=c(0.3,1))
true <- apply(ddf$TTt<2,2,mean)
true
#> [1] 0.740 0.770 0.395 0.430
datat <- ddf$datat
## set-random response on data, only relevant after status==2 
response <- rbinom(n,1,0.5)
datat$response <- as.factor(response[datat$id]*datat$Count2)
datat$A000 <- as.factor(1)
datat$A111 <- as.factor(1)

bb <- binregTSR(Event(entry,time,status)~+1+cluster(id),datat,time=2,cause=c(1),response.code=2,
        treat.model0=A0.f~+1, treat.model1=A1.f~A0.f,
        augmentR1=~X11+X12+TR, augmentR0=~X01+X02,
        augmentC=~X01+X02+A11t+A12t+X11+X12+TR, cens.model=~strata(A0.f))
bb
#> Simple estimator :
#>                              coef           
#> A0.f=1, response*A1.f=1 0.5913901 0.13861137
#> A0.f=1, response*A1.f=2 0.6240667 0.10605755
#> A0.f=2, response*A1.f=1 0.2446124 0.07925685
#> A0.f=2, response*A1.f=2 0.3897508 0.08252711
#> 
#> First Randomization Augmentation :
#>                              coef           
#> A0.f=1, response*A1.f=1 0.6047560 0.14921165
#> A0.f=1, response*A1.f=2 0.6441681 0.11761310
#> A0.f=2, response*A1.f=1 0.2371433 0.08089305
#> A0.f=2, response*A1.f=2 0.3806609 0.08391961
#> 
#> Second Randomization Augmentation :
#>                              coef           
#> A0.f=1, response*A1.f=1 0.5784696 0.18002763
#> A0.f=1, response*A1.f=2 0.5078635 0.14816954
#> A0.f=2, response*A1.f=1 0.2352898 0.08048304
#> A0.f=2, response*A1.f=2 0.3703686 0.08815050
#> 
#> 1st and 2nd Randomization Augmentation :
#>                              coef           
#> A0.f=1, response*A1.f=1 0.6141209 0.19240265
#> A0.f=1, response*A1.f=2 0.5270450 0.15149921
#> A0.f=2, response*A1.f=1 0.2297845 0.08096617
#> A0.f=2, response*A1.f=2 0.3672756 0.08784395

estimate(coef=bb$riskG$riskG01[,1],vcov=crossprod(bb$riskG.iid$riskG01))
#>                         Estimate Std.Err    2.5%  97.5%   P-value
#> A0.f=1, response*A1.f=1   0.6141 0.19240 0.23702 0.9912 1.414e-03
#> A0.f=1, response*A1.f=2   0.5270 0.15150 0.23011 0.8240 5.035e-04
#> A0.f=2, response*A1.f=1   0.2298 0.08097 0.07109 0.3885 4.539e-03
#> A0.f=2, response*A1.f=2   0.3673 0.08784 0.19510 0.5394 2.902e-05

estimate(coef=bb$riskG$riskG01[,1],vcov=crossprod(bb$riskG.iid$riskG01),f=function(p) c(p[1]/p[2],p[3]/p[4]))
#>                         Estimate Std.Err    2.5% 97.5% P-value
#> A0.f=1, response*A1.f=1   1.1652  0.5435 0.09991 2.231 0.03205
#> A0.f=2, response*A1.f=1   0.6256  0.2573 0.12144 1.130 0.01502
estimate(coef=bb$riskG$riskG01[,1],vcov=crossprod(bb$riskG.iid$riskG01),f=function(p) c(p[1]-p[2],p[3]-p[4]))
#>                         Estimate Std.Err    2.5%   97.5% P-value
#> A0.f=1, response*A1.f=1  0.08708  0.2681 -0.4384 0.61257  0.7454
#> A0.f=2, response*A1.f=1 -0.13749  0.1150 -0.3630 0.08799  0.2320
## 2 levels for each response , fixed weights 
datat$response.f <- as.factor(datat$response)
bb <- binregTSR(Event(entry,time,status)~+1+cluster(id),datat,time=2,cause=c(1),response.code=2,
        treat.model0=A0.f~+1, treat.model1=A1.f~A0.f*response.f,
        augmentR0=~X01+X02, augmentR1=~X11+X12,
        augmentC=~X01+X02+A11t+A12t+X11+X12+TR, cens.model=~strata(A0.f),
        estpr=c(0,0),pi0=0.5,pi1=0.5)
bb
#> Simple estimator :
#>                                  coef           
#> A0.f=1, response.f*A1.f=1,1 0.5386068 0.12844087
#> A0.f=1, response.f*A1.f=2,1 0.5450214 0.12794277
#> A0.f=1, response.f*A1.f=1,2 0.5456221 0.09349913
#> A0.f=1, response.f*A1.f=2,2 0.5520366 0.09093621
#> A0.f=2, response.f*A1.f=1,1 0.2570426 0.08524398
#> A0.f=2, response.f*A1.f=2,1 0.3522177 0.09946394
#> A0.f=2, response.f*A1.f=1,2 0.3600957 0.10342185
#> A0.f=2, response.f*A1.f=2,2 0.4552707 0.11129564
#> 
#> First Randomization Augmentation :
#>                                  coef           
#> A0.f=1, response.f*A1.f=1,1 0.6464138 0.14788853
#> A0.f=1, response.f*A1.f=2,1 0.6524848 0.14783874
#> A0.f=1, response.f*A1.f=1,2 0.6435582 0.09492478
#> A0.f=1, response.f*A1.f=2,2 0.6496292 0.09153841
#> A0.f=2, response.f*A1.f=1,1 0.2213105 0.09350027
#> A0.f=2, response.f*A1.f=2,1 0.3092979 0.10675847
#> A0.f=2, response.f*A1.f=1,2 0.3102643 0.11228693
#> A0.f=2, response.f*A1.f=2,2 0.3982518 0.11851483
#> 
#> Second Randomization Augmentation :
#>                                  coef           
#> A0.f=1, response.f*A1.f=1,1 0.4404540 0.15440522
#> A0.f=1, response.f*A1.f=2,1 0.5847041 0.16921711
#> A0.f=1, response.f*A1.f=1,2 0.5215925 0.11292250
#> A0.f=1, response.f*A1.f=2,2 0.5549930 0.10040415
#> A0.f=2, response.f*A1.f=1,1 0.2647734 0.07944743
#> A0.f=2, response.f*A1.f=2,1 0.3437537 0.09821336
#> A0.f=2, response.f*A1.f=1,2 0.3970266 0.08317368
#> A0.f=2, response.f*A1.f=2,2 0.3995221 0.11567339
#> 
#> 1st and 2nd Randomization Augmentation :
#>                                  coef           
#> A0.f=1, response.f*A1.f=1,1 0.5499140 0.15696306
#> A0.f=1, response.f*A1.f=2,1 0.7049532 0.19047490
#> A0.f=1, response.f*A1.f=1,2 0.6206264 0.11607918
#> A0.f=1, response.f*A1.f=2,2 0.6566749 0.09929892
#> A0.f=2, response.f*A1.f=1,1 0.2303423 0.08548320
#> A0.f=2, response.f*A1.f=2,1 0.3069402 0.10292148
#> A0.f=2, response.f*A1.f=1,2 0.3487837 0.08783732
#> A0.f=2, response.f*A1.f=2,2 0.3563507 0.11928271

## 2 levels for each response ,  estimated treat probabilities
bb <- binregTSR(Event(entry,time,status)~+1+cluster(id),datat,time=2,cause=c(1),response.code=2,
        treat.model0=A0.f~+1, treat.model1=A1.f~A0.f*response.f,
        augmentR0=~X01+X02, augmentR1=~X11+X12,
        augmentC=~X01+X02+A11t+A12t+X11+X12+TR, cens.model=~strata(A0.f),estpr=c(1,1))
bb
#> Simple estimator :
#>                                  coef           
#> A0.f=1, response.f*A1.f=1,1 0.5960606 0.17488200
#> A0.f=1, response.f*A1.f=2,1 0.6241013 0.17440045
#> A0.f=1, response.f*A1.f=1,2 0.5970085 0.09374896
#> A0.f=1, response.f*A1.f=2,2 0.6250491 0.09621393
#> A0.f=2, response.f*A1.f=1,1 0.2511629 0.08214906
#> A0.f=2, response.f*A1.f=2,1 0.2897991 0.07348482
#> A0.f=2, response.f*A1.f=1,2 0.3513307 0.09298624
#> A0.f=2, response.f*A1.f=2,2 0.3899668 0.08400431
#> 
#> First Randomization Augmentation :
#>                                  coef           
#> A0.f=1, response.f*A1.f=1,1 0.6110247 0.18838108
#> A0.f=1, response.f*A1.f=2,1 0.6392858 0.18875912
#> A0.f=1, response.f*A1.f=1,2 0.6144511 0.10254061
#> A0.f=1, response.f*A1.f=2,2 0.6427122 0.10570324
#> A0.f=2, response.f*A1.f=1,1 0.2440860 0.08346801
#> A0.f=2, response.f*A1.f=2,1 0.2831312 0.07506141
#> A0.f=2, response.f*A1.f=1,2 0.3410878 0.09418680
#> A0.f=2, response.f*A1.f=2,2 0.3801331 0.08553880
#> 
#> Second Randomization Augmentation :
#>                                  coef           
#> A0.f=1, response.f*A1.f=1,1 0.4814011 0.17426935
#> A0.f=1, response.f*A1.f=2,1 0.6103501 0.18912497
#> A0.f=1, response.f*A1.f=1,2 0.6070156 0.11378882
#> A0.f=1, response.f*A1.f=2,2 0.6181593 0.09508071
#> A0.f=2, response.f*A1.f=1,1 0.2454093 0.08562583
#> A0.f=2, response.f*A1.f=2,1 0.3061112 0.06782067
#> A0.f=2, response.f*A1.f=1,2 0.3545614 0.09061532
#> A0.f=2, response.f*A1.f=2,2 0.3709128 0.08781320
#> 
#> 1st and 2nd Randomization Augmentation :
#>                                  coef           
#> A0.f=1, response.f*A1.f=1,1 0.5086290 0.18332584
#> A0.f=1, response.f*A1.f=2,1 0.6311793 0.20425552
#> A0.f=1, response.f*A1.f=1,2 0.6250920 0.12136105
#> A0.f=1, response.f*A1.f=2,2 0.6410325 0.10178189
#> A0.f=2, response.f*A1.f=1,1 0.2381002 0.08632006
#> A0.f=2, response.f*A1.f=2,1 0.3018155 0.06857549
#> A0.f=2, response.f*A1.f=1,2 0.3452178 0.09088007
#> A0.f=2, response.f*A1.f=2,2 0.3666639 0.08738161


## 2 and 3 levels for each response , fixed weights 
datat$A1.23.f <- as.numeric(datat$A1.f)
dtable(datat,~A1.23.f+response)
#> 
#>         response   0   1
#> A1.23.f                 
#> 1                116  23
#> 2                120  23
datat <- dtransform(datat,A1.23.f=2+rbinom(nrow(datat),1,0.5),
            Count2==1 & A1.23.f==2 & response==0)
dtable(datat,~A1.23.f+response)
#> 
#>         response   0   1
#> A1.23.f                 
#> 1                116  23
#> 2                111  23
#> 3                  9   0
datat$A1.23.f <- as.factor(datat$A1.23.f)
dtable(datat,~A1.23.f+response|Count2==1)
#> 
#>         response  0  1
#> A1.23.f               
#> 1                17 23
#> 2                10 23
#> 3                 9  0
###
bb <- binregTSR(Event(entry,time,status)~+1+cluster(id),datat,time=2,cause=c(1),response.code=2,
        treat.model0=A0.f~+1, treat.model1=A1.23.f~A0.f*response.f,
        augmentR0=~X01+X02, augmentR1=~X11+X12,
        augmentC=~X01+X02+A11t+A12t+X11+X12+TR, cens.model=~strata(A0.f),
        estpr=c(1,0),pi1=c(0.3,0.5))
bb
#> Simple estimator :
#>                                     coef           
#> A0.f=1, response.f*A1.23.f=1,1 0.6138741 0.14546619
#> A0.f=1, response.f*A1.23.f=2,1 0.6257528 0.14027635
#> A0.f=1, response.f*A1.23.f=3,1 0.5753190 0.13540555
#> A0.f=1, response.f*A1.23.f=1,2 0.6216688 0.10602763
#> A0.f=1, response.f*A1.23.f=2,2 0.6335476 0.09548483
#> A0.f=1, response.f*A1.23.f=3,2 0.5831138 0.08882984
#> A0.f=2, response.f*A1.23.f=1,1 0.2719027 0.09932666
#> A0.f=2, response.f*A1.23.f=2,1 0.2562909 0.08395583
#> A0.f=2, response.f*A1.23.f=3,1 0.3361501 0.11249207
#> A0.f=2, response.f*A1.23.f=1,2 0.3655873 0.11106102
#> A0.f=2, response.f*A1.23.f=2,2 0.3499755 0.09860883
#> A0.f=2, response.f*A1.23.f=3,2 0.4298347 0.11791066
#> 
#> First Randomization Augmentation :
#>                                     coef           
#> A0.f=1, response.f*A1.23.f=1,1 0.6254238 0.15870500
#> A0.f=1, response.f*A1.23.f=2,1 0.6402288 0.15454601
#> A0.f=1, response.f*A1.23.f=3,1 0.5922315 0.14938976
#> A0.f=1, response.f*A1.23.f=1,2 0.6367920 0.11621860
#> A0.f=1, response.f*A1.23.f=2,2 0.6515970 0.10470729
#> A0.f=1, response.f*A1.23.f=3,2 0.6035997 0.09759337
#> A0.f=2, response.f*A1.23.f=1,1 0.2643835 0.10132734
#> A0.f=2, response.f*A1.23.f=2,1 0.2534870 0.08372325
#> A0.f=2, response.f*A1.23.f=3,1 0.3252664 0.11484580
#> A0.f=2, response.f*A1.23.f=1,2 0.3552907 0.11311288
#> A0.f=2, response.f*A1.23.f=2,2 0.3443942 0.09915534
#> A0.f=2, response.f*A1.23.f=3,2 0.4161736 0.11990969
#> 
#> Second Randomization Augmentation :
#>                                     coef           
#> A0.f=1, response.f*A1.23.f=1,1 0.5052801 0.17545930
#> A0.f=1, response.f*A1.23.f=2,1 0.6490684 0.15881690
#> A0.f=1, response.f*A1.23.f=3,1 0.6854636 0.21833075
#> A0.f=1, response.f*A1.23.f=1,2 0.5585969 0.14220646
#> A0.f=1, response.f*A1.23.f=2,2 0.6777914 0.10735131
#> A0.f=1, response.f*A1.23.f=3,2 0.5813296 0.09751519
#> A0.f=2, response.f*A1.23.f=1,1 0.2422917 0.10988029
#> A0.f=2, response.f*A1.23.f=2,1 0.2797783 0.06601642
#> A0.f=2, response.f*A1.23.f=3,1 0.3401244 0.10216861
#> A0.f=2, response.f*A1.23.f=1,2 0.3485496 0.10783283
#> A0.f=2, response.f*A1.23.f=2,2 0.3412911 0.09398459
#> A0.f=2, response.f*A1.23.f=3,2 0.4201655 0.10601190
#> 
#> 1st and 2nd Randomization Augmentation :
#>                                     coef           
#> A0.f=1, response.f*A1.23.f=1,1 0.5364106 0.17539959
#> A0.f=1, response.f*A1.23.f=2,1 0.6790927 0.17741623
#> A0.f=1, response.f*A1.23.f=3,1 0.7120475 0.23374336
#> A0.f=1, response.f*A1.23.f=1,2 0.5848366 0.14466454
#> A0.f=1, response.f*A1.23.f=2,2 0.7002151 0.11773612
#> A0.f=1, response.f*A1.23.f=3,2 0.6093505 0.10260212
#> A0.f=2, response.f*A1.23.f=1,1 0.2325801 0.11079752
#> A0.f=2, response.f*A1.23.f=2,1 0.2794200 0.06590063
#> A0.f=2, response.f*A1.23.f=3,1 0.3304444 0.10321469
#> A0.f=2, response.f*A1.23.f=1,2 0.3371281 0.10787101
#> A0.f=2, response.f*A1.23.f=2,2 0.3408481 0.09407294
#> A0.f=2, response.f*A1.23.f=3,2 0.4097042 0.10540790

## 2 and 3 levels for each response , estimated 
bb <- binregTSR(Event(entry,time,status)~+1+cluster(id),datat,time=2,cause=c(1),response.code=2,
        treat.model0=A0.f~+1, treat.model1=A1.23.f~A0.f*response.f,
        augmentR0=~X01+X02, augmentR1=~X11+X12,
        augmentC=~X01+X02+A11t+A12t+X11+X12+TR, cens.model=~strata(A0.f),estpr=c(1,1))
bb
#> Simple estimator :
#>                                     coef           
#> A0.f=1, response.f*A1.23.f=1,1 0.5960607 0.17488240
#> A0.f=1, response.f*A1.23.f=2,1 0.6694918 0.18436102
#> A0.f=1, response.f*A1.23.f=3,1 0.5787109 0.17389417
#> A0.f=1, response.f*A1.23.f=1,2 0.5970086 0.09374912
#> A0.f=1, response.f*A1.23.f=2,2 0.6704397 0.12466711
#> A0.f=1, response.f*A1.23.f=3,2 0.5796588 0.09175040
#> A0.f=2, response.f*A1.23.f=1,1 0.2511630 0.08214910
#> A0.f=2, response.f*A1.23.f=2,1 0.2466693 0.07985946
#> A0.f=2, response.f*A1.23.f=3,1 0.3390904 0.13291742
#> A0.f=2, response.f*A1.23.f=1,2 0.3513309 0.09298631
#> A0.f=2, response.f*A1.23.f=2,2 0.3468372 0.09363568
#> A0.f=2, response.f*A1.23.f=3,2 0.4392583 0.13816514
#> 
#> First Randomization Augmentation :
#>                                     coef           
#> A0.f=1, response.f*A1.23.f=1,1 0.6110248 0.18838149
#> A0.f=1, response.f*A1.23.f=2,1 0.6824835 0.19886165
#> A0.f=1, response.f*A1.23.f=3,1 0.5960883 0.18774606
#> A0.f=1, response.f*A1.23.f=1,2 0.6144512 0.10254079
#> A0.f=1, response.f*A1.23.f=2,2 0.6859099 0.13389812
#> A0.f=1, response.f*A1.23.f=3,2 0.5995147 0.10050974
#> A0.f=2, response.f*A1.23.f=1,1 0.2440861 0.08346805
#> A0.f=2, response.f*A1.23.f=2,1 0.2436866 0.08028322
#> A0.f=2, response.f*A1.23.f=3,1 0.3282110 0.13608467
#> A0.f=2, response.f*A1.23.f=1,2 0.3410881 0.09418688
#> A0.f=2, response.f*A1.23.f=2,2 0.3406886 0.09477872
#> A0.f=2, response.f*A1.23.f=3,2 0.4252130 0.14126153
#> 
#> Second Randomization Augmentation :
#>                                     coef           
#> A0.f=1, response.f*A1.23.f=1,1 0.4814004 0.17426965
#> A0.f=1, response.f*A1.23.f=2,1 0.6135499 0.17753447
#> A0.f=1, response.f*A1.23.f=3,1 0.6888656 0.25450984
#> A0.f=1, response.f*A1.23.f=1,2 0.6070155 0.11378895
#> A0.f=1, response.f*A1.23.f=2,2 0.6754339 0.10506823
#> A0.f=1, response.f*A1.23.f=3,2 0.5781644 0.09243287
#> A0.f=2, response.f*A1.23.f=1,1 0.2454092 0.08562594
#> A0.f=2, response.f*A1.23.f=2,1 0.2755312 0.06176367
#> A0.f=2, response.f*A1.23.f=3,1 0.3436018 0.10039784
#> A0.f=2, response.f*A1.23.f=1,2 0.3545614 0.09061545
#> A0.f=2, response.f*A1.23.f=2,2 0.3396800 0.09092113
#> A0.f=2, response.f*A1.23.f=3,2 0.4176542 0.11160494
#> 
#> 1st and 2nd Randomization Augmentation :
#>                                     coef           
#> A0.f=1, response.f*A1.23.f=1,1 0.5086283 0.18332613
#> A0.f=1, response.f*A1.23.f=2,1 0.6349396 0.19140558
#> A0.f=1, response.f*A1.23.f=3,1 0.7148045 0.26881972
#> A0.f=1, response.f*A1.23.f=1,2 0.6250918 0.12136117
#> A0.f=1, response.f*A1.23.f=2,2 0.6956879 0.11422414
#> A0.f=1, response.f*A1.23.f=3,2 0.6145399 0.09722634
#> A0.f=2, response.f*A1.23.f=1,1 0.2381001 0.08632018
#> A0.f=2, response.f*A1.23.f=2,1 0.2746787 0.06225545
#> A0.f=2, response.f*A1.23.f=3,1 0.3340444 0.10201691
#> A0.f=2, response.f*A1.23.f=1,2 0.3452178 0.09088021
#> A0.f=2, response.f*A1.23.f=2,2 0.3384473 0.09094019
#> A0.f=2, response.f*A1.23.f=3,2 0.4068396 0.11084657

## 2 and 1 level for each response 
datat$A1.21.f <- as.numeric(datat$A1.f)
dtable(datat,~A1.21.f+response|Count2==1)
#> 
#>         response  0  1
#> A1.21.f               
#> 1                17 23
#> 2                19 23
datat <- dtransform(datat,A1.21.f=1,Count2==1 & response==1)
dtable(datat,~A1.21.f+response|Count2==1)
#> 
#>         response  0  1
#> A1.21.f               
#> 1                17 46
#> 2                19  0
datat$A1.21.f <- as.factor(datat$A1.21.f)
dtable(datat,~A1.21.f+response|Count2==1)
#> 
#>         response  0  1
#> A1.21.f               
#> 1                17 46
#> 2                19  0
bb <- binregTSR(Event(entry,time,status)~+1+cluster(id),datat,time=2,cause=c(1),response.code=2,
        treat.model0=A0.f~+1, treat.model1=A1.21.f~A0.f*response.f,
        augmentR0=~X01+X02, augmentR1=~X11+X12,
        augmentC=~X01+X02+A11t+A12t+X11+X12+TR, cens.model=~strata(A0.f),estpr=c(1,1))
bb
#> Simple estimator :
#>                                     coef           
#> A0.f=1, response.f*A1.21.f=1,1 0.5965662 0.09733539
#> A0.f=1, response.f*A1.21.f=2,1 0.6246068 0.09822505
#> A0.f=2, response.f*A1.21.f=1,1 0.2996312 0.07727063
#> A0.f=2, response.f*A1.21.f=2,1 0.3382673 0.06699693
#> 
#> First Randomization Augmentation :
#>                                     coef           
#> A0.f=1, response.f*A1.21.f=1,1 0.6128521 0.10629676
#> A0.f=1, response.f*A1.21.f=2,1 0.6411132 0.10832312
#> A0.f=2, response.f*A1.21.f=1,1 0.2910224 0.07750644
#> A0.f=2, response.f*A1.21.f=2,1 0.3300676 0.06746375
#> 
#> Second Randomization Augmentation :
#>                                     coef           
#> A0.f=1, response.f*A1.21.f=1,1 0.6051429 0.09770130
#> A0.f=1, response.f*A1.21.f=2,1 0.6483866 0.09264360
#> A0.f=2, response.f*A1.21.f=1,1 0.3025669 0.07788942
#> A0.f=2, response.f*A1.21.f=2,1 0.3325213 0.07135192
#> 
#> 1st and 2nd Randomization Augmentation :
#>                                     coef           
#> A0.f=1, response.f*A1.21.f=1,1 0.6326858 0.10838935
#> A0.f=1, response.f*A1.21.f=2,1 0.6766156 0.10446225
#> A0.f=2, response.f*A1.21.f=1,1 0.2944012 0.07730608
#> A0.f=2, response.f*A1.21.f=2,1 0.3287928 0.07092539

## known weights 
bb <- binregTSR(Event(entry,time,status)~+1+cluster(id),datat,time=2,cause=c(1),response.code=2,
        treat.model0=A0.f~+1, treat.model1=A1.21.f~A0.f*response.f,
        augmentR0=~X01+X02, augmentR1=~X11+X12,
        augmentC=~X01+X02+A11t+A12t+X11+X12+TR, cens.model=~strata(A0.f),estpr=c(1,0),pi1=c(0.5,1))
bb
#> Simple estimator :
#>                                     coef           
#> A0.f=1, response.f*A1.21.f=1,1 0.6023494 0.09968651
#> A0.f=1, response.f*A1.21.f=2,1 0.6094767 0.09708463
#> A0.f=2, response.f*A1.21.f=1,1 0.2805174 0.06945416
#> A0.f=2, response.f*A1.21.f=2,1 0.3670402 0.07983587
#> 
#> First Randomization Augmentation :
#>                                     coef           
#> A0.f=1, response.f*A1.21.f=1,1 0.6178310 0.10889407
#> A0.f=1, response.f*A1.21.f=2,1 0.6267140 0.10667341
#> A0.f=2, response.f*A1.21.f=1,1 0.2722077 0.07020526
#> A0.f=2, response.f*A1.21.f=2,1 0.3586436 0.07971457
#> 
#> Second Randomization Augmentation :
#>                                     coef           
#> A0.f=1, response.f*A1.21.f=1,1 0.6052636 0.10251830
#> A0.f=1, response.f*A1.21.f=2,1 0.6359914 0.09334072
#> A0.f=2, response.f*A1.21.f=1,1 0.3008284 0.06070542
#> A0.f=2, response.f*A1.21.f=2,1 0.3281989 0.09349507
#> 
#> 1st and 2nd Randomization Augmentation :
#>                                     coef           
#> A0.f=1, response.f*A1.21.f=1,1 0.6337891 0.11081838
#> A0.f=1, response.f*A1.21.f=2,1 0.6661916 0.10467515
#> A0.f=2, response.f*A1.21.f=1,1 0.2984575 0.05975394
#> A0.f=2, response.f*A1.21.f=2,1 0.3290272 0.09244601

SessionInfo

sessionInfo()
#> R version 4.3.2 (2023-10-31)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 22.04.3 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so;  LAPACK version 3.10.0
#> 
#> locale:
#>  [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
#>  [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
#>  [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
#> [10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   
#> 
#> time zone: UTC
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] mets_1.3.4     timereg_2.0.5  survival_3.5-7
#> 
#> loaded via a namespace (and not attached):
#>  [1] Matrix_1.6-1.1      future.apply_1.11.1 jsonlite_1.8.8     
#>  [4] compiler_4.3.2      Rcpp_1.0.12         stringr_1.5.1      
#>  [7] parallel_4.3.2      jquerylib_0.1.4     globals_0.16.2     
#> [10] splines_4.3.2       systemfonts_1.0.5   textshaping_0.3.7  
#> [13] yaml_2.3.8          fastmap_1.1.1       lattice_0.21-9     
#> [16] R6_2.5.1            knitr_1.45          future_1.33.1      
#> [19] desc_1.4.3          bslib_0.6.1         rlang_1.1.3        
#> [22] cachem_1.0.8        stringi_1.8.3       xfun_0.42          
#> [25] fs_1.6.3            sass_0.4.8          memoise_2.0.1      
#> [28] cli_3.6.2           pkgdown_2.0.7       magrittr_2.0.3     
#> [31] digest_0.6.34       grid_4.3.2          mvtnorm_1.2-4      
#> [34] lifecycle_1.0.4     lava_1.7.3          vctrs_0.6.5        
#> [37] evaluate_0.23       glue_1.7.0          listenv_0.9.1      
#> [40] numDeriv_2016.8-1.1 codetools_0.2-19    ragg_1.2.7         
#> [43] parallelly_1.37.0   rmarkdown_2.25      purrr_1.0.2        
#> [46] tools_4.3.2         htmltools_0.5.7