recurrentpseudo: An R package for analysing recurrent events in the presence of terminal events using pseudo-observations

Introduction

This package computes pseudo-observations for recurrent event data in the presence of terminal events. Three versions exist: One-dimensional, two-dimensional or three-dimensional pseudo-observations.

Following the computation of pseudo-observations, the marginal mean function, survival probability and/or cumulative incidences can be modelled using generalised estimating equations.

See Furberg et al. (Bivariate pseudo-observations for recurrent event analysis with terminal events (2023)) for technical details on the procedure.

Package and main functions

# Development version

#require(devtools)
#devtools::install_github("JulieKFurberg/recurrentpseudo", force = TRUE)

require(recurrentpseudo)
# Main functions

#?pseudo.onedim
#?pseudo.twodim
#?pseudo.threedim
#?pseudo.geefit

Notation

Let D* denote the survival time and let N*(t) denote the number of recurrent events by time t. Let C denote the time of censoring. Due to right-censoring, the data consists of X = {N(⋅), D, δ, Z} where N(t) = N*(t ∧ C), D = D* ∧ C, δ = I(D* ≤ C) and Z denotes p baseline covariates.

We observe Xi = {Ni(⋅), Di, δi, Zi} for each individual i = 1, …, n.

We consider the marginal mean function, μ(t), given by μ(t) = E(N*(t)) = ∫0tS(u) dR(u),  dR(t) = E(dN*(t) ∣ D* ≥ t) and the survival probability, S(t), given by S(t) = P(D* > t).

Moreover, we consider the cumulative incidences for death causes 1, C1(t), and 2, C2(t) C1(t) = E(I(D* ≤ t, Δ = 1)),  C2(t) = E(I(D* ≤ t, Δ = 2)) where Δ = {1, 2} represents a cause-of-death indicator.

Introduction to pseudo-observations

The following section serves as a fast introduction to pseudo-observations, which the methods of this package is based on.

For more detailed information, please see

  • Andersen and Perme (Pseudo-observations in survival analysis (2010)) or

  • Andersen, Klein and Rosthøj (Generalised linear models for correlated pseudo-observations, with applications to multi-state models (2003))

We wish to formulate a model for θ = E(f(X)) where X = X1, …, Xn denotes a vector of survival times (or other survival data) for n individuals and f denotes some function. An example would be θ = E(I(D* > t)) = P(D* > t).

Assume that a sufficiently nice estimator θ̂ of θ exists. For a fixed time, t ∈ [0, τ], the pseudo-observation for the i’th individual at t is given by θ̂i(t) = n ⋅ θ̂(t) − (n − 1) ⋅ θ̂i(t) where θ̂(t) denotes the estimate based on the total data set, and θ̂i(t) denotes the estimate based on the same data set but omitting observations from individual i.

Since the survival times are subject to right-censoring, standard inference on survival data is adjusted to accommodate this, e.g. in likelihood estimation.

However, since all subjects has a valid pseudo-observation, θ̂i(t), at one or more times, these can be used as an outcome variable in a generalised linear model. Note, that this is regardless of the whether a subject is alive, censored or died at time t.

Assume that g denotes a link function, then we wish to fit

g(E(f(X) ∣ Z)) = ξTZ. Following, f(X) is replaced by θ̂i(⋅) in the model fit.

The model parameters, ξ, are estimated using generalised estimating equations (GEE), see Liang and Zeger (Longitudinal data analysis using generalized linear models (1986)).

The GEE procedure accommodates the fact that each individual can have several (pseudo-)observations.

One-dimensional pseudo-observations

The one-dimensional pseudo-observations model is based on the parameter θ = μ(t), which is estimated by θ̂ = μ̂(t) = ∫0t(u) d(u), where (t) denotes the Kaplan-Meier estimator of S(t) and (t) denotes the Nelson-Aalen estimator of R(t).

We assume that

log (μ(t ∣ Z)) = log (μ0(t)) + βTZ.

Two-dimensional pseudo-observations

The two-dimensional pseudo-observations model is based on the parameter θ = (μ(t), S(t)), which is estimated by $$ \hat{\theta} = \left( \begin{matrix} \hat{\mu}(t) \\ \hat{S}(t) \end{matrix} \right). $$

We assume that $$ \left( \begin{matrix} \log \left(\mu (t \mid Z) \right) \\ \text{cloglog} \left( S( t \mid Z) \right) \end{matrix} \right) = \left( \begin{matrix} \log \left( \mu_0(t) \right) + {\beta}^T {Z} \\ \log \left(\Lambda_0(t)\right) + {\gamma}^T {Z} \end{matrix} \right). $$

