MyNixOS website logo
Description

Estimation of Prevalence Ratios via Logistic Regression Models.

Estimates adjusted prevalence ratios (PR) and their confidence intervals from logistic regression models, addressing the well-known limitation of odds ratios (OR) as approximations to PR in cross-sectional studies with common outcomes. Supports independent observations (glm()), clustered/multilevel data (glmer() from 'lme4'), longitudinal data via Generalised Estimating Equations (geeglm() from 'geepack'), and complex survey designs (svyglm() from 'survey'). Inference is available via the delta method (conditional and marginal standardisation) and via bootstrap (normal-approximation and percentile intervals). Continuous covariates are handled through user-specified or median-based reference values; flexible baseline specification allows any reference category to be chosen for factor predictors. Based on the methodology described in Amorim & Ospina (2021) <doi:10.1590/0001-3765202120190316>.

prLogistic

R-CMD-check CRAN status License: GPL v2

prLogistic estimates adjusted prevalence ratios (PR) and their confidence intervals from logistic regression models, addressing the well-known limitation of odds ratios (OR) as approximations to PR in cross-sectional and other studies with common binary outcomes.

Why PR instead of OR?

When the outcome is common (prevalence > 10%), the OR from logistic regression overestimates the PR. For example, with a 30% baseline prevalence and an OR = 2.5, the true PR is closer to 1.8. prLogistic corrects this using conditional or marginal standardisation directly on the logistic model.

Supported data structures

FunctionModelUse case
prLogisticDelta()glmIndependent observations
prLogisticDelta()glmerModClustered / multilevel data
prLogisticGEE()geeglmLongitudinal data (GEE)
prLogisticSurvey()svyglmComplex survey designs

Installation

# Stable release from CRAN
install.packages("prLogistic")

# Development version from GitHub
# install.packages("remotes")
remotes::install_github("Raydonal/prLogistic")

Quick start

library(prLogistic)

# Fit a standard logistic model
data(birthwt, package = "MASS")
birthwt$smoke <- factor(birthwt$smoke)
birthwt$race  <- factor(birthwt$race)

fit <- glm(low ~ smoke + race + age + lwt,
           family = binomial, data = birthwt)

# --- Delta method --------------------------------------------------------

# Conditional PR (default: continuous covariates at median)
prLogisticDelta(fit, standardisation = "conditional")

# Marginal PR (population-averaged)
prLogisticDelta(fit, standardisation = "marginal")

# Custom reference: age = 25, lwt = 55 kg
prLogisticDelta(fit,
                standardisation = "conditional",
                ref_values = list(age = 25, lwt = 55))

# --- Bootstrap CIs -------------------------------------------------------
set.seed(42)
prLogisticBootCond(fit, data = birthwt, R = 999)

# --- Forest plot ---------------------------------------------------------
res <- prLogisticDelta(fit)
plot(res)

Longitudinal data (GEE)

library(geepack)
data(ohio, package = "geepack")

fit_gee <- geeglm(resp ~ smoke + age,
                  family = binomial, id = id,
                  corstr = "exchangeable", data = ohio)

prLogisticGEE(fit_gee)

Complex survey data

library(survey)
data(api, package = "survey")
dclus2 <- svydesign(id = ~dnum + snum, fpc = ~fpc1 + fpc2, data = apiclus2)
fit_svy <- svyglm(sch.wide ~ meals + stype,
                  design = dclus2, family = quasibinomial)

prLogisticSurvey(fit_svy)

Citation

If you use prLogistic in your research, please cite:

Amorim, L. D. & Ospina, R. (2021). Prevalence ratio estimation using R. Anais da Academia Brasileira de Ciências, 93(4), e20190316. https://doi.org/10.1590/0001-3765202120190316

@article{Amorim2021,
  author  = {Amorim, Leila D. and Ospina, Raydonal},
  title   = {Prevalence ratio estimation using {R}},
  journal = {Anais da Academia Brasileira de Ci\^{e}ncias},
  year    = {2021},
  volume  = {93},
  number  = {4},
  pages   = {e20190316},
  doi     = {10.1590/0001-3765202120190316}
}

License

GPL (≥ 2). See the GNU GPL v2 for details.

Metadata

Version

2.0.2

License

Unknown

Platforms (79)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    wasip1
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arc-linux
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • sh4-linux
  • vc4-none
  • wasm32-wasip1
  • wasm64-wasip1
  • x86_64-cygwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows