betaregscale

betaregscale fits regression models for scores on a bounded rating scale $0, 1, \ldots, K$ (pain NRS-11 or NRS-101, Likert items, quality ratings). Each score is the coarsened reading of a latent beta variable on $(0, 1)$, written in mean–dispersion form: mean $\mu$, dispersion $\sigma = 1/(1 + \phi) \in (0, 1)$ with $\phi$ the beta precision, and $\mathrm{Var}(Y) = \mu(1 - \mu)\sigma$. Both can depend on covariates through link functions. The latent scale is cut at cutpoints anchored on the score labels, so each score is an interval-censored observation and the likelihood is a probability mass function over the scores $0, \ldots, K$. The scale borders need no ad hoc squeezing: score 0 is left-censored and score $K$ right-censored. Fixed-effects models are fitted with brs() and mixed models with Gaussian random effects with brsmm(); the log-likelihood and its derivatives are compiled C++.

Installation

# Released version from CRAN
install.packages("betaregscale")

# Development version from GitHub
# install.packages("remotes")
# remotes::install_github("evandeilton/betaregscale")
install.packages("betaregscale", repos = c('https://evandeilton.r-universe.dev', 'https://cloud.r-project.org'))

Example

Simulated NRS-11 scores (0 to 10) for 200 patients, with a continuous covariate and a treatment indicator:

library(betaregscale)

set.seed(1)
d <- data.frame(x1 = rnorm(200), trt = rbinom(200, 1, 0.5))
nrs <- brs_sim(~ x1 + trt, data = d, beta = c(-0.4, 0.5, -0.6),
               phi = qlogis(0.15), ncuts = 10)

# Mean with logit link, constant dispersion with logit link
fit <- brs(y ~ x1 + trt, data = nrs)
summary(fit)

# The fitted model is a pmf over the scores 0..10
round(head(brs_predict_scoreprob(fit), 3), 3)

# Expected score by arm at x1 = 0, and the difference between arms,
# with delta-method standard errors
nd <- data.frame(x1 = 0, trt = c(0, 1))
brs_marginal(fit, nd, type = "expected_score")
brs_marginal(fit, nd, type = "expected_score", contrast = c(2, 1))

# Diagnostic plots of randomized quantile residuals
plot(fit)

Features

Documentation

Function reference and changelog: https://evandeilton.github.io/betaregscale/. Bug reports and questions: https://github.com/evandeilton/betaregscale/issues.

Citation

citation("betaregscale") gives the reference for the package. The model is described in

Other references:

License

MIT © José Evandeilton Lopes and Wagner Hugo Bonat