write.surv: write.surv

View source: R/write.surv.R

write.survR Documentation

write.surv

Description

Writes the survival summary to an excel file (helpful to then call the values in the Markov model) - ported from survHE

Usage

write.surv(object, file, sheet = NULL, what = "surv")

Arguments

object

a summary.flexsurvreg object containing the survival curves (with times, estimates and interval limits)

file

a string with the full path to the file name to be saved

sheet

a string with the name of the sheet to be created

what

a string to describe what to be exported. Can either be 'surv' (default), which outputs the simulation(s) for the survival curves or 'sim', which outputs the simulation(s) for the underlying model parameters. If there are several 'profiles', they get written in separate spreadsheets and a clear indication is given as the name of the spreadsheet

Value

A spreadsheet file with the simulation(s) of the relevant quantity

Author(s)

Gianluca Baio

References

P Cooney (2023). expertsurv: Incorporating expert opinion into parametric survival models.

\insertRef

Baio.2020expertsurv

See Also

make.surv

Examples

## Not run: 
require("dplyr")
param_expert_example1 <- list()
param_expert_example1[[1]] <- data.frame(dist = c("norm","t"),
                                        wi = c(0.5,0.5), # Ensure Weights sum to 1
                                        param1 = c(0.1,0.12),
                                        param2 = c(0.15,0.5),
                                        param3 = c(NA,3))

timepoint_expert <- 14
data2 <- data %>% rename(status = censored) %>% mutate(time2 = ifelse(time > 10, 10, time),
                                                      status2 = ifelse(time> 10, 0, status))
example1 <- fit.models.expert(formula=Surv(time2,status2)~1,data=data2,
                             distr=c("wph", "gomp"),
                             method="mle",
                             pool_type = "log pool",
                             opinion_type = "survival",
                             times_expert = timepoint_expert,
                             param_expert = param_expert_example1)

p.mle = make.surv(example1,mod= 2,t = 1:30, nsim=1000) #Plot the Gompertz model
write.surv(p.mle,file="test.xlsx")

## End(Not run)

Philip-Cooney/expertsurv documentation built on Sept. 21, 2023, 9:11 a.m.