pat-s / oddsratio

Simplified odds ratio calculation of binomial GAM/GLM models
https://pat-s.github.io/oddsratio
Other
31 stars 2 forks source link

Account for partial matching of predictor variables #41

Closed pat-s closed 4 years ago

pat-s commented 4 years ago

fixes #34

# load libraries
library(oddsratio)
library(mgcv)
#> Loading required package: nlme
#> This is mgcv 1.8-31. For overview type 'help("mgcv-package")'.

# get data
dat <- oddsratio::data_gam
dat.test <- dat

# rename variables x0 and x1 
names(dat.test)[2:3] <- c("x_0", "x_01")

# fit models
fit_gam <- mgcv::gam(y ~ s(x0) + s(I(x1^2)) + s(x2) + offset(x3) + x4, 
                     data = dat)

fit_gam_test <- mgcv::gam(y ~ s(x_0) + s(I(x_01^2)) + s(x2) + offset(x3) + x4, 
                          data = dat.test)

# check oddsratio function
oddsratio::plot_gam(model = fit_gam, pred = "x2") 

oddsratio::plot_gam(model = fit_gam_test, pred = "x_0")

Created on 2020-05-24 by the reprex package (v0.3.0)

codecov[bot] commented 4 years ago

Codecov Report

Merging #41 into master will decrease coverage by 33.90%. The diff coverage is 93.61%.

Impacted file tree graph

@@             Coverage Diff              @@
##            master      #41       +/-   ##
============================================
- Coverage   100.00%   66.09%   -33.91%     
============================================
  Files            3        5        +2     
  Lines          138      233       +95     
============================================
+ Hits           138      154       +16     
- Misses           0       79       +79     
Impacted Files Coverage Δ
R/insert_or.R 0.00% <0.00%> (ø)
R/helper_funs.R 100.00% <100.00%> (ø)
R/or_gam.R 100.00% <100.00%> (ø)
R/or_glm.R 100.00% <100.00%> (ø)
R/plot_gam.R 80.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2a252b9...c5727d8. Read the comment docs.