apsurvival calculates total sample size and its allocation across regions for the MRCT with a survival endpoint:
* Assurance probability to claim overall consistency based on Definitions 1-4
* Total sample size ensuring significance of overall treatment effect and desired conditional assurance probability to claim overall consistency at the same time
* Optimal sample size allocation determined by maximizing conditional assurance probability if regional treatment effects are slightly different. (Allocate equal sample size to each region if treatment effects are uniform across regions.）

The package consists of functions like these:
* Calculation of assurance probability (return a list of unconditional and conditional assurance probabilities):
* Definition 1: prob.def1 (using simulation) and prob_ddc.def1 (using asymptotic distributions derived, listed but not used)
* Definition 2: prob.def2 (using simulation) and prob_ddc.def2 (using asymptotic distributions derived, listed but not used)
* Definition 3: prob.def3 (using asymptotic distributions derived)
* Definition 4: prob.def4 (using simulation)
* Optimal sample size allocation (return a list of optimal sample size allocation, conditional assurance probabilities with different combinations of sample size allocation and program running time):
* Definition 1: alloc.def1 (using simulation)
* Definition 2: alloc.def2 (using simulation)
* Definition 3: alloc.def3 (using asymptotic distributions derived)
* Definition 4: alloc.def4 (using simulation)
* Calculation of total sample size (return a list of sample size ensuring overall significance and overall consistency, traditional sample size ensuring overall significance, optimal sample size allocation, conditional assurance probabilities with different combinations of sample size allocation and program running time):
* Definition 1: sample.def1 (using simulation)
* Definition 2: sample.def2 (using simulation)
* Definition 3: sample.def3 (using asymptotic distributions derived)
* Definition 4: sample.def4 (using simulation)
* Other functions
* estimatelogHR: observed log hazard ratio
* Eventnum and Samplesize: calculate event number and total sample size

The R package you need to install before

```
install.packages("mvtnorm")
```

```
# install.packages("devtools")
devtools::install_github("carolinewei/apsurvival")
```

```
library(apsurvival)
set.seed(123)
# Simulation times = 100
Sampsize1 <- sample.def1(r0=log(0.7), alpha=0.05, beta=0.2, lamda=1, lamda_cen=1, L=2, s=3, u=c(0.9,1,1.1), pai=1/3, grid=0.1, n=100, consistency=0.8)
# Sample size ensuring overall significance and 80% conditional assurance probability to claim overall consistency
samplesize_AP <- Sampsize1$samplesize_AP
# Sample size only ensuring overall significance
samplesize <- Sampsize1$samplesize
# Optimal sample size allocation across regions
optimal_alloc <- Sampsize1$optimal_alloc
```

The package is incomplete and any suggestions for improvements are welcome.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.