Skip to content

Commit

Permalink
Update paper.md
Browse files Browse the repository at this point in the history
  • Loading branch information
masahikoji authored Dec 27, 2024
1 parent 65f1dcc commit b8b4618
Showing 1 changed file with 86 additions and 6 deletions.
92 changes: 86 additions & 6 deletions paper.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,35 @@ The following main functions are demonstrated in this article:

`rmstpara`: Restricted mean survival time via parametric models.

The function provides the inference of Bayesian regression models using Stan for parametric survival time.

**Usage**: The `brm_surv` function is called using following syntax.
```
brm_surv(time, cnsr, var, rvar, family = "exponential", random = "fixed", data,
iter = 2000, warmup = 1000, seed = NA, chains = 4)
```

**Arguments**: The main arguments of `brm_surv` function is tabulated as below:

- `time`: name of time variable in data. Need to set character.
- `cnsr`: name of censor variable in data. Need to set character.
- `var`: vector of covariate names in data. Need to set character.
- `rvar`: name of random effect in data. Need to set character.
- `family`: A description of the response distribution and link function to be used in the model. 'exponential', 'Weibull', 'log-normal', and 'log-logistic' can be selected.
- `random`: A description of random effect. 'fixed', 'normal', and 'frailty' are available.
- `data`: An object of class data.frame (or one that can be coerced to that class) containing data of all variables used in the model.


**Value**: The `brm_surv` function returns a list of list of an object of class `brmsfit` or `stanfit` (see \CRANpkg{rstan} and \CRANpkg{brms}), sampling values from posterior distribution, leave-one-out cross-validation, and widely applicable information criterions.

- `fit`: An object of class `brmsfit` or `stanfit`.
- `post_sample`: Extract posterior samples of specified parameters.
- `waic`: Widely applicable information criterion.
- `loo`: Efficient approximate leave-one-out cross-validation.

## Example data
We illustrate a real example of the Leukemia Survival Data in `spBayesSurv`, which include 1,043 patients of survival of acute myeloid leukemia. We focus on the "time", "cens", "age" and "district" variables.
"District" can be regarded as a cluster, and the impact of mixed effects and frailty can be considered.

```
data(LeukSurv)
Expand Down Expand Up @@ -132,6 +158,18 @@ fit_x$waic
fit_x$loo
```

||Estimate|SE|
| ---- | ---- | ---- |
|elpd_waic|-6056.5|73.6|
|p_waic|4.8|0.4|
|waic|12113.0|147.1|

||Estimate|SE|
| ---- | ---- | ---- |
|elpd_loo|-6056.5|73.6|
|p_loo|4.8|0.4|
|looic|12113.0|147.1|

Although main purpose of `rmstBayespara` is to present group differences in RMST, the Bayesian parametric model also can illustrate the posterior distribution of covariate parameters.

```
Expand All @@ -140,6 +178,14 @@ round(estimate, 4)
boxplot(fit_x$post_sample, cex.axis=0.8)
```

||b_intercept|b_factor(arm)|b_factor(sex)|shape|
| ---- | ---- | ---- | ---- | ---- |
|Min.|5.4637|1.1233|-0.5284|0.5114|
|1st Qu.|5.7489|1.5012|-0.1710|0.5446|
|Median|5.8212|1.5867|-0.0865|0.5542|
|Mean|5.8219|1.5860|-0.0873|0.5547|
|3rd Qu. |5.8930|1.6692|-0.0058|0.5648|
|Max.|6.2475|2.0499|0.3431|0.6007|

The difference in RMST between arms of posterior samples from Weibull model can be obtained as below:

