Skip to content

Commit

Permalink
Remove complete logging, update readme, set v0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
qmarcou committed Jun 1, 2024
1 parent 9d16713 commit 2bb341f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 25 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-7074-2761"))
Expand Down
7 changes: 4 additions & 3 deletions R/renewnetTPreg.R
Original file line number Diff line number Diff line change
@@ -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 <ref>
# Largely rewritten and adapted for net survival setting by Quentin Marcou,
# based on <ref>


#' @title Wraps the call to mod.glm.fit to handle convergence errors
Expand Down Expand Up @@ -32,7 +33,7 @@ mod.glm.fit.errorwrapper <-
maxmaxit = 1000,
warning_str = "",
...) {
result <- tryCatchLog::tryCatchLog({
result <- tryCatch({
# Try
withCallingHandlers({
mod.glm.fit2(
Expand Down
20 changes: 11 additions & 9 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 only model, similar to Pohar-Perme estimation
data = crude_synth_idm_data,
# Use a standard ratetable
ratetable = const_ratetable,
Expand All @@ -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
)
Expand All @@ -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!
28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -94,14 +94,14 @@ 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 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 only model, similar to Pohar-Perme estimation
data = crude_synth_idm_data,
# Use a standard ratetable
ratetable = const_ratetable,
Expand All @@ -111,22 +111,26 @@ 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()`).
```

<img src="man/figures/README-plot-1.png" width="100%" />

More examples to come\!
Let’s make sure we a More examples to come\!
Binary file modified man/figures/README-plot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2bb341f

Please sign in to comment.