Coder Social home page Coder Social logo

logbin's Introduction

logbin

CRAN_Status_Badge

logbin provides methods for performing relative risk regression by fitting log-link GLMs and GAMs to binomial data. As well as providing a consistent interface to use the usual Fisher scoring algorithm (via glm or glm2) and an adaptive barrier approach (via constrOptim), it implements EM-type algorithms that have more stable convergence properties than other methods.

An example of periodic non-convergence using glm (run with trace = TRUE to see deviance at each iteration):

require(glm2, quietly = TRUE)
data(heart)

start.p <- sum(heart$Deaths) / sum(heart$Patients)
t.glm <- system.time(
  fit.glm <- logbin(cbind(Deaths, Patients-Deaths) ~ factor(AgeGroup) + factor(Severity) + 
                      factor(Delay) + factor(Region), data = heart,
                    start = c(log(start.p), -rep(1e-4, 8)), method = "glm", maxit = 10000)
)

The combinatorial EM method (Marschner and Gillett, 2012) provides stable convergence:

t.cem <- system.time(fit.cem <- update(fit.glm, method = "cem"))

…but it can take a while. Using an overparameterised EM approach removes the need to run (3^4 = 81) separate EM algorithms:

t.em <- system.time(fit.em <- update(fit.glm, method = "em"))

…while generic EM acceleration algorithms (from the turboEM package) can speed this up further still:

t.cem.acc <- system.time(fit.cem.acc <- update(fit.cem, accelerate = "squarem"))
t.em.acc <- system.time(fit.em.acc <- update(fit.em, accelerate = "squarem"))

Comparison of results:

#>         converged    logLik iterations   time
#> glm         FALSE -186.7366      10000   2.08
#> cem          TRUE -179.9016     445161 102.41
#> em           TRUE -179.9016       7403   1.62
#> cem.acc      TRUE -179.9016       7545  10.38
#> em.acc       TRUE -179.9016         90   0.24

An adaptive barrier algorithm can also be applied using method = "ab", with user-specified options via control.method: see help(logbin) for more details.

Semi-parametric regression using B-splines (Donoghoe and Marschner, 2015) can be incorporated by using the logbin.smooth function. See example(logbin.smooth) for a simple example.

Installation

Get the released version from CRAN:

install.packages("logbin")

Or the development version from github:

# install.packages("devtools")
devtools::install_github("mdonoghoe/logbin")

References

  • Donoghoe, M. W. and I. C. Marschner (2015). Flexible regression models for rate differences, risk differences and relative risks. International Journal of Biostatistics 11(1): 91–108.
  • Donoghoe, M. W. and I. C. Marschner (2018). logbin: An R package for relative risk regression using the log-binomial model. Journal of Statistical Software 86(9): 1–22.
  • Marschner, I. C. and A. C. Gillett (2012). Relative risk regression: reliable and flexible methods for log-binomial models. Biostatistics 13(1): 179–192.

logbin's People

Contributors

mdonoghoe avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.