Expand All @@ -155,16 +201,30 @@ c(summary(rmst_diff_x),quantile(rmst_diff_x,c(0.025,0.975)))
hist(rmst_diff_x, breaks=100, freq=F)
```

|Min.|1st Qu.|Median|Mean|3rd Qu.|Max.|2.5%|97.5%|
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
|10.18390|13.89870|14.77579|14.77010|15.59717|19.53334|12.25126|17.27399|

The 95% confidence interval can be obtained from the 2.5% and 97.5% results.

Next, the analysis of mixed effects model can be implemented as follows.
Next, the analysis of mixed effects model can be implemented as follows. By setting random="normal", it is possible to adapt to a mixed effects model.
```
fit_x_r <- brm_surv(time="time", cnsr="1-status", var=c("factor(arm)", "factor(sex)"),
rvar="district", data=dat, family="Weibull", random="normal")
fit_x_r$waic
fit_x_r$loo
```

||Estimate|SE|
| ---- | ---- | ---- |
|elpd_waic|-6050.0|73.8|
|p_waic|21.0|1.6|
|waic|12100.0|147.6|

||Estimate|SE|
| ---- | ---- | ---- |
|elpd_loo|-6050.1|73.8|
|p_loo|21.0|1.6|
|looic|12100.1|147.6|

The results of the difference in RMST with mixed effect, taking heterogeneity into account, can be calculated as follows.

Expand All @@ -181,6 +241,9 @@ rmst_diff_x_r<-as.numeric(
c(summary(rmst_diff_x_r),quantile(rmst_diff_x_r,c(0.025,0.975)))
```

|Min.|1st Qu.|Median|Mean|3rd Qu.|Max.|2.5%|97.5%|
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
|8.837232|12.074202|12.917372|12.974916|13.844946|17.774116|10.443351|15.619410|

The results of the difference in RMST for distinct 1, taking heterogeneity into account, can be calculated as follows.
```
Expand All @@ -195,7 +258,9 @@ rmst_diff_x_r_1<-as.numeric(
c(summary(rmst_diff_x_r_1),quantile(rmst_diff_x_r_1,c(0.025,0.975)))
```


|Min.|1st Qu.|Median|Mean|3rd Qu.|Max.|2.5%|97.5%|
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
|0.2712211|0.4375881|0.4887243|0.4945920|0.5460238|0.9143291|0.3492974|0.6731644|

Finally, frailty effects model can be implemented as follows.
```
Expand All @@ -204,8 +269,17 @@ fit_x_f <- brm_surv(time="time", cnsr="1-status", var=c("factor(arm)", "factor(s
fit_x_f$waic
fit_x_f$loo
```


||Estimate|SE|
| ---- | ---- | ---- |
|elpd_waic|-6050.0|73.9|
|p_waic|22.0|1.7|
|waic|12100.0|147.7|

||Estimate|SE|
| ---- | ---- | ---- |
|elpd_loo|-6050.1|73.9|
|p_loo|22.1|1.7|
|looic|12100.2|147.7|

The results of the difference in RMST with frailty effect, taking heterogeneity into account, can be calculated as follows.

Expand All @@ -222,6 +296,10 @@ rmst_diff_x_f<-as.numeric(
c(summary(rmst_diff_x_f),quantile(rmst_diff_x_f,c(0.025,0.975)))
```

|Min.|1st Qu.|Median|Mean|3rd Qu.|Max.|2.5%|97.5%|
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
|0.08846989|0.68157877|1.02491134|1.13388377|1.44250681|4.85410016|0.27837340|2.70644121|

The results of the difference in RMST for distinct 1, taking heterogeneity into account, can be calculated as follows.
```
rmst_diff_x_f_1<-as.numeric(
Expand All @@ -234,8 +312,10 @@ rmst_diff_x_f_1<-as.numeric(
)
c(summary(rmst_diff_x_f_1),quantile(rmst_diff_x_f_1,c(0.025,0.975)))
```
|Min.|1st Qu.|Median|Mean|3rd Qu.|Max.|2.5%|97.5%|
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
|-25.039281591|8.385407514|10.359507614|9.357048164|11.463067134|14.833317067|0.005389485|12.930702706|

# Acknowledgements


# References

0 comments on commit b8b4618

Please sign in to comment.