Skip to content

djnavarro/erlr

Repository files navigation

erlr

R-CMD-check

Provides estimation and plotting tools for exposure-response models that use logistic regression for binary responses.

Installation

You can install the development version of erlr like so:

pak::pak("djnavarro/erlr")

Example

library(erlr)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(tibble)

lr_data
#> # A tibble: 300 × 6
#>       id  dose exposure quartile response sex   
#>    <int> <dbl>    <dbl> <fct>       <dbl> <fct> 
#>  1     1   100    148.  Q3              1 Male  
#>  2     2   100     79.7 Q1              1 Male  
#>  3     3   200    212.  Q3              1 Male  
#>  4     4   200    236.  Q3              0 Female
#>  5     5     0      0   Placebo         1 Female
#>  6     6   200     71.0 Q1              1 Male  
#>  7     7   100    173.  Q3              1 Male  
#>  8     8   100    123.  Q2              0 Female
#>  9     9     0      0   Placebo         0 Male  
#> 10    10   200    165.  Q3              1 Male  
#> # ℹ 290 more rows

mod <- lr_model(response ~ exposure, lr_data)
mod
#> 
#> Call:  stats::glm(formula = formula, family = stats::binomial(link = "logit"), 
#>     data = data)
#> 
#> Coefficients:
#> (Intercept)     exposure  
#>     0.15078      0.01112  
#> 
#> Degrees of Freedom: 299 Total (i.e. Null);  298 Residual
#> Null Deviance:       341.7 
#> Residual Deviance: 283.9     AIC: 287.9

lr_data |> 
  lr_plot(exposure, response) |> 
  lr_plot_add_quantiles(bins = 4) |> 
  lr_plot_add_boxplot(group_by = quartile) |> 
  print()
#> Warning: annotation$theme is not a valid theme.
#> Please use `theme()` to construct themes.

lr_data |> 
  filter(exposure > 0) |> 
  lr_plot(exposure, response) |> 
  lr_plot_add_quantiles(bins = 4) |> 
  lr_plot_add_strips(color_by = sex) |> 
  lr_plot_add_boxplot(group_by = quartile) |> 
  lr_plot_add_boxplot(group_by = sex) |> 
  print(box_height = 2)
#> Warning: annotation$theme is not a valid theme.
#> Please use `theme()` to construct themes.

About

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages