survMS
survMS (survival Model Simulation) is an R package enabling the data simulation from different survival models (Cox, AFT, and AH models). The simulated data will have various levels of complexity according to the survival model considered.
Science Score: 10.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
1 of 4 committers (25.0%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.9%) to scientific vocabulary
Last synced: 6 months ago
·
JSON representation
Repository
survMS (survival Model Simulation) is an R package enabling the data simulation from different survival models (Cox, AFT, and AH models). The simulated data will have various levels of complexity according to the survival model considered.
Basic Info
- Host: GitHub
- Owner: mathildesautreuil
- Language: R
- Default Branch: master
- Homepage: https://mathildesautreuil.github.io/survMS
- Size: 2.84 MB
Statistics
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Created almost 5 years ago
· Last pushed almost 4 years ago
Metadata Files
Readme
README.Rmd
---
title: "survMS R package: survival Model Simulation"
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
[](https://cran.r-project.org/package=survMS)
[](https://cran.r-project.org/package=survMS)
[](https://github.com/mathildesautreuil/survMS//actions)
[](https://mathildesautreuil.github.io/survMS)
# Installation
Install from CRAN:
```{r setupCRAN, eval=FALSE}
install.packages("survMS")
```
Or install the development version from Github:
```{r setupDevtools, eval=FALSE}
install.packages("devtools")
devtools::install_github("mathildesautreuil/survMS")
```
And load the library:
```{r load}
library(survMS)
```
# 1 Introduction
**survMS** is an R package that generates survival data from different survival models with varying levels of complexity. Three survival models are implemented in the package to simulate survival data: a Cox model, an Accelerated Failure Time (AFT) model, and an Accelerated Hazard (AH) model. These models have their specificities. Indeed, a Cox model is a proportional risk model, not an AFT and an AH model. A proportional risk model means that the ratio of the risks between two individuals with different explanatory variables does not depend on the time. In an AFT model, the explanatory variables have an accelerating or decelerating effect on individuals' survival. In both models, a Cox model and an AFT model, the survival function’s curves never intersect. When one is interested in more complex data with intersecting survival curves, for example, to make it more difficult for methods to predict survival, two approaches are implemented in the package. The first approach consists of modifying an AFT model to have intersecting survival curves. The
second approach concerns using of an AH model (for *Accelerated Hazards*) to generate the survival data. an AH
model is more flexible than the two models mentioned above. In an AH model, the variables accelerate or decelerate the hazard risk. The survival curves of an AH model can therefore cross each other. The generation of survival times carried out from the different models mentioned above. The baseline risk function of the models is
assumed to be known and follows a particular probability distribution. For these different models, we use parametric distribution of the baseline risk for the generation of survival time.
Note that we stayed in a linear dependency framework without interaction. We will adapt the package in a second step to be in a nonlinear framework to simulate interactions. The package's implementation is easily adapted to the nonlinear framework with interactions by replacing the explanatory variables' linear part with a nonlinear function of the explanatory variables. All the functions in the package are coded to introduce this nonlinear function of the explanatory variables easily.
For details on methodology, see [Vignette](https://mathildesautreuil.github.io/survMS/articles/how-to-simulate-survival-models.html).
# 2 Simulation from a Cox model
The package survMS can simulate data from a Cox model. We have chosen to carry out this simulation to generate survival data that respects the proportional risk hypothesis. For more details, see [Vignette](https://mathildesautreuil.github.io/survMS/articles/how-to-simulate-survival-models.html).
Survival times can follow different distributions: Weibull, log-normal, exponential (in progress) and Gompertz (in progress).
## 2.1 Simulation from a Cox model with baseline hazard following Weibull distribution
To simulate survival data checking the proportional risk hypothesis, we use a Cox model with survival times following a Weibull distribution.
```{r sim_cox_model}
res_paramW = get_param_weib(med = 1062, mu = 1134)
# c(res_paramW$a, res_paramW$lambda)
listCoxWSim_n500_p1000 <- modelSim(model = "cox", matDistr = "unif", matParam = c(-1,1), n = 500,
p = 1000, pnonull = 20, betaDistr = 1, hazDistr = "weibull",
hazParams = c(3, 4), seed = 1, d = 0)
hist(listCoxWSim_n500_p1000)
```
## 2.2 Simulation from a Cox model with baseline hazard following log-normal distribution
To simulate survival data checking the proportional risk hypothesis, we use a Cox model with survival times following a log-normal distribution.
```{r sim_coxLN_model}
res_paramLN = get_param_ln(var = 170000, mu = 2320)
listCoxSim_n500_p1000 <- modelSim(model = "cox", matDistr = "unif", matParam = c(-1,1), n = 500,
p = 1000, pnonull = 20, betaDistr = 1, hazDistr = "log-normal",
hazParams = c(res_paramLN$a, res_paramLN$lambda), seed = 1, d = 0)
hist(listCoxSim_n500_p1000)
```
## 2.3 Simulation from a Cox model with a correlated covariate matrix
For this simulation, we consider the same design as 2.1 to simulate survival times. However, the simulated covariate matrix is correlated. The pertinent covariates are those correlated. We split this set of pertinent covariates in two subsets: one with a correlation parameter (*matParam[2]*) and the other one with (1 - *matParam[2]*). The non-pertinent covariates are uncorrelated.
```{r sim_cox_model_cor}
res_paramW = get_param_weib(med = 2.5, mu = 1.2)
listCoxSimCor_n500_p1000 <- modelSim(model = "cox", matDistr = "mvnorm", matParam = c(0,0.6), n = 500,
p = 1000, pnonull = 10, betaDistr = 1, hazDistr = "weibull",
hazParams = c(res_paramW$a, res_paramW$lambda), seed = 1, d = 0)
Heatmap(listCoxSimCor_n500_p1000, ind = 1:15, k = 3)
```
# 3 Simulation from an AFT model
From survMS package, we can simulate the data from an AFT model. We have chosen to carry out this simulation to generate survival data that does not respect the proportional risk hypothesis. For more details, see [Vignette](https://mathildesautreuil.github.io/survMS/articles/how-to-simulate-survival-models.html).
Survival times can follow different distributions: Weibull, log-normal, exponential (in progress) and Gompertz (in progress).
## 3.1 Simulation from an AFT model with baseline hazard following Weibull distribution
To simulate survival data not checking the proportional risk hypothesis, we use an AFT model with survival times following a weibull distribution.
```{r sim_aftW_model}
res_paramW = get_param_weib(med = 1062, mu = 1134)
# c(res_paramW$a, res_paramW$lambda)
listAFTWSim_n500_p1000 <- modelSim(model = "AFT", matDistr = "unif", matParam = c(-1,1), n = 500,
p = 1000, pnonull = 20, betaDistr = 1, hazDistr = "weibull",
hazParams = c(3, 2), seed = 1, d = 0)
hist(listAFTWSim_n500_p1000)
```
## 3.2 Simulation from an AFT model with baseline hazard following log-normal distribution
To simulate survival data not checking the proportional risk hypothesis, we use an AFT model with survival times following a log-normal distribution.
```{r sim_aftLN_model}
res_paramLN = get_param_ln(var = 170000, mu = 2325)
listAFTLNSim_n500_p1000 <- modelSim(model = "AFT", matDistr = "unif", matParam = c(-1,1), n = 500,
p = 10, pnonull = 10, betaDistr = 1, hazDistr = "log-normal",
hazParams = c(res_paramLN$a*3, res_paramLN$lambda), seed = 1, d = 0)
hist(listAFTLNSim_n500_p1000)
```
## 3.3 Simulation from a shifted AFT model
To obtain survival data from a model that does not respect the proportional risk hypothesis and that their survival curves can not cross, we have modified the AFT model by adding a term *betaDistr* in the model. For more details, see [Vignette](https://mathildesautreuil.github.io/survMS/articles/how-to-simulate-survival-models.html).
Survival times can follow different distributions: Weibull, log-normal, exponential (in progress) and Gompertz (in progress).
```{r sim_aft_mod_model}
res_paramLN = get_param_ln(var = 170000, mu = 2325)
listAFTsSim_n500_p1000 <- modelSim(model = "AFTshift", matDistr = "unif", matParam = c(-1,1), n = 500,
p = 10, pnonull = 10, betaDistr = "unif", hazDistr = "log-normal",
hazParams = c(0.3, res_paramLN$lambda), seed = 1, d = 0)
hist(listAFTsSim_n500_p1000)
```
# 4 Simulation from an AH model
From survMS package, we can also simulated survival data from another model, an AH model. We have chosen to carry out this simulation to generate survival data that does not respect the proportional risk hypothesis and survival curves can cross. For more details, see [Vignette](https://mathildesautreuil.github.io/survMS/articles/how-to-simulate-survival-models.html).
## 4.1 Simulation from an AH model with baseline hazard following Weibull distribution
```{r sim_ah_model}
res_paramW = get_param_weib(med = 1062, mu = 1134)
listAHwSim_n500_p1000 <- modelSim(model = "AH", matDistr = "unif", matParam = c(-1,1), n = 500,
p = 100, pnonull = 20, betaDistr = 1, hazDistr = "weibull",
hazParams = c(res_paramW$a, res_paramW$lambda),
Phi = 0, seed = 1, d = 0)
hist(listAHwSim_n500_p1000)
```
## 4.2 Simulation from the an AH model with baseline hazard following log-normal distribution
```{r sim_ahLN_model}
res_paramLN = get_param_ln(var = 170000, mu = 2325)
listAHSim_n500_p1000 <- modelSim(model = "AH", matDistr = "unif", matParam = c(-1,1), n = 500,
p = 100, pnonull = 100, betaDistr = 1.5, hazDistr = "log-normal",
hazParams = c(res_paramLN$a*4, res_paramLN$lambda), Phi = 0,
seed = 1, d = 0)
# summary(listAHSim_n500_p1000)
# print(listAHSim_n500_p1000)
hist(listAHSim_n500_p1000)
```
# 5 Utils functions
## 5.1 Get parameters of survival time distribution
```{r param_distr}
# Weibull distribution
res_paramW = get_param_weib(med = 1062, mu = 1134)
res_paramW
# Log-normale distribution
res_paramLN = get_param_ln(var = 600000, mu = 1134)
res_paramLN
```
## 5.2 Plotting survival curves
### 5.2.1 Cox/Weibull model
```{r surv_curves}
set.seed(1234)
ind = sample(x = 1:500, 8)
## Cox/Weibull model
# df_p1000_n500[1:6,1:10]
plot(listCoxWSim_n500_p1000, ind = ind)
```
### 5.2.2 AFT/Log-normal model
```{r surv_curves_aft}
## AFT/Weibull model
# df_p1000_n500[1:6,1:10]
plot(listAFTLNSim_n500_p1000, ind = ind)
```
### 5.2.3 Shifted AFT/Log-normal model
```{r surv_curves_afts}
## Shifted AFT/LN model
# df_p1000_n500[1:6,1:10]
plot(listAFTsSim_n500_p1000, ind = ind)
```
### 5.2.4 AH/LN model
```{r surv_curves_ah}
## Cox/Weibull model
# df_p1000_n500[1:6,1:10]
# set.seed(765)
ind = sample(x = 1:500, 8)
plot(listAHSim_n500_p1000, ind = ind)
```
## 5.3 Plotting hazard curves
### 5.3.1 Cox/Weibull model
```{r haz_curves}
## Cox/Weibull model
# df_p1000_n500[1:6,1:10]
plot(listCoxWSim_n500_p1000, ind = ind, type = "hazard")
```
### 5.3.2 AFT/Weibull model
```{r haz_curves_aft}
## AFT/Weibull model
# df_p1000_n500[1:6,1:10]
plot(listAFTWSim_n500_p1000, ind = ind, type = "hazard")
```
### 5.3.3 AFT/Log-normal model
```{r haz_curves_aftLN}
## AFT/LN model
# df_p1000_n500[1:6,1:10]
plot(listAFTLNSim_n500_p1000, ind = ind, type = "hazard")
```
### 5.3.4 Shifted AFT/Log-normal model
```{r haz_curves_afts}
## Shifted AFT/LN model
# df_p1000_n500[1:6,1:10]
plot(listAFTsSim_n500_p1000, ind = ind, type = "hazard")
```
### 5.3.5 AH/LN model
```{r haz_curves_ah}
## Cox/Weibull model
# df_p1000_n500[1:6,1:10]
plot(listAHSim_n500_p1000, ind = ind, type = "hazard")
```
# 6 Examples
Please also see the package [vignette](https://mathildesautreuil.github.io/survMS/articles/how-to-simulate-survival-models.html) for more detailed examples and a description of the methodology underpinning the **survMS** package.
Owner
- Name: Mathilde
- Login: mathildesautreuil
- Kind: user
- Website: mathildesautreuil.github.io
- Repositories: 1
- Profile: https://github.com/mathildesautreuil
GitHub Events
Total
- Watch event: 3
Last Year
- Watch event: 3
Committers
Last synced: almost 3 years ago
All Time
- Total Commits: 46
- Total Committers: 4
- Avg Commits per committer: 11.5
- Development Distribution Score (DDS): 0.283
Top Committers
| Name | Commits | |
|---|---|---|
| Sautreuil Mathilde | m****l@c****r | 33 |
| mathilde | m****l@g****m | 8 |
| mesl_cb | m****s@s****m | 3 |
| Mathilde | 3****l@u****m | 2 |
Committer Domains (Top 20 + Academic)
Packages
- Total packages: 1
- Total downloads: unknown
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 1
cran.r-project.org: survMS
Survival Model Simulation
- Homepage: https://github.com/mathildesautreuil/survMS/
- Documentation: http://cran.r-project.org/web/packages/survMS/survMS.pdf
- License: GPL-3
- Status: removed
-
Latest release: 0.0.1
published almost 5 years ago
Rankings
Stargazers count: 22.5%
Forks count: 28.8%
Average: 29.1%
Dependent packages count: 29.8%
Dependent repos count: 35.5%
Last synced:
almost 3 years ago
Dependencies
DESCRIPTION
cran
- ComplexHeatmap * depends
- circlize * depends
- ggplot2 * depends
- MASS * imports
- graphics * imports
- knitr * suggests
- markdown * suggests
- rmarkdown * suggests