diff --git a/README.Rmd b/README.Rmd index e1962ec..3bff8e0 100644 --- a/README.Rmd +++ b/README.Rmd @@ -59,7 +59,7 @@ For factor variables (here: `rank` with 4 levels), automatically all odds ratios corresponding to the base level (here: `rank1`) are returned including their respective confident intervals. The default level is 95%. However, other levels can be specified with the param `CI`. -Data source: http://www.ats.ucla.edu/stat/r/dae/logit.htm +Data source: https://stats.idre.ucla.edu/stat/data/binary.csv ```{r} pacman::p_load(oddsratio, mgcv) diff --git a/README.md b/README.md index d9d4d85..314fd37 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,28 @@ #### General -[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1095473.svg)](https://doi.org/10.5281/zenodo.1095473) +[![Project Status: Active – The project has reached a stable, usable +state and is being actively +developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) +[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1095473.svg)](https://doi.org/10.5281/zenodo.1095473) | Resource: | CRAN | Travis CI | Appveyor | -|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | *Platforms:* | *Multiple* | *Linux & macOS* | *Windows* | | R CMD check | CRAN version | Build status | Build status | | Test coverage | | Coverage Status | | #### CRAN -[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/oddsratio)](https://cran.r-project.org/package=oddsratio) [![Downloads](https://cranlogs.r-pkg.org/badges/oddsratio?color=brightgreen)](https://www.r-pkg.org/pkg/oddsratio) ![](https://cranlogs.r-pkg.org/badges/grand-total/oddsratio) +[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/oddsratio)](https://cran.r-project.org/package=oddsratio) +[![Downloads](https://cranlogs.r-pkg.org/badges/oddsratio?color=brightgreen)](https://www.r-pkg.org/pkg/oddsratio) +![](https://cranlogs.r-pkg.org/badges/grand-total/oddsratio) -Functions for calculation and plotting of odds ratios of Generalized Additive (Mixed) Models and Generalized Linear (Mixed) Models with a binomial response variable (i.e. logistic regression models). +Functions for calculation and plotting of odds ratios of Generalized +Additive (Mixed) Models and Generalized Linear (Mixed) Models with a +binomial response variable (i.e. logistic regression models). -Installation ------------- +## Installation Install from CRAN: @@ -30,13 +36,17 @@ Get the development version from Github: remotes::install_github("pat-s/oddsratio") ``` -Examples --------- +## Examples ### GLM -Odds ratio calculation of predictors `gre` & `gpa` of a fitted model `fit_glm` with increment steps of 380 and 5, respectively. -For factor variables (here: `rank` with 4 levels), automatically all odds ratios corresponding to the base level (here: `rank1`) are returned including their respective confident intervals. The default level is 95%. However, other levels can be specified with the param `CI`. Data source: +Odds ratio calculation of predictors `gre` & `gpa` of a fitted model +`fit_glm` with increment steps of 380 and 5, respectively. +For factor variables (here: `rank` with 4 levels), automatically all +odds ratios corresponding to the base level (here: `rank1`) are returned +including their respective confident intervals. The default level is +95%. However, other levels can be specified with the param `CI`. Data +source: ``` r pacman::p_load(oddsratio, mgcv) @@ -50,9 +60,17 @@ or_glm(data = df, model = fit_glm, ### GAM -For GAMs, the calculation of odds ratio is different. Due to its non-linear definition, odds ratios do only apply to specific value changes and are not constant throughout the whole value range of the predictor as for GLMs. Hence, odds ratios of GAMs can only be computed for one predictor at a time by holding all other predictors at a fixed value while changing the value of the specific predictor. Confident intervals are currently fixed to the 95% level for GAMs. Data source: `?mgcv::predict.gam()` +For GAMs, the calculation of odds ratio is different. Due to its +non-linear definition, odds ratios do only apply to specific value +changes and are not constant throughout the whole value range of the +predictor as for GLMs. Hence, odds ratios of GAMs can only be computed +for one predictor at a time by holding all other predictors at a fixed +value while changing the value of the specific predictor. Confident +intervals are currently fixed to the 95% level for GAMs. Data source: +`?mgcv::predict.gam()` -Here, the usage of `or_gam()` is shown by calculating odds ratios of pred `x2` for a 20% steps across the whole value range of the predictor. +Here, the usage of `or_gam()` is shown by calculating odds ratios of +pred `x2` for a 20% steps across the whole value range of the predictor. ``` r set.seed(1234) @@ -66,22 +84,27 @@ or_gam(data = df, model = fit_gam, pred = "x2", percentage = 20, slice = TRUE) ``` -If you want to compute a single odds ratio for specific values, simply set param `slice = FALSE`: +If you want to compute a single odds ratio for specific values, simply +set param `slice = FALSE`: ``` r or_gam(data = df, model = fit_gam, pred = "x2", values = c(0.099, 0.198)) ``` -Plotting of GAM smooths is also supported: +Plotting of GAM smooths is also +supported: ``` r plot_gam(fit_gam, pred = "x2", title = "Predictor 'x2'") ```

+ +

+ Insert the calculated odds ratios into the smoothing function: ``` r @@ -97,8 +120,11 @@ plot ```

+ +

+ Insert multiple odds ratios into one smooth: ``` r @@ -114,5 +140,7 @@ insert_or(plot, or_object2, or_yloc = 2.1, values_yloc = 2, ```

+ +

diff --git a/vignettes/function_tutorial.Rmd b/vignettes/function_tutorial.Rmd index 759fb0c..2039714 100644 --- a/vignettes/function_tutorial.Rmd +++ b/vignettes/function_tutorial.Rmd @@ -138,7 +138,7 @@ Aesthetics like opacity or color are fully customizable. ## GLM example Fit model. -Data source: http://www.ats.ucla.edu/stat/r/dae/logit.htm +Data source: https://stats.idre.ucla.edu/stat/data/binary.csv ```{r} fit_glm <- glm(admit ~ gre + gpa + rank, data = data_glm, family = "binomial")