Three-dimensional pseudo-observations

The three-dimensional pseudo-observations model is based on the parameter θ = (μ(t), C1(t), C2(t)), which is estimated by $$ \hat{\theta} = \left( \begin{matrix} \hat{\mu}(t) \\ \hat{C}_1(t) \\ \hat{C}_2(t) \end{matrix} \right) $$ where 1(t) and 2(t) are the Aalen-Johansen estimates of the cumulative incidences for causes 1, C1(t), and 2, C2(t), respectively.

We assume that $$ \left( \begin{matrix} \log \left(\mu (t \mid Z) \right) \\ \text{cloglog} \left(1- C_1( t \mid Z) \right) \\ \text{cloglog} \left(1- C_2( t \mid Z) \right) \end{matrix} \right) = \left( \begin{matrix} \log \left( \mu_0(t) \right) + {\beta}^T {Z} \\ \log \left(\Lambda_{10}(t)\right) + {\gamma_1}^T {Z} \\ \log \left(\Lambda_{20}(t)\right) + {\gamma_2}^T {Z} \end{matrix} \right). $$

Example - Bladder cancer data from survival package

The functions in recurrentpseudo will be exemplified using the well-known bladder cancer data from the survival package. This data set considers data from a clinical cancer trial conducted by the Veterans Administration Cooperative Urological Research Group (Byar: The veterans administration study of chemoprophylaxis for recurrent stage I bladder tumours: comparisons of placebo, pyridoxine and topical thiotepa (1980)) Here, 118 patients with stage I bladder cancer were randomised to receive placebo, pyridoxine or thiotepa. After randomisation, information on occurrences of superficial bladder tumours and any deaths were collected.

We focus on the comparison between placebo and thiotepa (n = 86 in total). We model recurrent bladder tumours, and adjust for death (cause 1: bladder cancer disease death, cause 2: other causes).

One-, two- and three-dimensional pseudo-observations are computed based on a single time point, t = 30 months.

For the comparison between placebo and thiotepa on recurrent bladder tumours, the effect measure of interest is the mean ratio exp (β).

# Example: Bladder cancer data from survival package
require(survival)
#> Loading required package: survival

# Make a three level status variable
bladder1$status3 <- ifelse(bladder1$status %in% c(2, 3), 2, bladder1$status)

# Add one extra day for the two patients with start=stop=0
# subset(bladder1, stop <= start)
bladder1[bladder1$id == 1, "stop"] <- 1
bladder1[bladder1$id == 49, "stop"] <- 1

# Restrict the data to placebo and thiotepa
bladdersub <- subset(bladder1, treatment %in% c("placebo", "thiotepa"))

# Make treatment variable two-level factor
bladdersub$Z <- as.factor(ifelse(bladdersub$treatment == "placebo", 0, 1))
levels(bladdersub$Z) <- c("placebo", "thiotepa")
head(bladdersub)
#>   id treatment number size recur start stop status rtumor rsize enum status3
#> 1  1   placebo      1    1     0     0    1      3      .     .    1       2
#> 2  2   placebo      1    3     0     0    1      3      .     .    1       2
#> 3  3   placebo      2    1     0     0    4      0      .     .    1       0
#> 4  4   placebo      1    1     0     0    7      0      .     .    1       0
#> 5  5   placebo      5    1     0     0   10      3      .     .    1       2
#> 6  6   placebo      4    1     1     0    6      1      1     1    1       1
#>         Z
#> 1 placebo
#> 2 placebo
#> 3 placebo
#> 4 placebo
#> 5 placebo
#> 6 placebo

We fit the univariate pseudo-observation model using the binary treatment indicator as covariate, i.e. we model log (μ(t ∣ Z)) = log (μ0(t)) + βZ

One-dimensional pseudo-observations and GEE fit can be computed using the following code,

# Pseudo observations at t = 30
pseudo_bladder_1d <- pseudo.onedim(tstart = bladdersub$start,
                                   tstop = bladdersub$stop,
                                   status = bladdersub$status3,
                                   id = bladdersub$id,
                                   covar_names = "Z",
                                   tk = c(30),
                                   data = bladdersub)
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
head(pseudo_bladder_1d$outdata)
#>              mu k ts id       Z
#> 1 -0.0004269178 1 30  1 placebo
#> 2 -0.0004269178 1 30  2 placebo
#> 3  2.2068346439 1 30  3 placebo
#> 4  2.0490624124 1 30  4 placebo
#> 5 -0.2365050848 1 30  5 placebo
#> 6  0.8716030233 1 30  6 placebo

