Skip to content

Commit

Permalink
darft using expertsurv package in vignette
Browse files Browse the repository at this point in the history
  • Loading branch information
n8thangreen committed Jun 25, 2024
1 parent 8fdfb26 commit 905f84a
Showing 1 changed file with 51 additions and 1 deletion.
52 changes: 51 additions & 1 deletion vignettes/basic.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ plot(ble_Surv2) +

## flexsurv frequentist background fit

The last example is for an HMC and frequentist survival model using the flexsurv package directly.
The next example is for an HMC and frequentist survival model using the flexsurv package directly.

```{r}
obs_Surv3 <- fit.models(formula = Surv(death_t, death) ~ 1,
Expand All @@ -136,3 +136,53 @@ ble_Surv3 <- blendsurv(obs_Surv3, ext_Surv3, blend_interv, beta_params)
plot(ble_Surv3)
```

<!-- TODO -->
## `{expertsurv}` background fit

The next example is using the [`{expertsurv}`](https://github.com/Philip-Cooney/expertsurv) package to fit the external model.

We can create the external survival curve using the penalised regression model.

```{r eval=FALSE}}
# devtools::install_github("Philip-Cooney/expertsurv")
library(expertsurv)
param_expert[[1]] <- data.frame(dist = "norm",
wi = 1,
param1 = 0.1,
param2 = 0.005)
param_expert[[2]] <- data.frame(dist = "norm",
wi = 1,
param1 = 0.05,
param2 = 0.005,
param3 = NA)
timepoint_expert <- c(14,18)
obs_Surv3 <- fit.models(formula = Surv(death_t, death) ~ 1,
data = dat_FCR,
distr = "exponential",
method = "hmc")
# dummy data
data <- data.frame(time = 1, event = 0)
# don't provide any data so its all based on the prior
example1 <- fit.models.expert(formula = Surv(time,event) ~ 1,
data = data,
distr = "gomp",
method = "hmc",
iter = 5000,
opinion_type = "survival",
times_expert = timepoint_expert,
param_expert = param_expert)
ble_Surv3 <- blendsurv(obs_Surv3, ext_Surv3, blend_interv, beta_params)
plot(ble_Surv3)
```

Alternatively, we could use the `{expertsurv}` functions to fit both the data and the external information together as intended in the `{expertsurv}` package.
However, to modify this so that it is similar to `{blendr}` we can choose variance of constraint as functions of the blending interval.

0 comments on commit 905f84a

Please sign in to comment.