FederatedApproachStage1: Fits the first stage model in the two-stage federated data...

View source: R/FederatedApproachStage1.R

FederatedApproachStage1R Documentation

Fits the first stage model in the two-stage federated data analysis approach.

Description

The function 'FederatedApproachStage1()' fits the first stage model of the two-stage federated data analysis approach to assess surrogacy.

Usage

FederatedApproachStage1(
  Dataset,
  Surr,
  True,
  Treat,
  Trial.ID,
  Min.Treat.Size = 2,
  Alpha = 0.05
)

Arguments

Dataset

A data frame with the correct columns (See Data Format).

Surr

Surrogate endpoint.

True

True endpoint.

Treat

Treatment indicator.

Trial.ID

Trial indicator.

Min.Treat.Size

The minimum number of patients in each group (control or experimental) that a trial should contain to be included in the analysis. If the number of patients in a group of a trial is smaller than the value specified by Min.Treat.Size, the data of the trial are excluded from the analysis. Default 2.

Alpha

The \alpha-level that is used to determine the confidence intervals around R^2_{trial} and R^2_{indiv}. Default 0.05.

Value

Returns an object of class "FederatedApproachStage1()" that can be used to evaluate surrogacy in the second stage model and contains the following elements:

  • Results.Stage.1: a data frame that contains the estimated fixed effects and the elements of \Sigma_i.

  • R.i: the variance-covariance matrix of the estimated fixed effects.

Model

The two-stage federated data analysis approach developed by XXX can be used to assess surrogacy in the meta-analytic multiple-trial setting (Continuous-continuous case), but without the need of sharing data. Instead, each organization conducts separate analyses on their data set using a so-called "first stage" model. The results of these analyses are then aggregated at a central analysis hub, where the aggregated results are analyzed using a "second stage" model and the necessary metrics (R^2_{trial} and R^2_{indiv}) for the validation of the surrogate endpoint are obtained. This function fits the first stage model, where a linear model is fitted, allowing estimation of the fixed effects.

Data Format

The data frame must contain the following columns:

  • a column with the true endpoint

  • a column with the surrogate endpoint

  • a column with the treatment indicator: 0 or 1

  • a column with the trial indicator

  • a column with the patient indicator

Author(s)

Dries De Witte

References

Florez, A. J., Molenberghs G, Verbeke G, Alonso, A. (2019). A closed-form estimator for metaanalysis and surrogate markers evaluation. Journal of Biopharmaceutical Statistics, 29(2) 318-332.

Examples

## Not run: 
#As an example, the federated data analysis approach can be applied to the Schizo data set
data(Schizo)
Schizo <-  Schizo[order(Schizo$InvestId, Schizo$Id),]
#Create separate datasets for each investigator
Schizo_datasets <- list()

for (invest_id in 1:198) {
Schizo_datasets[[invest_id]] <- Schizo[Schizo$InvestId == invest_id, ]
assign(paste0("Schizo", invest_id), Schizo_datasets[[invest_id]])
}
#Fit the first stage model for each dataset separately
results_stage1 <- list()
invest_ids <- list()
i <- 1
for (invest_id in 1:198) {
  dataset <- Schizo_datasets[[invest_id]]

  skip_to_next <- FALSE
  tryCatch(FederatedApproachStage1(dataset, Surr=CGI, True=PANSS, Treat=Treat, Trial.ID = InvestId,
                                   Min.Treat.Size = 5, Alpha = 0.05),
                                   error = function(e) { skip_to_next <<- TRUE})
  #if the trial does not have the minimum required number, skip to the next
  if(skip_to_next) { next }

  results_stage1[[invest_id]] <- FederatedApproachStage1(dataset, Surr=CGI, True=PANSS, Treat=Treat,
                                                         Trial.ID = InvestId, Min.Treat.Size = 5,
                                                         Alpha = 0.05)
  assign(paste0("stage1_invest", invest_id), results_stage1[[invest_id]])
  invest_ids[[i]] <- invest_id #keep a list of ids with datasets with required number of patients
  i <- i+1
}

invest_ids <- unlist(invest_ids)
invest_ids

#Combine the results of the first stage models
for (invest_id in invest_ids) {
  dataset <- results_stage1[[invest_id]]$Results.Stage.1
  if (invest_id == invest_ids[1]) {
    all_results_stage1<- dataset
 } else {
    all_results_stage1 <- rbind(all_results_stage1,dataset)
  }
}

all_results_stage1 #that combines the results of the first stage models

R.list <- list()
i <- 1
for (invest_id in invest_ids) {
  R <- results_stage1[[invest_id]]$R.i
  R.list[[i]] <- as.matrix(R[1:4,1:4])
  i <- i+1
}

R.list #list that combines all the variance-covariance matrices of the fixed effects

fit <- FederatedApproachStage2(Dataset = all_results_stage1, Intercept.S = Intercept.S,
                               alpha = alpha, Intercept.T = Intercept.T, beta = beta,
                               sigma.SS = sigma.SS, sigma.ST = sigma.ST,
                               sigma.TT = sigma.TT, Obs.per.trial = n,
                               Trial.ID = Trial.ID, R.list = R.list)
summary(fit)

## End(Not run)

Surrogate documentation built on June 22, 2024, 9:16 a.m.