# GEE fit
fit_bladder_1d <- pseudo.geefit(pseudodata = pseudo_bladder_1d,
                                covar_names = c("Z"))
fit_bladder_1d
#> $xi
#>                       
#> (Intercept)  0.5410214
#> Zthiotepa   -0.3216062
#> 
#> $sigma
#>             (Intercept)   Zthiotepa
#> (Intercept)   0.0242502 -0.02425020
#> Zthiotepa    -0.0242502  0.06606093
#> 
#> attr(,"class")
#> [1] "pseudo.geefit"

# Treatment differences
xi_diff_1d <- as.matrix(c(fit_bladder_1d$xi[2]), ncol = 1)

mslabels <- c("treat, mu")
rownames(xi_diff_1d) <- mslabels
colnames(xi_diff_1d) <- ""
xi_diff_1d
#>                     
#> treat, mu -0.3216062

# Variance matrix for differences
sigma_diff_1d <- matrix(c(fit_bladder_1d$sigma[2,2]),
                          ncol = 1, nrow = 1,
                          byrow = T)

rownames(sigma_diff_1d) <- colnames(sigma_diff_1d) <- mslabels
sigma_diff_1d
#>            treat, mu
#> treat, mu 0.06606093

Thus, the estimated mean ratio is exp (β̂)= 0.7249836 (standard error and confidence intervals can be found using the Delta method).

Alternatively, the bivariate pseudo-observation model using the binary treatment indicator as covariate can be fitted, i.e.  $$ \left( \begin{matrix} \log \left(\mu (t \mid Z) \right) \\ \text{cloglog} \left( S( t \mid Z) \right) \end{matrix} \right) = \left( \begin{matrix} \log \left( \mu_0(t) \right) + {\beta} {Z} \\ \log \left(\Lambda_0(t)\right) + {\gamma} {Z} \end{matrix} \right) $$

Two-dimensional pseudo-observations and GEE fit can be computed using the following code

# Pseudo observations at t = 30
pseudo_bladder_2d <- pseudo.twodim(tstart = bladdersub$start,
                                   tstop = bladdersub$stop,
                                   status = bladdersub$status3,
                                   id = bladdersub$id,
                                   covar_names = "Z",
                                   tk = c(30),
                                   data = bladdersub)
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
head(pseudo_bladder_2d$outdata)
#>              mu          surv k ts id       Z
#> 1 -0.0004269178  1.421085e-14 1 30  1 placebo
#> 2 -0.0004269178  1.421085e-14 1 30  2 placebo
#> 3  2.2068346439  8.170875e-01 1 30  3 placebo
#> 4  2.0490624124  8.170875e-01 1 30  4 placebo
#> 5 -0.2365050848 -5.305763e-02 1 30  5 placebo
#> 6  0.8716030233 -5.305763e-02 1 30  6 placebo

# GEE fit
fit_bladder_2d <- pseudo.geefit(pseudodata = pseudo_bladder_2d,
                                covar_names = c("Z"))
fit_bladder_2d
#> $xi
#>                                  
#> esttypemu              0.54102140
#> esttypemu:Zthiotepa   -0.32160621
#> esttypesurv           -1.41652478
#> esttypesurv:Zthiotepa -0.04800778
#> 
#> $sigma
#>                          esttypemu esttypemu:Zthiotepa  esttypesurv
#> esttypemu              0.024250203        -0.024250203 -0.008870686
#> esttypemu:Zthiotepa   -0.024250203         0.066060930  0.008870686
#> esttypesurv           -0.008870686         0.008870686  0.123251791
#> esttypesurv:Zthiotepa  0.008870686        -0.006524386 -0.123251791
#>                       esttypesurv:Zthiotepa
#> esttypemu                       0.008870686
#> esttypemu:Zthiotepa            -0.006524386
#> esttypesurv                    -0.123251791
#> esttypesurv:Zthiotepa           0.260915569
#> 
#> attr(,"class")
#> [1] "pseudo.geefit"

# Treatment differences
xi_diff_2d <- as.matrix(c(fit_bladder_2d$xi[2],
                          fit_bladder_2d$xi[4]), ncol = 1)

