diff --git a/DESCRIPTION b/DESCRIPTION index 170ea1f..ac7bfd9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Type: Package Package: netidmtpreg Title: Net Survival Binomial Regression for Progressive Illness Death Models -Version: 0.0.0.9000 +Version: 0.1.0 Authors@R: person("Quentin", "Marcou", , "quentin.marcou@univ-amu.fr", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-7074-2761")) diff --git a/R/renewnetTPreg.R b/R/renewnetTPreg.R index 45a1490..4daacc0 100644 --- a/R/renewnetTPreg.R +++ b/R/renewnetTPreg.R @@ -1,6 +1,7 @@ -# Code adapted from idmTPreg package v1.1 under GNU-GPLv2 +# Code initially inspired from idmTPreg package v1.1 under GNU-GPLv2 # Original Authors: Leyla Azarang and Manuel Oviedo de la Fuente -# Adapted for net survival setting by Quentin Marcou, based on +# Largely rewritten and adapted for net survival setting by Quentin Marcou, +# based on #' @title Wraps the call to mod.glm.fit to handle convergence errors @@ -32,7 +33,7 @@ mod.glm.fit.errorwrapper <- maxmaxit = 1000, warning_str = "", ...) { - result <- tryCatchLog::tryCatchLog({ + result <- tryCatch({ # Try withCallingHandlers({ mod.glm.fit2( diff --git a/README.Rmd b/README.Rmd index 8b9567b..2d4ae45 100644 --- a/README.Rmd +++ b/README.Rmd @@ -23,7 +23,7 @@ knitr::opts_chunk$set( The goal of netidmtpreg is to enable net survival estimation through direct binomial regression, allowing modeling continuous covariate effects that could -not be handled through stratified Pohar-Perme estimation, all this in a +not be handled through e.g stratified Pohar-Perme estimation, all this in a multistate Illness-Death setting. ## Installation @@ -59,7 +59,7 @@ n_ind <- 1e2 # number of simulated individuals synth_idm_data <- generate_uncensored_ind_exp_idm_data( n_individuals = n_ind, lambda_illness = 1.0, - lambda_death = 0.1 + lambda_death = 1.0 ) # Generate random age and sex labels @@ -77,7 +77,7 @@ synth_idm_data <- )) # Generate population mortality assuming equal constant population rate -l_pop_death <- 0.1 # extra disease mortality doubles the population mortality +l_pop_death <- 1.0 # extra disease mortality doubles the population mortality population_death_times <- generate_exponential_time_to_event( n_individuals = n_ind, lambda = l_pop_death @@ -92,13 +92,13 @@ crude_synth_idm_data <- netidmtpreg:::apply_iddata_death( ) ``` -Now let's carry the of net survival: +Now let's carry the of net survival estimation: ```{r estimation, echo=TRUE, warning=FALSE, message=FALSE} # Estimation can be sped up and carried in parrallel using futures: future::plan("multisession") # will work on any OS # future::plan("multicore") # more efficient but only works on UNIX systems net_estimate <- renewnetTPreg( - formula = ~ sex, # intercept + binary covariate + formula = ~1, # intercept + binary covariate data = crude_synth_idm_data, # Use a standard ratetable ratetable = const_ratetable, @@ -108,8 +108,9 @@ net_estimate <- renewnetTPreg( year = start_date ), time_dep_popvars = list("age", "year"), - s = 0.5, - trans = "13", + s = 0.2, + by = n_ind / 10, + trans = "11", link = "logit", R = 100 # Number of bootstraps ) @@ -118,8 +119,9 @@ future::plan("sequential") # close the multisession, see future's documentation We obtain a `TPreg` object with a dedicated plotting method using ggplot: -```{r plot, echo = FALSE} -plot(net_estimate) +```{r plot} +plot(net_estimate) + ggplot2::ylim(-5, 5) ``` +Let's make sure we a More examples to come! \ No newline at end of file diff --git a/README.md b/README.md index 0279636..432b70c 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Status](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifec The goal of netidmtpreg is to enable net survival estimation through direct binomial regression, allowing modeling continuous covariate -effects that could not be handled through stratified Pohar-Perme +effects that could not be handled through e.g stratified Pohar-Perme estimation, all this in a multistate Illness-Death setting. ## Installation @@ -61,7 +61,7 @@ n_ind <- 1e2 # number of simulated individuals synth_idm_data <- generate_uncensored_ind_exp_idm_data( n_individuals = n_ind, lambda_illness = 1.0, - lambda_death = 0.1 + lambda_death = 1.0 ) # Generate random age and sex labels @@ -79,7 +79,7 @@ synth_idm_data <- )) # Generate population mortality assuming equal constant population rate -l_pop_death <- 0.1 # extra disease mortality doubles the population mortality +l_pop_death <- 1.0 # extra disease mortality doubles the population mortality population_death_times <- generate_exponential_time_to_event( n_individuals = n_ind, lambda = l_pop_death @@ -101,7 +101,7 @@ Now let’s carry the of net survival: future::plan("multisession") # will work on any OS # future::plan("multicore") # more efficient but only works on UNIX systems net_estimate <- renewnetTPreg( - formula = ~ sex, # intercept + binary covariate + formula = ~ 1, # intercept + binary covariate data = crude_synth_idm_data, # Use a standard ratetable ratetable = const_ratetable, @@ -111,21 +111,25 @@ net_estimate <- renewnetTPreg( year = start_date ), time_dep_popvars = list("age", "year"), - s = 0.5, - trans = "13", + s = 0.2, + by=n_ind/10, + trans = "11", link = "logit", R = 100 # Number of bootstraps ) +#> [1] "estimate" +#> [1] "bootstrap" future::plan("sequential") # close the multisession, see future's documentation ``` We obtain a `TPreg` object with a dedicated plotting method using ggplot: - #> Warning: Removed 1 row containing missing values or values outside the scale range - #> (`geom_line()`). - #> `geom_line()`: Each group consists of only one observation. - #> ℹ Do you need to adjust the group aesthetic? +``` r +plot(net_estimate) + ggplot2::ylim(-5,5) +#> Warning: Removed 1 row containing missing values or values outside the scale range +#> (`geom_line()`). +``` diff --git a/man/figures/README-plot-1.png b/man/figures/README-plot-1.png index 7b4f2a7..9dc6f49 100644 Binary files a/man/figures/README-plot-1.png and b/man/figures/README-plot-1.png differ