Load data with a discrete surrogate marker. Take a look at first few and last few rows. Note that sob indicates the surrogate marker value, yob is the value of the primary outcome, and aob is the treatment indicator (0 or 1).

data(marker_disc)
head(marker_disc)
##   sob yob aob
## 1   4   1   1
## 2   3   1   0
## 3   4   0   1
## 4   2   0   1
## 5   2   0   0
## 6   6   1   1
tail(marker_disc)
##      sob yob aob
## 995    2   1   0
## 996    3   1   1
## 997    6   1   1
## 998    5   0   1
## 999    5   0   1
## 1000   4   1   1

Run function pte_disc which is the main function for a discrete surrogate marker. You must indicate which variable is the surrogate, primary outcome and treatment, whether standard error estimates are desired (var = TRUE), whether confidence intervals are desired (conf.int=TRUE), and the number of replications to be used for resampling (used to estimate variance and confidence intervals; default is 500).

set.seed(123)
system.time(out <- pte_disc(
  sob = marker_disc$sob, 
  yob = marker_disc$yob, 
  aob = marker_disc$aob, 
  var = TRUE, conf.int = TRUE, rep = 1000))
##    user  system elapsed 
##   9.946   6.713  16.714
out
## [[1]]
##                 est         se      lower      upper
## delta    -0.2001792 0.02971103 -0.2584128 -0.1419456
## delta.gs -0.1074217 0.01549308 -0.1377882 -0.0770553
## pte1      0.5366279 0.07128668  0.3969060  0.6763498
## pte2      0.2993602 0.03030820  0.2399561  0.3587643
## 
## [[2]]
##         est         se     lower     upper
## 1 0.8821713 0.06835341 0.7481986 1.0161439
## 2 0.7657722 0.03888905 0.6895497 0.8419948
## 3 0.5285443 0.03266675 0.4645175 0.5925712
## 4 0.4388855 0.03118164 0.3777695 0.5000016
## 5 0.3735158 0.03567187 0.3035989 0.4434327
## 6 0.4684559 0.06706625 0.3370061 0.5999058

The function outputs estimates (and standard error estimates and confidence intervals if indicated) of \(\Delta\), the true treatment effect; \(\Delta_{g_{opt}(S)}\), the treatment effect on the optimal transformation of the surrogate denoted as \(g_{opt}(S)\); \(PTE_1 =\Delta_{g_{opt}(S)} / \Delta\), a version of the proportion of treatment effect explained quantity based on the ratio between the treatment effect on the optimal transformation of the potential surrogate marker and the treatment effect on the primary outcome; and \(PTE_2\) a version of the proportion of treatment effect explained quantity based on quantifying how well the individual-level treatment effect on the primary outcome can be approximated by the effect on the identified optimal transformation.

Here, the treatment effect is estimated to be -0.20, and the treatment effect on the optimal transformation of the surrogate is estimated to be -0.11. The resulting proportion of treatment effect estimates are 0.54 using \(PTE_1\) and 0.30 using \(PTE_2\). These results indicate that this is a poor surrogate marker in this setting.