mslabels <- c("treat, mu", "treat, surv")
rownames(xi_diff_2d) <- mslabels
colnames(xi_diff_2d) <- ""
xi_diff_2d
#>                        
#> treat, mu   -0.32160621
#> treat, surv -0.04800778


# Variance matrix for differences
sigma_diff_2d <- matrix(c(fit_bladder_2d$sigma[2,2],
                          fit_bladder_2d$sigma[2,4],
                          fit_bladder_2d$sigma[2,4],
                          fit_bladder_2d$sigma[4,4]),
                          ncol = 2, nrow = 2,
                          byrow = T)

rownames(sigma_diff_2d) <- colnames(sigma_diff_2d) <- mslabels
sigma_diff_2d
#>                treat, mu  treat, surv
#> treat, mu    0.066060930 -0.006524386
#> treat, surv -0.006524386  0.260915569

Finally, one could fit the three-dimensional pseudo-observation model to the bladder cancer data.

Three-dimensional pseudo-observations and GEE fit can be computed using the following code

# Add deathtype variable to bladder data
# Deathtype = 1 (bladder disease death), deathtype = 2 (other death reason)
bladdersub$deathtype <- with(bladdersub, ifelse(status == 2, 1, ifelse(status == 3, 2, 0)))
table(bladdersub$deathtype, bladdersub$status)
#>    
#>       0   1   2   3
#>   0  55 132   0   0
#>   1   0   0   2   0
#>   2   0   0   0  20

# Pseudo-observations
pseudo_bladder_3d <- pseudo.threedim(tstart = bladdersub$start,
                                     tstop = bladdersub$stop,
                                     status = bladdersub$status3,
                                     id = bladdersub$id,
                                     deathtype = bladdersub$deathtype,
                                     covar_names = "Z",
                                     tk = c(30), 
                                     data = bladdersub)
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
head(pseudo_bladder_3d$outdata_long)
#>   k ts id esttype             y       Z
#> 1 1 30  1      mu -4.269178e-04 placebo
#> 2 1 30  1    surv  1.421085e-14 placebo
#> 3 1 30  1    cif1  0.000000e+00 placebo
#> 4 1 30  1    cif2  1.000000e+00 placebo
#> 5 1 30  2      mu -4.269178e-04 placebo
#> 6 1 30  2    surv  1.421085e-14 placebo

# GEE fit
fit_bladder_3d <- pseudo.geefit(pseudodata = pseudo_bladder_3d,
                                covar_names = c("Z"))
fit_bladder_3d
#> $xi
#>                                 
#> esttypemu              0.5410214
#> esttypemu:Zthiotepa   -0.3216062
#> esttypecif1           -3.7618319
#> esttypecif1:Zthiotepa  0.2930357
#> esttypecif2           -1.5431978
#> esttypecif2:Zthiotepa -0.1005109
#> 
#> $sigma
#>                         esttypemu esttypemu:Zthiotepa esttypecif1
#> esttypemu              0.02425020        -0.024250203  0.01077521
#> esttypemu:Zthiotepa   -0.02425020         0.066060930 -0.01077521
#> esttypecif1            0.01077521        -0.010775214  1.07839851
#> esttypecif1:Zthiotepa -0.01077521         0.010436061 -1.07839851
#> esttypecif2           -0.01119997         0.011199967 -0.02642283
#> esttypecif2:Zthiotepa  0.01119997        -0.008433405  0.02642283
#>                       esttypecif1:Zthiotepa esttypecif2 esttypecif2:Zthiotepa
#> esttypemu                       -0.01077521 -0.01119997           0.011199967
#> esttypemu:Zthiotepa              0.01043606  0.01119997          -0.008433405
#> esttypecif1                     -1.07839851 -0.02642283           0.026422825
#> esttypecif1:Zthiotepa            2.01305239  0.02642283          -0.057715255
#> esttypecif2                      0.02642283  0.13816738          -0.138167379
#> esttypecif2:Zthiotepa           -0.05771525 -0.13816738           0.299045959
#> 
#> attr(,"class")
#> [1] "pseudo.geefit"

# Treatment differences
xi_diff_3d <- as.matrix(c(fit_bladder_3d$xi[2],
                          fit_bladder_3d$xi[4],
                          fit_bladder_3d$xi[6]), ncol = 1)

mslabels <- c("treat, mu", "treat, cif1", "treat, cif2")
rownames(xi_diff_3d) <- mslabels
colnames(xi_diff_3d) <- ""
xi_diff_3d
#>                       
#> treat, mu   -0.3216062
#> treat, cif1  0.2930357
#> treat, cif2 -0.1005109


# Variance matrix for differences
sigma_diff_3d <- matrix(c(fit_bladder_3d$sigma[2,2],
                          fit_bladder_3d$sigma[2,4],
                          fit_bladder_3d$sigma[2,6],

                          fit_bladder_3d$sigma[2,4],
                          fit_bladder_3d$sigma[4,4],
                          fit_bladder_3d$sigma[4,6],

                          fit_bladder_3d$sigma[2,6],
                          fit_bladder_3d$sigma[4,6],
                          fit_bladder_3d$sigma[6,6]

                          ),
                        ncol = 3, nrow = 3,
                        byrow = T)

rownames(sigma_diff_3d) <- colnames(sigma_diff_3d) <- mslabels
sigma_diff_3d
#>                treat, mu treat, cif1  treat, cif2
#> treat, mu    0.066060930  0.01043606 -0.008433405
#> treat, cif1  0.010436061  2.01305239 -0.057715255
#> treat, cif2 -0.008433405 -0.05771525  0.299045959

We can compare the three model fits. Note, that the μ components match each other.

# Compare - should match for mu elements 
xi_diff_1d
#>                     
#> treat, mu -0.3216062
xi_diff_2d
#>                        
#> treat, mu   -0.32160621
#> treat, surv -0.04800778
xi_diff_3d
#>                       
#> treat, mu   -0.3216062
#> treat, cif1  0.2930357
#> treat, cif2 -0.1005109

sigma_diff_1d
#>            treat, mu
#> treat, mu 0.06606093
sigma_diff_2d
#>                treat, mu  treat, surv
#> treat, mu    0.066060930 -0.006524386
#> treat, surv -0.006524386  0.260915569
sigma_diff_3d
#>                treat, mu treat, cif1  treat, cif2
#> treat, mu    0.066060930  0.01043606 -0.008433405
#> treat, cif1  0.010436061  2.01305239 -0.057715255
#> treat, cif2 -0.008433405 -0.05771525  0.299045959

More covariates

Assume that we wish to add extra baseline covariates to the model fit. For the sake of illustration, we have simulated a continuous covariate, Z2, and a categorical covariate, Z3. The covariate Z1 corresponds to the binary treatment covariate (Z = 1 is thiotepa and Z = 0 is placebo). In order to make estimation for these models possible, the pseudo-observations are calculated at three time points, namely t = 20, 30, 40 months.

For the one-dimensional model for μ it holds that,

log (μ(t ∣ Z)) = log (μ0(t)) + β1Z1 + β2Z2 + β3Z3.

This can be fitted using the below code,

require(dplyr)

## One-dim
# A binary variable, Z1_
# A continuous variable, Z2_
# A categorical variable, Z3_
set.seed(0308)

bladdersub <- as.data.frame(
  bladdersub %>% group_by(id) %>% 
  mutate(Z1_ = Z,
         Z2_ = rnorm(1, mean = 3, sd = 1),
         Z3_ = sample(x = c("A", "B", "C"), 
                      size = 1, replace = TRUE, 
                      prob = c(1/4, 1/2, 1/4))
         ))
# head(bladdersub, 20)

# Make pseudo obs at more timepoints (more data)
# Pseudo observations at t = 20, 30, 40
pseudo_bladder_1d_3t <- pseudo.onedim(tstart = bladdersub$start,
                                      tstop = bladdersub$stop,
                                      status = bladdersub$status3,
                                      id = bladdersub$id,
                                      covar_names = c("Z1_", "Z2_", "Z3_"),
                                      tk = c(20, 30, 40),
                                      data = bladdersub)
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length

fit1 <- pseudo.geefit(pseudodata = pseudo_bladder_1d_3t, 
                      covar_names = c("Z1_", "Z2_", "Z3_"))

fit1$xi
#>                        
#> (Intercept)  0.25615759
#> Ztime30      0.45743097
#> Ztime40      0.65605316
#> Z1_thiotepa -0.13653433
#> Z2_         -0.09648477
#> Z3_B         0.16138290
#> Z3_C        -0.26864406
fit1$sigma
#>              (Intercept)       Ztime30       Ztime40   Z1_thiotepa
#> (Intercept)  0.117115580 -0.0071583424 -0.0107994960 -0.0369114498
#> Ztime30     -0.007158342  0.0047337863  0.0059029172  0.0009136906
#> Ztime40     -0.010799496  0.0059029172  0.0090302983  0.0036896167
#> Z1_thiotepa -0.036911450  0.0009136906  0.0036896167  0.0700944992
#> Z2_         -0.018488196  0.0002005557 -0.0003019444 -0.0041450966
#> Z3_B        -0.049877636  0.0015076989  0.0038152528  0.0282038266
#> Z3_C        -0.037119771  0.0075388498  0.0119505567  0.0158651293
#>                       Z2_         Z3_B         Z3_C
#> (Intercept) -0.0184881959 -0.049877636 -0.037119771
#> Ztime30      0.0002005557  0.001507699  0.007538850
#> Ztime40     -0.0003019444  0.003815253  0.011950557
#> Z1_thiotepa -0.0041450966  0.028203827  0.015865129
#> Z2_          0.0082615678 -0.002622905 -0.006816236
#> Z3_B        -0.0026229047  0.072963075  0.043571275
#> Z3_C        -0.0068162357  0.043571275  0.170628370

fit1$xi[4]
#> [1] -0.1365343

Or for two-dimensional pseudo-observations, it holds that

$$ \left( \begin{matrix} \log \left(\mu (t \mid Z) \right) \\ \text{cloglog} \left( S( t \mid Z) \right) \end{matrix} \right) = \left( \begin{matrix} \log \left( \mu_0(t) \right) + \beta_1 {Z_1} + \beta_2 {Z_2} + \beta_3 {Z_3} \\ \log \left(\Lambda_0(t)\right) + {\gamma_1} Z_1 + {\gamma_2} Z_2 + {\gamma_3} Z_3 \end{matrix} \right). $$ Or for three-dimensional pseudo-observations, it holds that $$ \left( \begin{matrix} \log \left(\mu (t \mid Z) \right) \\ \text{cloglog} \left(1- C_1( t \mid Z) \right) \\ \text{cloglog} \left( 1-C_2( t \mid Z) \right) \end{matrix} \right) = \left( \begin{matrix} \log \left( \mu_0(t) \right) + {\beta_1} {Z_1} + {\beta_2} {Z_2} + {\beta_3} Z_3\\ \log \left(\Lambda_{10}(t)\right) + \gamma_{11} {Z_1} + \gamma_{12} {Z_2} + \gamma_{13} {Z_3} \\ \log \left(\Lambda_{20}(t)\right) + \gamma_{21} {Z_1} + \gamma_{22} {Z_2} + \gamma_{23} {Z_3} \end{matrix} \right). $$

These two models are fitted using the below code,

## Two-dim
# Pseudo observations at t = 20, 30, 40
pseudo_bladder_2d_3t <- pseudo.twodim(tstart = bladdersub$start,
                                      tstop = bladdersub$stop,
                                      status = bladdersub$status3,
                                      id = bladdersub$id,
                                      covar_names = c("Z1_", "Z2_", "Z3_"),
                                      tk = c(20, 30, 40),
                                      data = bladdersub)
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length

fit2 <- pseudo.geefit(pseudodata = pseudo_bladder_2d_3t, 
                      covar_names = c("Z1_", "Z2_", "Z3_"))

# fit2$xi
# fit2$sigma


## Three-dim
pseudo_bladder_3d_3t <- pseudo.threedim(tstart = bladdersub$start,
                                        tstop = bladdersub$stop,
                                        status = bladdersub$status3,
                                        id = bladdersub$id,
                                        covar_names = c("Z1_", "Z2_", "Z3_"),
                                        deathtype = bladdersub$deathtype,
                                        tk = c(20, 30, 40),
                                        data = bladdersub)
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length
#> Warning in lS * dA: longer object length is not a multiple of shorter object
#> length

fit3 <- pseudo.geefit(pseudodata = pseudo_bladder_3d_3t, 
                      covar_names = c("Z1_", "Z2_", "Z3_"))

# fit3$xi
# fit3$sigma

## Compare for mu
fit1$xi[4]
#> [1] -0.1365343
fit2$xi[4]
#> [1] -0.136524
fit3$xi[4]
#> [1] -0.1365262

Citation

To cite the recurrentpseudo package please use the following reference,

Julie K. Furberg, Per K. Andersen, Sofie Korn, Morten Overgaard, Henrik Ravn: Bivariate pseudo-observations for recurrent event analysis with terminal events (Lifetime Data Analysis, 2023)