| Title: | Beta Regression for Interval-Censored Scale-Derived Outcomes |
|---|---|
| Description: | Maximum-likelihood estimation of beta regression models for responses derived from bounded rating scales. Observations are treated as interval-censored on (0, 1) after a scale-to-unit transformation, and the likelihood is built from the difference of the beta CDF at the interval endpoints. The complete likelihood supports mixed censoring types: uncensored, left-censored, right-censored, and interval-censored observations. Both fixed- and variable-dispersion submodels are supported, with flexible link functions for the mean and precision components. A compiled C++ backend (via 'Rcpp' and 'RcppArmadillo') provides numerically stable, high-performance log-likelihood evaluation. Standard S3 methods (print(), summary(), coef(), fitted(), residuals(), predict(), plot(), confint(), vcov(), logLik(), AIC(), BIC()) are available for fitted objects. |
| Authors: | José Evandeilton Lopes [aut, cre] (ORCID: <https://orcid.org/0009-0007-5887-4084>), Wagner Hugo Bonat [aut] (ORCID: <https://orcid.org/0000-0002-0349-7054>) |
| Maintainer: | José Evandeilton Lopes <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 2.7.1 |
| Built: | 2026-05-23 19:24:07 UTC |
| Source: | https://github.com/evandeilton/betaregscale |
Akaike information criterion
## S3 method for class 'brs' AIC(object, ..., k = 2)## S3 method for class 'brs' AIC(object, ..., k = 2)
object |
A fitted |
... |
Ignored. |
k |
Penalty per parameter (default 2). |
Scalar AIC value.
brs, logLik.brs, BIC.brs,
brs_gof
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) AIC(fit)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) AIC(fit)
AIC for brsmm models
## S3 method for class 'brsmm' AIC(object, ..., k = 2)## S3 method for class 'brsmm' AIC(object, ..., k = 2)
object |
A fitted |
... |
Currently ignored. |
k |
Numeric penalty per parameter. |
Numeric scalar.
brsmm, logLik.brsmm,
BIC.brsmm, brs_gof
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) AIC(fit)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) AIC(fit)
Model comparison by analysis of deviance (LR test) for 'brs'
## S3 method for class 'brs' anova(object, ..., test = c("Chisq", "none"))## S3 method for class 'brs' anova(object, ..., test = c("Chisq", "none"))
object |
A fitted |
... |
Additional fitted |
test |
Character; |
An object of class "anova" and "data.frame" with
model-wise log-likelihood, information criteria, and (optionally) LR test
columns.
Lopes, J. E. (2023). Modelos de regressao beta para dados de escala. Master's dissertation, Universidade Federal do Parana, Curitiba. URI: https://hdl.handle.net/1884/86624.
Ferrari, S. L. P., and Cribari-Neto, F. (2004). Beta regression for modelling rates and proportions. Journal of Applied Statistics, 31(7), 799–815. doi:10.1080/0266476042000214501
brs, logLik.brs, AIC.brs,
BIC.brs
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), x2 = rep(c(0, 0, 1, 1), 5) ) prep <- brs_prep(dat, ncuts = 100) m1 <- brs(y ~ 1, data = prep) m2 <- brs(y ~ x1, data = prep) m3 <- brs(y ~ x1 + x2, data = prep) anova(m1, m2, m3)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), x2 = rep(c(0, 0, 1, 1), 5) ) prep <- brs_prep(dat, ncuts = 100) m1 <- brs(y ~ 1, data = prep) m2 <- brs(y ~ x1, data = prep) m3 <- brs(y ~ x1 + x2, data = prep) anova(m1, m2, m3)
Model comparison by analysis of deviance (LR test) for 'brsmm'
## S3 method for class 'brsmm' anova(object, ..., test = c("Chisq", "none"))## S3 method for class 'brsmm' anova(object, ..., test = c("Chisq", "none"))
object |
A fitted |
... |
Additional fitted |
test |
Character; |
An object of class "anova" and "data.frame" with
model-wise log-likelihood, information criteria, and (optionally) LR test
columns.
Lopes, J. E. (2023). Modelos de regressao beta para dados de escala. Master's dissertation, Universidade Federal do Parana, Curitiba. URI: https://hdl.handle.net/1884/86624.
Ferrari, S. L. P., and Cribari-Neto, F. (2004). Beta regression for modelling rates and proportions. Journal of Applied Statistics, 31(7), 799–815. doi:10.1080/0266476042000214501
brsmm, logLik.brsmm,
AIC.brsmm, BIC.brsmm
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) m1 <- brs(y ~ 1, data = prep) m2 <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) anova(m1, m2)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) m1 <- brs(y ~ 1, data = prep) m2 <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) anova(m1, m2)
Produces ggplot2 diagnostics tailored to interval-censored scale models.
## S3 method for class 'brs' autoplot( object, type = c("calibration", "score_dist", "cdf", "residuals_by_delta", "all"), bins = 10L, scores = NULL, newdata = NULL, n_grid = 200L, max_curves = 6L, residual_type = "rqr", title = NULL, xlab = NULL, ylab = NULL, ncol = 2L, theme = ggplot2::theme_minimal(), ... )## S3 method for class 'brs' autoplot( object, type = c("calibration", "score_dist", "cdf", "residuals_by_delta", "all"), bins = 10L, scores = NULL, newdata = NULL, n_grid = 200L, max_curves = 6L, residual_type = "rqr", title = NULL, xlab = NULL, ylab = NULL, ncol = 2L, theme = ggplot2::theme_minimal(), ... )
object |
A fitted |
type |
Plot type: |
bins |
Number of bins for |
scores |
Optional integer vector of scores for |
newdata |
Optional data frame of covariate scenarios for |
n_grid |
Number of points on |
max_curves |
Maximum number of CDF curves shown when |
residual_type |
Residual type for |
title |
Optional character: override the plot title via
|
xlab |
Optional character: override the x-axis label.
Ignored when |
ylab |
Optional character: override the y-axis label.
Ignored when |
ncol |
Number of columns for the grid when |
theme |
A ggplot2 theme object (e.g., |
... |
Additional arguments forwarded to |
type = "calibration" bins predictions and compares mean observed vs
mean predicted response in each bin.
type = "score_dist" compares observed score frequencies against
expected frequencies implied by the fitted beta interval model.
A ggplot2 object.
Lopes, J. E. (2023). Modelos de regressao beta para dados de escala. Master's dissertation, Universidade Federal do Parana, Curitiba. URI: https://hdl.handle.net/1884/86624.
Hawker, G. A., Mian, S., Kendzerska, T., and French, M. (2011). Measures of adult pain: Visual Analog Scale for Pain (VAS Pain), Numeric Rating Scale for Pain (NRS Pain), McGill Pain Questionnaire (MPQ), Short-Form McGill Pain Questionnaire (SF-MPQ), Chronic Pain Grade Scale (CPGS), Short Form-36 Bodily Pain Scale (SF-36 BPS), and Measure of Intermittent and Constant Osteoarthritis Pain (ICOAP). Arthritis Care and Research, 63(S11), S240-S252. doi:10.1002/acr.20543
Hjermstad, M. J., Fayers, P. M., Haugen, D. F., et al. (2011). Studies comparing Numerical Rating Scales, Verbal Rating Scales, and Visual Analogue Scales for assessment of pain intensity in adults: a systematic literature review. Journal of Pain and Symptom Management, 41(6), 1073-1093. doi:10.1016/j.jpainsymman.2010.08.016
brs, plot.brs,
autoplot.brs_bootstrap
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), x2 = rep(c(0, 0, 1, 1), 5) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1 + x2, data = prep) ggplot2::autoplot(fit, type = "calibration") ggplot2::autoplot(fit, type = "calibration", title = "My calibration", ylab = "Observed" ) ggplot2::autoplot(fit, type = "all")dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), x2 = rep(c(0, 0, 1, 1), 5) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1 + x2, data = prep) ggplot2::autoplot(fit, type = "calibration") ggplot2::autoplot(fit, type = "calibration", title = "My calibration", ylab = "Observed" ) ggplot2::autoplot(fit, type = "all")
Produces visual summaries for objects returned by brs_bootstrap.
## S3 method for class 'brs_bootstrap' autoplot( object, type = c("ci_forest", "dist", "qq", "stability"), parameter = NULL, title = NULL, caption = NULL, max_parameters = 12L, ci_level = NULL, theme = NULL, ... )## S3 method for class 'brs_bootstrap' autoplot( object, type = c("ci_forest", "dist", "qq", "stability"), parameter = NULL, title = NULL, caption = NULL, max_parameters = 12L, ci_level = NULL, theme = NULL, ... )
object |
An object of class |
type |
Plot type:
|
parameter |
Optional parameter name used by |
title |
Optional plot title override. |
caption |
Optional subtitles/titles for plot types. Accepts:
|
max_parameters |
Maximum number of parameters shown in
|
ci_level |
Confidence level used in |
theme |
Optional ggplot2 theme object (e.g., |
... |
Currently ignored. |
For type = "dist", "qq", and "stability",
bootstrap draws must be present in attr(object, "boot_draws"),
obtained by fitting with brs_bootstrap(..., keep_draws = TRUE).
A ggplot2 object.
brs_bootstrap, brs,
autoplot.brs
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) boot <- brs_bootstrap(fit, R = 50) ggplot2::autoplot(boot, type = "ci_forest")dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) boot <- brs_bootstrap(fit, R = 50) ggplot2::autoplot(boot, type = "ci_forest")
Produces visual summaries for objects returned by
brs_marginaleffects.
## S3 method for class 'brs_marginaleffects' autoplot( object, type = c("forest", "magnitude", "dist"), variable = NULL, top_n = 12L, title = NULL, caption = NULL, theme = NULL, ... )## S3 method for class 'brs_marginaleffects' autoplot( object, type = c("forest", "magnitude", "dist"), variable = NULL, top_n = 12L, title = NULL, caption = NULL, theme = NULL, ... )
object |
An object of class |
type |
Plot type: |
variable |
Optional variable name for |
top_n |
Maximum number of variables shown in |
title |
Optional plot title override. |
caption |
Optional subtitle override. |
theme |
Optional ggplot2 theme object. If |
... |
Currently ignored. |
type = "dist" requires AME simulation draws stored in
attr(object, "ame_draws"), which are available when marginal
effects are computed with keep_draws = TRUE and interval = TRUE.
A ggplot2 object.
brs_marginaleffects, brs,
autoplot.brs
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) ame <- brs_marginaleffects(fit) ggplot2::autoplot(ame, type = "forest")dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) ame <- brs_marginaleffects(fit) ggplot2::autoplot(ame, type = "forest")
Produces ggplot2 diagnostics tailored to mixed beta interval models.
## S3 method for class 'brsmm' autoplot( object, type = c("calibration", "score_dist", "ranef_qq", "residuals_by_group", "ranef_caterpillar", "ranef_density", "ranef_pairs", "shrinkage", "all"), bins = 10L, scores = NULL, residual_type = c("response", "pearson"), max_groups = 25L, title = NULL, xlab = NULL, ylab = NULL, ncol = 2L, theme = ggplot2::theme_minimal(), ... )## S3 method for class 'brsmm' autoplot( object, type = c("calibration", "score_dist", "ranef_qq", "residuals_by_group", "ranef_caterpillar", "ranef_density", "ranef_pairs", "shrinkage", "all"), bins = 10L, scores = NULL, residual_type = c("response", "pearson"), max_groups = 25L, title = NULL, xlab = NULL, ylab = NULL, ncol = 2L, theme = ggplot2::theme_minimal(), ... )
object |
A fitted |
type |
Plot type. One of |
bins |
Number of bins for |
scores |
Optional integer vector of scores for |
residual_type |
Residual type for |
max_groups |
Maximum groups in |
title |
Optional character: override the plot title via
|
xlab |
Optional character: override the x-axis label.
Ignored when |
ylab |
Optional character: override the y-axis label.
Ignored when |
ncol |
Number of columns for the grid when |
theme |
A ggplot2 theme object (e.g., |
... |
Additional arguments forwarded to |
A ggplot2 object, or (when type = "all") invisibly
returns the list of all panels after rendering the grid.
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit_mm <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) ggplot2::autoplot(fit_mm, type = "calibration", bins = 4) ggplot2::autoplot(fit_mm, type = "ranef_caterpillar", title = "My title", ylab = "Mode" ) ggplot2::autoplot(fit_mm, type = "all")dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit_mm <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) ggplot2::autoplot(fit_mm, type = "calibration", bins = 4) ggplot2::autoplot(fit_mm, type = "ranef_caterpillar", title = "My title", ylab = "Mode" ) ggplot2::autoplot(fit_mm, type = "all")
Bayesian information criterion
## S3 method for class 'brs' BIC(object, ...)## S3 method for class 'brs' BIC(object, ...)
object |
A fitted |
... |
Ignored. |
Scalar BIC value.
brs, logLik.brs, AIC.brs,
brs_gof
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) BIC(fit)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) BIC(fit)
BIC for brsmm models
## S3 method for class 'brsmm' BIC(object, ...)## S3 method for class 'brsmm' BIC(object, ...)
object |
A fitted |
... |
Currently ignored. |
Numeric scalar.
brsmm, logLik.brsmm,
AIC.brsmm, brs_gof
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) BIC(fit)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) BIC(fit)
Unified interface that dispatches to brs_fit_fixed
(fixed dispersion) or brs_fit_var (variable
dispersion) based on the formula structure.
brs( formula, data, link = "logit", link_phi = "logit", ncuts = 100L, lim = 0.5, repar = 2L, method = c("BFGS", "L-BFGS-B"), hessian_method = c("numDeriv", "optim") )brs( formula, data, link = "logit", link_phi = "logit", ncuts = 100L, lim = 0.5, repar = 2L, method = c("BFGS", "L-BFGS-B"), hessian_method = c("numDeriv", "optim") )
formula |
A |
data |
Data frame. |
link |
Mean link function (default |
link_phi |
Dispersion link function (default |
ncuts |
Number of scale categories (default 100). |
lim |
Uncertainty half-width (default 0.5). |
repar |
Reparameterization scheme (default 2). |
method |
Optimization method (default |
hessian_method |
Character: |
If the formula contains a | separator
(e.g., y ~ x1 + x2 | z1), the variable-dispersion model is
fitted; otherwise, a fixed-dispersion model is used.
An object of class "brs".
Lopes, J. E. (2023). Modelos de regressao beta para dados de escala. Master's dissertation, Universidade Federal do Parana, Curitiba. URI: https://hdl.handle.net/1884/86624.
Hawker, G. A., Mian, S., Kendzerska, T., and French, M. (2011). Measures of adult pain: Visual Analog Scale for Pain (VAS Pain), Numeric Rating Scale for Pain (NRS Pain), McGill Pain Questionnaire (MPQ), Short-Form McGill Pain Questionnaire (SF-MPQ), Chronic Pain Grade Scale (CPGS), Short Form-36 Bodily Pain Scale (SF-36 BPS), and Measure of Intermittent and Constant Osteoarthritis Pain (ICOAP). Arthritis Care and Research, 63(S11), S240-S252. doi:10.1002/acr.20543
Hjermstad, M. J., Fayers, P. M., Haugen, D. F., et al. (2011). Studies comparing Numerical Rating Scales, Verbal Rating Scales, and Visual Analogue Scales for assessment of pain intensity in adults: a systematic literature review. Journal of Pain and Symptom Management, 41(6), 1073-1093. doi:10.1016/j.jpainsymman.2010.08.016
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), x2 = rep(c(0, 0, 1, 1), 5) ) prep <- brs_prep(dat, ncuts = 100) # Fixed dispersion fit1 <- brs(y ~ x1, data = prep) print(fit1) # Variable dispersion fit2 <- brs(y ~ x1 | x2, data = prep) print(fit2)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), x2 = rep(c(0, 0, 1, 1), 5) ) prep <- brs_prep(dat, ncuts = 100) # Fixed dispersion fit1 <- brs(y ~ x1, data = prep) print(fit1) # Variable dispersion fit2 <- brs(y ~ x1 | x2, data = prep) print(fit2)
Computes bootstrap-based confidence intervals for the parameters of a
fitted "brs" model by repeatedly simulating data from the fitted
model and re-estimating parameters. Only "brs" (fixed or
variable-dispersion) objects are supported; "brsmm" is not supported.
brs_bootstrap( object, R = 199L, level = 0.95, ci_type = c("percentile", "basic", "normal", "bca"), max_tries = NULL, keep_draws = FALSE ) ## S3 method for class 'brs_bootstrap' print(x, ...)brs_bootstrap( object, R = 199L, level = 0.95, ci_type = c("percentile", "basic", "normal", "bca"), max_tries = NULL, keep_draws = FALSE ) ## S3 method for class 'brs_bootstrap' print(x, ...)
object |
A fitted |
R |
Integer: number of bootstrap replicates (default 199). |
level |
Numeric: confidence level (default 0.95). |
ci_type |
Character: type of confidence interval. One of
|
max_tries |
Optional integer: maximum number of bootstrap attempts
to obtain converged replicates. If |
keep_draws |
Logical: if |
x |
Object returned by |
... |
Ignored. |
For each replicate, data are simulated via brs_sim using
the estimated coefficients (on the link scale) and the original
design. The model is then re-fitted with brs. Replicates
that fail to converge are discarded; if the number of successful replicates
is too low, a warning is issued. Intervals are the empirical quantiles of
the bootstrap distribution of each parameter.
A data frame with columns parameter, estimate
(original point estimate), se_boot (bootstrap standard error),
ci_lower, ci_upper, mcse_lower, mcse_upper,
wald_lower, wald_upper, and level. The attribute
"n_success" gives the number of replicates that converged.
Additional attributes include "R", "n_attempted",
"ci_type", and optionally "boot_draws".
print(brs_bootstrap): Print method for bootstrap results
confint.brs for Wald intervals;
brs_sim for simulation; brs for fitting.
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), x2 = rep(c(0, 0, 1, 1), 5) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) boot <- brs_bootstrap(fit, R = 50, level = 0.95) print(boot)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), x2 = rep(c(0, 0, 1, 1), 5) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) boot <- brs_bootstrap(fit, R = 50, level = 0.95) print(boot)
Produces a visual summary of the censoring structure in a fitted
"brs" model or a response matrix produced by
brs_check. The summary includes:
Bar chart of censoring type counts
Histogram of midpoint responses colored by censoring type
Interval plot showing segments
Proportion table of censoring types
brs_cens( object, n_sample = 100L, which = 1:4, caption = NULL, gg = FALSE, title = "Censoring diagnostic overview", sub.caption = NULL, theme = NULL, palette = NULL, inform = FALSE, ... )brs_cens( object, n_sample = 100L, which = 1:4, caption = NULL, gg = FALSE, title = "Censoring diagnostic overview", sub.caption = NULL, theme = NULL, palette = NULL, inform = FALSE, ... )
object |
A fitted |
n_sample |
Integer: maximum number of observations to show in the interval plot (default 100). If the data has more observations, a random sample is drawn. |
which |
Integer vector selecting which panels to draw
(default |
caption |
Optional panel captions. Accepts a character vector (or list coercible to character) with up to 4 labels, in the order: burden, midpoint-by-type, width-by-type, ordered interval map. |
gg |
Logical: use ggplot2? (default |
title |
Optional global title for the plotting page. |
sub.caption |
Optional subtitle/caption for the plotting page. |
theme |
Optional ggplot2 theme object (e.g., |
palette |
Optional named character vector with colors for censoring
types |
inform |
Logical; if |
... |
Further arguments (currently ignored). |
Invisibly returns a data frame with censoring counts and proportions, percentages, and interpretation flags.
Lopes, J. E. (2023). Modelos de regressao beta para dados de escala. Master's dissertation, Universidade Federal do Parana, Curitiba. URI: https://hdl.handle.net/1884/86624.
Hawker, G. A., Mian, S., Kendzerska, T., and French, M. (2011). Measures of adult pain: Visual Analog Scale for Pain (VAS Pain), Numeric Rating Scale for Pain (NRS Pain), McGill Pain Questionnaire (MPQ), Short-Form McGill Pain Questionnaire (SF-MPQ), Chronic Pain Grade Scale (CPGS), Short Form-36 Bodily Pain Scale (SF-36 BPS), and Measure of Intermittent and Constant Osteoarthritis Pain (ICOAP). Arthritis Care and Research, 63(S11), S240-S252. doi:10.1002/acr.20543
Hjermstad, M. J., Fayers, P. M., Haugen, D. F., et al. (2011). Studies comparing Numerical Rating Scales, Verbal Rating Scales, and Visual Analogue Scales for assessment of pain intensity in adults: a systematic literature review. Journal of Pain and Symptom Management, 41(6), 1073-1093. doi:10.1016/j.jpainsymman.2010.08.016
y <- c(0, 3, 5, 7, 10) Y <- brs_check(y, ncuts = 10) brs_cens(Y) prep <- brs_prep(data.frame(y = y), ncuts = 10) brs_cens(prep)y <- c(0, 3, 5, 7, 10) Y <- brs_check(y, ncuts = 10) brs_cens(Y) prep <- brs_prep(data.frame(y = y), ncuts = 10) brs_cens(prep)
Takes a discrete (or continuous) response on the scale
(where ncuts) and converts
it to a pair of interval endpoints on the open unit interval
. Each observation is classified into one of four
censoring types following the complete likelihood used in this package:
Uncensored (exact): the observation is a
continuous value already in . The likelihood
contribution is the density .
Endpoints: (or when on
the scale).
Left-censored: the latent value is below
some upper bound . The contribution is
.
When the observation is at the scale minimum (),
the upper bound is .
When the user forces on a non-boundary
observation (), the upper bound is
, preserving observation-
specific variation. In both cases .
Right-censored: the latent value is above
some lower bound . The contribution is
.
When the observation is at the scale maximum (),
the lower bound is .
When the user forces on a non-boundary
observation (), the lower bound is
, preserving observation-
specific variation. In both cases .
Interval-censored: the standard case for
scale data. The contribution is
with midpoint interval
endpoints .
brs_check(y, ncuts = 100L, lim = 0.5, delta = NULL)brs_check(y, ncuts = 100L, lim = 0.5, delta = NULL)
y |
Numeric vector: the raw response. Can be either
integer scores on the scale |
ncuts |
Integer: number of scale categories |
lim |
Numeric: half-width |
delta |
Integer vector or If provided, must have the same length as This parameter is used internally by the simulation functions
when the analyst forces a specific censoring type
(e.g., |
Automatic classification (delta = NULL):
If the entire input vector is already in (i.e., all
values satisfy ), all observations are treated as
uncensored ().
Otherwise, for scale (integer) data:
: left-censored ().
: right-censored ().
: interval-censored ().
User-supplied delta (delta vector):
When the delta argument is provided, the user-supplied
censoring indicators override the automatic boundary-based rules
on a per-observation basis. This is the mechanism used by
brs_sim when the analyst forces a
specific censoring type in Monte Carlo studies.
The endpoint formulas for each delta value are:
|
Condition | (left) |
(right) |
| 0 | |
|
|
| 0 | on scale |
|
|
| 1 | (boundary) |
|
|
| 1 | (forced) |
|
|
| 2 | (boundary) |
|
|
| 2 | (forced) |
|
|
| 3 | midpoint interval |
|
|
All endpoints are clamped to with
to avoid boundary issues in the beta
likelihood.
The midpoint approximation yt is computed as:
when (continuous data).
when is on the integer scale.
This value is used exclusively as an initialization aid for starting-value computation and does not enter the likelihood.
Interaction with the fitting pipeline:
This function is called internally by .extract_response()
when the data does not carry the "is_prepared"
attribute. If data has already been processed by
brs_prep or by simulation with forced delta
(brs_sim with delta != NULL),
the pre-computed columns are used directly and
brs_check() is skipped.
A numeric matrix with rows and 5 columns:
leftLower endpoint on ,
clamped to .
rightUpper endpoint on ,
clamped to .
ytMidpoint approximation for
starting-value computation (does not enter the likelihood).
yOriginal response value (preserved unchanged).
deltaCensoring indicator: 0 = exact (density),
1 = left-censored , 2 = right-censored
, 3 = interval-censored .
Lopes, J. E. (2023). Modelos de regressao beta para dados de escala. Master's dissertation, Universidade Federal do Parana, Curitiba. URI: https://hdl.handle.net/1884/86624.
Hawker, G. A., Mian, S., Kendzerska, T., and French, M. (2011). Measures of adult pain: Visual Analog Scale for Pain (VAS Pain), Numeric Rating Scale for Pain (NRS Pain), McGill Pain Questionnaire (MPQ), Short-Form McGill Pain Questionnaire (SF-MPQ), Chronic Pain Grade Scale (CPGS), Short Form-36 Bodily Pain Scale (SF-36 BPS), and Measure of Intermittent and Constant Osteoarthritis Pain (ICOAP). Arthritis Care and Research, 63(S11), S240-S252. doi:10.1002/acr.20543
Hjermstad, M. J., Fayers, P. M., Haugen, D. F., et al. (2011). Studies comparing Numerical Rating Scales, Verbal Rating Scales, and Visual Analogue Scales for assessment of pain intensity in adults: a systematic literature review. Journal of Pain and Symptom Management, 41(6), 1073-1093. doi:10.1016/j.jpainsymman.2010.08.016
brs_prep for the analyst-facing
pre-processing function; brs_sim
for simulation with forced delta.
# Scale data with boundary observations y <- c(0, 3, 5, 7, 9, 10) brs_check(y, ncuts = 10) # Force all observations to be exact (delta = 0) brs_check(y, ncuts = 10, delta = rep(0L, length(y))) # Force delta = 1 on non-boundary observations: # endpoints use actual y values, preserving variation y2 <- c(30, 60) brs_check(y2, ncuts = 100, delta = c(1L, 1L)) # left = (eps, eps), right = (30.5/100, 60.5/100)# Scale data with boundary observations y <- c(0, 3, 5, 7, 9, 10) brs_check(y, ncuts = 10) # Force all observations to be exact (delta = 0) brs_check(y, ncuts = 10, delta = rep(0L, length(y))) # Force delta = 1 on non-boundary observations: # endpoints use actual y values, preserving variation y2 <- c(30, 60) brs_check(y2, ncuts = 100, delta = c(1L, 1L)) # left = (eps, eps), right = (30.5/100, 60.5/100)
Deprecated convenience wrapper. Use brs_est for coefficient
estimates or summary.brs for a full model summary.
brs_coef(fit, alpha = 0.05)brs_coef(fit, alpha = 0.05)
fit |
A fitted |
alpha |
Significance level. |
A list with components est (from brs_est)
and gof (from brs_gof).
Lopes, J. E. (2023). Modelos de regressao beta para dados de escala. Master's dissertation, Universidade Federal do Parana, Curitiba. URI: https://hdl.handle.net/1884/86624.
Ferrari, S. L. P., and Cribari-Neto, F. (2004). Beta regression for modelling rates and proportions. Journal of Applied Statistics, 31(7), 799–815. doi:10.1080/0266476042000214501
Hawker, G. A., Mian, S., Kendzerska, T., and French, M. (2011). Measures of adult pain: Visual Analog Scale for Pain (VAS Pain), Numeric Rating Scale for Pain (NRS Pain), McGill Pain Questionnaire (MPQ), Short-Form McGill Pain Questionnaire (SF-MPQ), Chronic Pain Grade Scale (CPGS), Short Form-36 Bodily Pain Scale (SF-36 BPS), and Measure of Intermittent and Constant Osteoarthritis Pain (ICOAP). Arthritis Care and Research, 63(S11), S240-S252. doi:10.1002/acr.20543
Hjermstad, M. J., Fayers, P. M., Haugen, D. F., et al. (2011). Studies comparing Numerical Rating Scales, Verbal Rating Scales, and Visual Analogue Scales for assessment of pain intensity in adults: a systematic literature review. Journal of Pain and Symptom Management, 41(6), 1073-1093. doi:10.1016/j.jpainsymman.2010.08.016
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) suppressWarnings(brs_coef(fit)) # deprecated; use brs_est()dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) suppressWarnings(brs_coef(fit)) # deprecated; use brs_est()
Performs repeated k-fold cross-validation for brs models.
brs_cv(formula, data, k = 5L, repeats = 1L, ...)brs_cv(formula, data, k = 5L, repeats = 1L, ...)
formula |
Model formula passed to |
data |
Data frame. |
k |
Number of folds. |
repeats |
Number of repeated k-fold runs. |
... |
Additional arguments forwarded to |
The log_score is the mean log predictive contribution under the
complete likelihood contribution implied by each observation's
censoring type (delta).
A data frame with one row per fold and columns:
repeat, fold, n_train, n_test,
log_score, rmse_yt, mae_yt, converged,
and error. The object has class "brs_cv".
Lopes, J. E. (2023). Modelos de regressao beta para dados de escala. Master's dissertation, Universidade Federal do Parana, Curitiba. URI: https://hdl.handle.net/1884/86624.
Hawker, G. A., Mian, S., Kendzerska, T., and French, M. (2011). Measures of adult pain: Visual Analog Scale for Pain (VAS Pain), Numeric Rating Scale for Pain (NRS Pain), McGill Pain Questionnaire (MPQ), Short-Form McGill Pain Questionnaire (SF-MPQ), Chronic Pain Grade Scale (CPGS), Short Form-36 Bodily Pain Scale (SF-36 BPS), and Measure of Intermittent and Constant Osteoarthritis Pain (ICOAP). Arthritis Care and Research, 63(S11), S240-S252. doi:10.1002/acr.20543
Hjermstad, M. J., Fayers, P. M., Haugen, D. F., et al. (2011). Studies comparing Numerical Rating Scales, Verbal Rating Scales, and Visual Analogue Scales for assessment of pain intensity in adults: a systematic literature review. Journal of Pain and Symptom Management, 41(6), 1073-1093. doi:10.1016/j.jpainsymman.2010.08.016
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), x2 = rep(c(0, 0, 1, 1), 5) ) prep <- brs_prep(dat, ncuts = 100) cv <- brs_cv(y ~ x1, data = prep, k = 3, repeats = 1) cvdat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), x2 = rep(c(0, 0, 1, 1), 5) ) prep <- brs_prep(dat, ncuts = 100) cv <- brs_cv(y ~ x1, data = prep, k = 3, repeats = 1) cv
Coefficient estimates with inference
brs_est(object, alpha = 0.05)brs_est(object, alpha = 0.05)
object |
A fitted |
alpha |
Significance level (default 0.05). |
Data frame of estimates, standard errors, z-values, and p-values.
Lopes, J. E. (2023). Modelos de regressao beta para dados de escala. Master's dissertation, Universidade Federal do Parana, Curitiba. URI: https://hdl.handle.net/1884/86624.
Ferrari, S. L. P., and Cribari-Neto, F. (2004). Beta regression for modelling rates and proportions. Journal of Applied Statistics, 31(7), 799–815. doi:10.1080/0266476042000214501
Hawker, G. A., Mian, S., Kendzerska, T., and French, M. (2011). Measures of adult pain: Visual Analog Scale for Pain (VAS Pain), Numeric Rating Scale for Pain (NRS Pain), McGill Pain Questionnaire (MPQ), Short-Form McGill Pain Questionnaire (SF-MPQ), Chronic Pain Grade Scale (CPGS), Short Form-36 Bodily Pain Scale (SF-36 BPS), and Measure of Intermittent and Constant Osteoarthritis Pain (ICOAP). Arthritis Care and Research, 63(S11), S240-S252. doi:10.1002/acr.20543
Hjermstad, M. J., Fayers, P. M., Haugen, D. F., et al. (2011). Studies comparing Numerical Rating Scales, Verbal Rating Scales, and Visual Analogue Scales for assessment of pain intensity in adults: a systematic literature review. Journal of Pain and Symptom Management, 41(6), 1073-1093. doi:10.1016/j.jpainsymman.2010.08.016
brs, brs_gof, brs_hessian,
summary.brs
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) brs_est(fit)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) brs_est(fit)
Goodness-of-fit measures
brs_gof(object)brs_gof(object)
object |
A fitted |
Data frame with logLik, AIC, BIC, and pseudo-R-squared.
Lopes, J. E. (2023). Modelos de regressao beta para dados de escala. Master's dissertation, Universidade Federal do Parana, Curitiba. URI: https://hdl.handle.net/1884/86624.
Hawker, G. A., Mian, S., Kendzerska, T., and French, M. (2011). Measures of adult pain: Visual Analog Scale for Pain (VAS Pain), Numeric Rating Scale for Pain (NRS Pain), McGill Pain Questionnaire (MPQ), Short-Form McGill Pain Questionnaire (SF-MPQ), Chronic Pain Grade Scale (CPGS), Short Form-36 Bodily Pain Scale (SF-36 BPS), and Measure of Intermittent and Constant Osteoarthritis Pain (ICOAP). Arthritis Care and Research, 63(S11), S240-S252. doi:10.1002/acr.20543
Hjermstad, M. J., Fayers, P. M., Haugen, D. F., et al. (2011). Studies comparing Numerical Rating Scales, Verbal Rating Scales, and Visual Analogue Scales for assessment of pain intensity in adults: a systematic literature review. Journal of Pain and Symptom Management, 41(6), 1073-1093. doi:10.1016/j.jpainsymman.2010.08.016
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) brs_gof(fit)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) brs_gof(fit)
Extract the Hessian matrix
brs_hessian(object)brs_hessian(object)
object |
A fitted |
Numeric Hessian matrix.
Lopes, J. E. (2023). Modelos de regressao beta para dados de escala. Master's dissertation, Universidade Federal do Parana, Curitiba. URI: https://hdl.handle.net/1884/86624.
Hawker, G. A., Mian, S., Kendzerska, T., and French, M. (2011). Measures of adult pain: Visual Analog Scale for Pain (VAS Pain), Numeric Rating Scale for Pain (NRS Pain), McGill Pain Questionnaire (MPQ), Short-Form McGill Pain Questionnaire (SF-MPQ), Chronic Pain Grade Scale (CPGS), Short Form-36 Bodily Pain Scale (SF-36 BPS), and Measure of Intermittent and Constant Osteoarthritis Pain (ICOAP). Arthritis Care and Research, 63(S11), S240-S252. doi:10.1002/acr.20543
Hjermstad, M. J., Fayers, P. M., Haugen, D. F., et al. (2011). Studies comparing Numerical Rating Scales, Verbal Rating Scales, and Visual Analogue Scales for assessment of pain intensity in adults: a systematic literature review. Journal of Pain and Symptom Management, 41(6), 1073-1093. doi:10.1016/j.jpainsymman.2010.08.016
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) brs_hessian(fit)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) brs_hessian(fit)
Computes average marginal effects (AME) for numeric covariates in the
mean or precision submodel of a fitted "brs" object.
brs_marginaleffects( object, newdata = NULL, model = c("mean", "precision"), type = c("response", "link"), variables = NULL, h = 1e-05, interval = TRUE, level = 0.95, n_sim = 400L, keep_draws = FALSE )brs_marginaleffects( object, newdata = NULL, model = c("mean", "precision"), type = c("response", "link"), variables = NULL, h = 1e-05, interval = TRUE, level = 0.95, n_sim = 400L, keep_draws = FALSE )
object |
A fitted |
newdata |
Optional data frame for evaluation; defaults to the data used in fitting. |
model |
Character; |
type |
Character prediction scale:
|
variables |
Optional character vector of covariate names. Defaults to all numeric covariates in the selected submodel. |
h |
Finite-difference step for non-binary numeric covariates. |
interval |
Logical; compute interval estimates via simulation. |
level |
Confidence level for interval estimates. |
n_sim |
Number of parameter draws when |
keep_draws |
Logical; if |
AMEs are computed by finite differences on predictions:
where is the selected prediction scale.
For binary covariates coded as 0/1, the effect is computed as the
average discrete difference .
If interval = TRUE, uncertainty is approximated by asymptotic
parameter simulation from .
A data frame with one row per variable and columns:
variable, ame, std.error, ci.lower,
ci.upper, model, type, and n.
The returned object has class "brs_marginaleffects" and
attributes with analysis metadata.
Lopes, J. E. (2023). Modelos de regressao beta para dados de escala. Master's dissertation, Universidade Federal do Parana, Curitiba. URI: https://hdl.handle.net/1884/86624.
Hawker, G. A., Mian, S., Kendzerska, T., and French, M. (2011). Measures of adult pain: Visual Analog Scale for Pain (VAS Pain), Numeric Rating Scale for Pain (NRS Pain), McGill Pain Questionnaire (MPQ), Short-Form McGill Pain Questionnaire (SF-MPQ), Chronic Pain Grade Scale (CPGS), Short Form-36 Bodily Pain Scale (SF-36 BPS), and Measure of Intermittent and Constant Osteoarthritis Pain (ICOAP). Arthritis Care and Research, 63(S11), S240-S252. doi:10.1002/acr.20543
Hjermstad, M. J., Fayers, P. M., Haugen, D. F., et al. (2011). Studies comparing Numerical Rating Scales, Verbal Rating Scales, and Visual Analogue Scales for assessment of pain intensity in adults: a systematic literature review. Journal of Pain and Symptom Management, 41(6), 1073-1093. doi:10.1016/j.jpainsymman.2010.08.016
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), x2 = rep(c(0, 0, 1, 1), 5) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) brs_marginaleffects(fit, model = "mean", type = "response")dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), x2 = rep(c(0, 0, 1, 1), 5) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) brs_marginaleffects(fit, model = "mean", type = "response")
Computes predicted probabilities for integer scores on the original scale
implied by the fitted beta interval model.
brs_predict_scoreprob( object, newdata = NULL, scores = NULL, format = c("matrix", "long"), id_col = "id" )brs_predict_scoreprob( object, newdata = NULL, scores = NULL, format = c("matrix", "long"), id_col = "id" )
object |
A fitted |
newdata |
Optional data frame for prediction. |
scores |
Optional integer vector of scores to evaluate.
Defaults to all scores in |
format |
Output format: |
id_col |
Column name for observation id when |
For a score and ncuts, probabilities are computed as:
for ,
for ,
for ,
where is the beta CDF under the fitted .
If format = "matrix", a numeric matrix with one row per
observation and one column per requested score.
If format = "long", a long data frame with columns
id_col, score, and prob.
Lopes, J. E. (2023). Modelos de regressao beta para dados de escala. Master's dissertation, Universidade Federal do Parana, Curitiba. URI: https://hdl.handle.net/1884/86624.
Hawker, G. A., Mian, S., Kendzerska, T., and French, M. (2011). Measures of adult pain: Visual Analog Scale for Pain (VAS Pain), Numeric Rating Scale for Pain (NRS Pain), McGill Pain Questionnaire (MPQ), Short-Form McGill Pain Questionnaire (SF-MPQ), Chronic Pain Grade Scale (CPGS), Short Form-36 Bodily Pain Scale (SF-36 BPS), and Measure of Intermittent and Constant Osteoarthritis Pain (ICOAP). Arthritis Care and Research, 63(S11), S240-S252. doi:10.1002/acr.20543
Hjermstad, M. J., Fayers, P. M., Haugen, D. F., et al. (2011). Studies comparing Numerical Rating Scales, Verbal Rating Scales, and Visual Analogue Scales for assessment of pain intensity in adults: a systematic literature review. Journal of Pain and Symptom Management, 41(6), 1073-1093. doi:10.1016/j.jpainsymman.2010.08.016
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), x2 = rep(c(0, 0, 1, 1), 5) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) pmat <- brs_predict_scoreprob(fit) head(pmat[, 1:5]) plong <- brs_predict_scoreprob(fit, scores = 0:10, format = "long") head(plong)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), x2 = rep(c(0, 0, 1, 1), 5) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) pmat <- brs_predict_scoreprob(fit) head(pmat[, 1:5]) plong <- brs_predict_scoreprob(fit, scores = 0:10, format = "long") head(plong)
Validates and transforms raw data into the format required by
brs.
The analyst can supply data in several ways:
Minimal (Mode 1): only the score y.
Censoring is inferred automatically:
, ,
,
.
Classic (Mode 2): y + explicit
delta. The analyst declares the censoring type;
interval endpoints are computed using the actual y
value.
Interval (Mode 3): left and/or
right columns (on the original scale). Censoring is
inferred from the NA pattern.
Full (Mode 4): y, left, and
right together. The analyst's own endpoints are
rescaled directly to .
All covariate columns are preserved unchanged in the output.
brs_prep( data, y = "y", delta = "delta", left = "left", right = "right", ncuts = 100L, lim = 0.5 )brs_prep( data, y = "y", delta = "delta", left = "left", right = "right", ncuts = 100L, lim = 0.5 )
data |
Data frame containing the response variable and covariates. |
y |
Character: name of the score column (default |
delta |
Character: name of the censoring indicator column
(default |
left |
Character: name of the left-endpoint column
(default |
right |
Character: name of the right-endpoint column
(default |
ncuts |
Integer: number of scale categories (default 100). |
lim |
Numeric: half-width of the uncertainty region
(default 0.5). Used only when constructing intervals from |
Priority rule: if delta is provided (non-NA),
it takes precedence over all automatic classification rules.
When delta is NA, the function infers the censoring type
from the pattern of left, right, and y:
left |
right |
y |
delta
|
Interpretation | Inferred |
NA |
5 | NA |
NA
|
Left-censored (below 5) | 1 |
| 20 | NA |
NA |
NA
|
Right-censored (above 20) | 2 |
| 30 | 45 | NA |
NA
|
Interval-censored [30, 45] | 3 |
NA |
NA |
50 | NA
|
Exact observation | 0 |
NA |
NA |
50 | 3 | Analyst says interval | 3 |
NA |
NA |
0 | 1 | Analyst says left-censored | 1 |
NA |
NA |
99 | 2 | Analyst says right-censored | 2 |
When y, left, and right are all present for the
same observation, the analyst's left/right values are
used directly (rescaled by ncuts) and delta
is set to 3 (interval-censored) unless the analyst supplied
delta explicitly.
Endpoint formulas for Mode 2 (y + explicit delta):
When the analyst supplies delta explicitly, the endpoint
computation uses the actual y value to produce
observation-specific bounds. This is the same logic used by
brs_check with a user-supplied delta
vector:
|
Condition | (left)
|
(right) |
| 0 | (any) | |
|
| 1 | |
|
|
| 1 | |
|
|
| 2 | |
|
|
| 2 | |
|
|
| 3 | type "m" |
|
|
Consistency warnings: when the analyst supplies delta
values that are unusual for the given y (e.g.,
but ), the function emits a warning
but proceeds. This is by design for Monte Carlo workflows where
forced delta on non-boundary observations is intentional.
All endpoints are clamped to with
.
A data.frame with the following columns appended or
replaced:
leftLower endpoint on .
rightUpper endpoint on .
ytMidpoint approximation on .
yOriginal scale value (preserved for reference).
deltaCensoring indicator: 0 = exact, 1 = left, 2 = right, 3 = interval.
Covariate columns are preserved.
The output carries attributes "is_prepared" (TRUE),
"ncuts" and "lim" so that
brs can detect prepared data and skip the
internal brs_check call.
Lopes, J. E. (2023). Modelos de regressao beta para dados de escala. Master's dissertation, Universidade Federal do Parana, Curitiba. URI: https://hdl.handle.net/1884/86624.
Hawker, G. A., Mian, S., Kendzerska, T., and French, M. (2011). Measures of adult pain: Visual Analog Scale for Pain (VAS Pain), Numeric Rating Scale for Pain (NRS Pain), McGill Pain Questionnaire (MPQ), Short-Form McGill Pain Questionnaire (SF-MPQ), Chronic Pain Grade Scale (CPGS), Short Form-36 Bodily Pain Scale (SF-36 BPS), and Measure of Intermittent and Constant Osteoarthritis Pain (ICOAP). Arthritis Care and Research, 63(S11), S240-S252. doi:10.1002/acr.20543
Hjermstad, M. J., Fayers, P. M., Haugen, D. F., et al. (2011). Studies comparing Numerical Rating Scales, Verbal Rating Scales, and Visual Analogue Scales for assessment of pain intensity in adults: a systematic literature review. Journal of Pain and Symptom Management, 41(6), 1073-1093. doi:10.1016/j.jpainsymman.2010.08.016
brs_check for the automatic
classification of raw scale scores;
brs for fitting the model.
# --- Mode 1: y only (automatic classification, like brs_check) --- d1 <- data.frame(y = c(0, 3, 5, 7, 10), x1 = rnorm(5)) brs_prep(d1, ncuts = 10) # --- Mode 2: y + explicit delta --- d2 <- data.frame( y = d1$y, delta = c(0, 3, 3, 3, 0), # Force interval-censoring for 3,5,7 x1 = d1$x1 ) brs_prep(d2, ncuts = 100) # --- Mode 3: left/right with NA patterns --- d3 <- data.frame( left = c(NA, 20, 30, NA), right = c(5, NA, 45, NA), y = c(NA, NA, NA, 50), x1 = d1$x1[1:4] ) brs_prep(d3, ncuts = 100) # --- Mode 4: y + left + right (analyst-supplied intervals) --- d4 <- data.frame( y = c(50, 75), left = c(48, 73), right = c(52, 77), x1 = rnorm(2) ) brs_prep(d4, ncuts = 100) # --- Fitting after prep --- dat5 <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep5 <- brs_prep(dat5, ncuts = 100) fit5 <- brs(y ~ x1, data = prep5) summary(fit5)# --- Mode 1: y only (automatic classification, like brs_check) --- d1 <- data.frame(y = c(0, 3, 5, 7, 10), x1 = rnorm(5)) brs_prep(d1, ncuts = 10) # --- Mode 2: y + explicit delta --- d2 <- data.frame( y = d1$y, delta = c(0, 3, 3, 3, 0), # Force interval-censoring for 3,5,7 x1 = d1$x1 ) brs_prep(d2, ncuts = 100) # --- Mode 3: left/right with NA patterns --- d3 <- data.frame( left = c(NA, 20, 30, NA), right = c(5, NA, 45, NA), y = c(NA, NA, NA, 50), x1 = d1$x1[1:4] ) brs_prep(d3, ncuts = 100) # --- Mode 4: y + left + right (analyst-supplied intervals) --- d4 <- data.frame( y = c(50, 75), left = c(48, 73), right = c(52, 77), x1 = rnorm(2) ) brs_prep(d4, ncuts = 100) # --- Fitting after prep --- dat5 <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep5 <- brs_prep(dat5, ncuts = 100) fit5 <- brs(y ~ x1, data = prep5) summary(fit5)
Converts a mean–dispersion pair to the shape
parameters of the beta distribution under one of
three reparameterization schemes.
brs_repar(mu, phi, repar = 2L)brs_repar(mu, phi, repar = 2L)
mu |
Numeric vector of mean values in |
phi |
Numeric vector (or scalar) of dispersion values. |
repar |
Integer (0, 1, or 2) selecting the scheme. |
The three schemes are:
repar = 0Direct: .
repar = 1Ferrari–Cribari-Neto:
, where
acts as a precision parameter.
repar = 2Mean–variance:
,
where is analogous to a coefficient
of variation.
A data.frame with columns shape1 and
shape2.
Lopes, J. E. (2023). Modelos de regressao beta para dados de escala. Master's dissertation, Universidade Federal do Parana, Curitiba. URI: https://hdl.handle.net/1884/86624.
Hawker, G. A., Mian, S., Kendzerska, T., and French, M. (2011). Measures of adult pain: Visual Analog Scale for Pain (VAS Pain), Numeric Rating Scale for Pain (NRS Pain), McGill Pain Questionnaire (MPQ), Short-Form McGill Pain Questionnaire (SF-MPQ), Chronic Pain Grade Scale (CPGS), Short Form-36 Bodily Pain Scale (SF-36 BPS), and Measure of Intermittent and Constant Osteoarthritis Pain (ICOAP). Arthritis Care and Research, 63(S11), S240-S252. doi:10.1002/acr.20543
Hjermstad, M. J., Fayers, P. M., Haugen, D. F., et al. (2011). Studies comparing Numerical Rating Scales, Verbal Rating Scales, and Visual Analogue Scales for assessment of pain intensity in adults: a systematic literature review. Journal of Pain and Symptom Management, 41(6), 1073-1093. doi:10.1016/j.jpainsymman.2010.08.016
brs_repar(mu = 0.5, phi = 0.2, repar = 2)brs_repar(mu = 0.5, phi = 0.2, repar = 2)
Simulates interval-censored responses from fixed- or variable-dispersion beta regression models.
brs_sim( formula, data, beta, phi = 1/5, zeta = NULL, link = "logit", link_phi = "logit", ncuts = 100L, lim = 0.5, repar = 2L, delta = NULL )brs_sim( formula, data, beta, phi = 1/5, zeta = NULL, link = "logit", link_phi = "logit", ncuts = 100L, lim = 0.5, repar = 2L, delta = NULL )
formula |
Model formula with one (mean) or two parts
(mean |
data |
Data frame with predictor variables. |
beta |
Numeric vector of mean-model coefficients. |
phi |
Scalar dispersion parameter (link scale), used only for one-part formulas. |
zeta |
Numeric vector of precision-model coefficients (link scale), required for two-part formulas. |
link |
Mean link function. |
link_phi |
Precision link function. |
ncuts |
Number of scale categories. |
lim |
Half-width used in interval construction. |
repar |
Reparameterization scheme. |
delta |
Forced censoring type ( |
The model structure is controlled by formula in the same style as
brs:
one-part formula (~ x1 + x2 or y ~ x1 + x2):
fixed dispersion using scalar phi.
two-part formula (~ x1 + x2 | z1 or y ~ x1 + x2 | z1):
variable dispersion using coefficient vector zeta.
The delta argument can force a single censoring type
(0,1,2,3) for all observations; otherwise, censoring is classified
automatically from simulated scale values via brs_check.
A data frame with columns left, right, yt,
y, delta, plus simulated predictor columns from the model
matrices. When delta != NULL, the output carries
attr(, "is_prepared") = TRUE.
Lopes, J. E. (2023). Modelos de regressao beta para dados de escala. Master's dissertation, Universidade Federal do Parana, Curitiba. URI: https://hdl.handle.net/1884/86624.
Hawker, G. A., Mian, S., Kendzerska, T., and French, M. (2011). Measures of adult pain: Visual Analog Scale for Pain (VAS Pain), Numeric Rating Scale for Pain (NRS Pain), McGill Pain Questionnaire (MPQ), Short-Form McGill Pain Questionnaire (SF-MPQ), Chronic Pain Grade Scale (CPGS), Short Form-36 Bodily Pain Scale (SF-36 BPS), and Measure of Intermittent and Constant Osteoarthritis Pain (ICOAP). Arthritis Care and Research, 63(S11), S240-S252. doi:10.1002/acr.20543
Hjermstad, M. J., Fayers, P. M., Haugen, D. F., et al. (2011). Studies comparing Numerical Rating Scales, Verbal Rating Scales, and Visual Analogue Scales for assessment of pain intensity in adults: a systematic literature review. Journal of Pain and Symptom Management, 41(6), 1073-1093. doi:10.1016/j.jpainsymman.2010.08.016
dat <- data.frame( x1 = rep(c(1, 2), 10), x2 = rep(c(0, 0, 1, 1), 5) ) # Fixed dispersion sim_fixed <- brs_sim( formula = ~ x1 + x2, data = dat, beta = c(0.2, -0.5, 0.3), phi = 1 / 5 ) # Variable dispersion sim_var <- brs_sim( formula = ~ x1 | x2, data = dat, beta = c(0.2, -0.5), zeta = c(0.5, -0.5) )dat <- data.frame( x1 = rep(c(1, 2), 10), x2 = rep(c(0, 0, 1, 1), 5) ) # Fixed dispersion sim_fixed <- brs_sim( formula = ~ x1 + x2, data = dat, beta = c(0.2, -0.5, 0.3), phi = 1 / 5 ) # Variable dispersion sim_var <- brs_sim( formula = ~ x1 | x2, data = dat, beta = c(0.2, -0.5), zeta = c(0.5, -0.5) )
Builds a comparison table for one or more fitted "brs" objects,
summarizing fit statistics and (optionally) censoring composition.
brs_table( ..., models = NULL, include_censoring = TRUE, sort_by = c("none", "AIC", "BIC", "logLik"), decreasing = FALSE, digits = 4L )brs_table( ..., models = NULL, include_censoring = TRUE, sort_by = c("none", "AIC", "BIC", "logLik"), decreasing = FALSE, digits = 4L )
... |
Fitted |
models |
Optional list of fitted |
include_censoring |
Logical; include censoring counts/proportions.
Default is |
sort_by |
Character; optional sort criterion:
|
decreasing |
Logical; sort direction when |
digits |
Integer number of digits used for numeric rounding. |
A data frame with one row per model.
Lopes, J. E. (2023). Modelos de regressao beta para dados de escala. Master's dissertation, Universidade Federal do Parana, Curitiba. URI: https://hdl.handle.net/1884/86624.
Hawker, G. A., Mian, S., Kendzerska, T., and French, M. (2011). Measures of adult pain: Visual Analog Scale for Pain (VAS Pain), Numeric Rating Scale for Pain (NRS Pain), McGill Pain Questionnaire (MPQ), Short-Form McGill Pain Questionnaire (SF-MPQ), Chronic Pain Grade Scale (CPGS), Short Form-36 Bodily Pain Scale (SF-36 BPS), and Measure of Intermittent and Constant Osteoarthritis Pain (ICOAP). Arthritis Care and Research, 63(S11), S240-S252. doi:10.1002/acr.20543
Hjermstad, M. J., Fayers, P. M., Haugen, D. F., et al. (2011). Studies comparing Numerical Rating Scales, Verbal Rating Scales, and Visual Analogue Scales for assessment of pain intensity in adults: a systematic literature review. Journal of Pain and Symptom Management, 41(6), 1073-1093. doi:10.1016/j.jpainsymman.2010.08.016
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), x2 = rep(c(0, 0, 1, 1), 5) ) prep <- brs_prep(dat, ncuts = 100) m1 <- brs(y ~ 1, data = prep) m2 <- brs(y ~ x1, data = prep) brs_table(null = m1, x1 = m2, sort_by = "AIC")dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), x2 = rep(c(0, 0, 1, 1), 5) ) prep <- brs_prep(dat, ncuts = 100) m1 <- brs(y ~ 1, data = prep) m2 <- brs(y ~ x1, data = prep) brs_table(null = m1, x1 = m2, sort_by = "AIC")
Fits a beta interval-censored mixed model with Gaussian random
intercepts/slopes using marginal maximum likelihood. The implementation supports
random-effects formulas such as ~ 1 | group and ~ 1 + x | group,
and offers three integration methods for the
random effects: Laplace approximation, Adaptive Gauss-Hermite Quadrature
(AGHQ), and Quasi-Monte Carlo (QMC).
brsmm( formula, random = ~1 | id, data, link = "logit", link_phi = "logit", repar = 2L, ncuts = 100L, lim = 0.5, int_method = c("laplace", "aghq", "qmc"), n_points = 11L, qmc_points = 1024L, start = NULL, method = c("BFGS", "L-BFGS-B"), hessian_method = c("numDeriv", "optim"), control = list(maxit = 2000L) )brsmm( formula, random = ~1 | id, data, link = "logit", link_phi = "logit", repar = 2L, ncuts = 100L, lim = 0.5, int_method = c("laplace", "aghq", "qmc"), n_points = 11L, qmc_points = 1024L, start = NULL, method = c("BFGS", "L-BFGS-B"), hessian_method = c("numDeriv", "optim"), control = list(maxit = 2000L) )
formula |
Model formula. Supports one- or two-part formulas:
|
random |
Random-effects specification of the form
|
data |
Data frame. |
link |
Mean link function. |
link_phi |
Precision link function. |
repar |
Beta reparameterization code (0, 1, 2). |
ncuts |
Number of categories on the original scale. |
lim |
Half-width used to construct interval endpoints. |
int_method |
Integration method: |
n_points |
Number of quadrature points for |
qmc_points |
Number of QMC points for |
start |
Optional numeric vector of starting values
( |
method |
Optimizer passed to |
hessian_method |
|
control |
Control list for |
The conditional contribution for each observation follows the same mixed
censoring likelihood used by brs:
: exact contribution via beta density,
: left-censored contribution via beta CDF,
: right-censored contribution via survival CDF,
: interval contribution via CDF difference.
For group , the random-effects vector
is integrated out numerically.
"laplace": Uses a second-order Laplace approximation at the
conditional mode. Fast and generally accurate for large.
"aghq": Adaptive Gauss-Hermite Quadrature. Uses n_points
quadrature nodes centered and scaled by the conditional mode and curvature.
More accurate than Laplace, especially for small .
"qmc": Quasi-Monte Carlo integration using a Halton sequence.
Uses qmc_points evaluation points. Suitable for high-dimensional
integration (future proofing) or checking robustness.
An object of class "brsmm".
Lopes, J. E. (2023). Modelos de regressao beta para dados de escala. Master's dissertation, Universidade Federal do Parana, Curitiba. URI: https://hdl.handle.net/1884/86624.
Ferrari, S. L. P., and Cribari-Neto, F. (2004). Beta regression for modelling rates and proportions. Journal of Applied Statistics, 31(7), 799–815. doi:10.1080/0266476042000214501
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit_mm <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) fit_mmdat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit_mm <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) fit_mm
Provides a compact numeric study of random effects, including: estimated covariance matrix, correlation matrix, per-term standard deviations, empirical mean/SD of posterior modes, shrinkage ratio, and a normality check by Shapiro-Wilk (when applicable).
brsmm_re_study(object, ...)brsmm_re_study(object, ...)
object |
A fitted |
... |
Currently ignored. |
A list with class "brsmm_re_study".
Lopes, J. E. (2023). Modelos de regressao beta para dados de escala. Master's dissertation, Universidade Federal do Parana, Curitiba. URI: https://hdl.handle.net/1884/86624.
Ferrari, S. L. P., and Cribari-Neto, F. (2004). Beta regression for modelling rates and proportions. Journal of Applied Statistics, 31(7), 799–815. doi:10.1080/0266476042000214501
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) rs <- brsmm_re_study(fit) print(rs) rs$summarydat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) rs <- brsmm_re_study(fit) print(rs) rs$summary
Extract model coefficients
## S3 method for class 'brs' coef(object, model = c("full", "mean", "precision"), ...)## S3 method for class 'brs' coef(object, model = c("full", "mean", "precision"), ...)
object |
A fitted |
model |
Character: which component to return.
|
... |
Ignored. |
Named numeric vector of estimated parameters.
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) coef(fit) coef(fit, model = "mean") coef(fit, model = "precision")dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) coef(fit) coef(fit, model = "mean") coef(fit, model = "precision")
Extract coefficients from a brsmm fit
## S3 method for class 'brsmm' coef(object, model = c("full", "mean", "precision", "random"), ...)## S3 method for class 'brsmm' coef(object, model = c("full", "mean", "precision", "random"), ...)
object |
A fitted |
model |
Character: |
... |
Currently ignored. |
Named numeric vector.
brsmm, vcov.brsmm,
confint.brsmm
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) coef(fit) coef(fit, model = "mean") coef(fit, model = "random")dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) coef(fit) coef(fit, model = "mean") coef(fit, model = "random")
Computes Wald confidence intervals for model parameters using the normal approximation.
## S3 method for class 'brs' confint( object, parm, level = 0.95, model = c("full", "mean", "precision"), ... )## S3 method for class 'brs' confint( object, parm, level = 0.95, model = c("full", "mean", "precision"), ... )
object |
A fitted |
parm |
Character or integer: which parameters. If missing, all parameters are returned. |
level |
Confidence level (default 0.95). |
model |
Character: |
... |
Currently ignored. |
Matrix with columns for lower and upper confidence bounds.
brs, coef.brs, vcov.brs,
brs_est
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) confint(fit) confint(fit, model = "mean")dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) confint(fit) confint(fit, model = "mean")
Wald confidence intervals for brsmm models
## S3 method for class 'brsmm' confint( object, parm, level = 0.95, model = c("full", "mean", "precision", "random"), ... )## S3 method for class 'brsmm' confint( object, parm, level = 0.95, model = c("full", "mean", "precision", "random"), ... )
object |
A fitted |
parm |
Character or integer: which parameters. |
level |
Confidence level (default 0.95). |
model |
Character: |
... |
Currently ignored. |
Matrix with columns for lower and upper confidence bounds.
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) confint(fit, model = "mean")dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) confint(fit, model = "mean")
Extract fitted values
## S3 method for class 'brs' fitted(object, type = c("mu", "phi"), ...)## S3 method for class 'brs' fitted(object, type = c("mu", "phi"), ...)
object |
A fitted |
type |
Character: |
... |
Currently ignored. |
Numeric vector of fitted values.
brs, residuals.brs,
predict.brs
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) head(fitted(fit)) head(fitted(fit, type = "phi"))dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) head(fitted(fit)) head(fitted(fit, type = "phi"))
Fitted values from a brsmm model
## S3 method for class 'brsmm' fitted(object, type = c("mu", "phi"), ...)## S3 method for class 'brsmm' fitted(object, type = c("mu", "phi"), ...)
object |
A fitted |
type |
Character: |
... |
Currently ignored. |
Numeric vector.
brsmm, residuals.brsmm,
predict.brsmm
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) head(fitted(fit)) head(fitted(fit, type = "phi"))dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) head(fitted(fit)) head(fitted(fit, type = "phi"))
Extract model formula
## S3 method for class 'brs' formula(x, ...)## S3 method for class 'brs' formula(x, ...)
x |
A fitted |
... |
Ignored. |
The formula used to fit the model.
brs, model.matrix.brs,
coef.brs
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) formula(fit)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) formula(fit)
Extract model formula
## S3 method for class 'brsmm' formula(x, ...)## S3 method for class 'brsmm' formula(x, ...)
x |
A fitted |
... |
Ignored. |
The formula used to fit the model.
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) formula(fit)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) formula(fit)
Extract log-likelihood
## S3 method for class 'brs' logLik(object, ...)## S3 method for class 'brs' logLik(object, ...)
object |
A fitted |
... |
Ignored. |
An object of class "logLik" with attributes
df (number of estimated parameters) and nobs
(number of observations).
brs, AIC.brs, BIC.brs,
brs_gof
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) logLik(fit)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) logLik(fit)
Log-likelihood for brsmm models
## S3 method for class 'brsmm' logLik(object, ...)## S3 method for class 'brsmm' logLik(object, ...)
object |
A fitted |
... |
Currently ignored. |
Object of class "logLik".
brsmm, AIC.brsmm,
BIC.brsmm, brs_gof
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) logLik(fit)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) logLik(fit)
Extract design matrix
## S3 method for class 'brs' model.matrix(object, model = c("mean", "precision"), ...)## S3 method for class 'brs' model.matrix(object, model = c("mean", "precision"), ...)
object |
A fitted |
model |
Character: |
... |
Ignored. |
The design matrix for the specified submodel.
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) head(model.matrix(fit)) head(model.matrix(fit, model = "precision"))dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) head(model.matrix(fit)) head(model.matrix(fit, model = "precision"))
Extract design matrix
## S3 method for class 'brsmm' model.matrix(object, model = c("mean", "precision", "random"), ...)## S3 method for class 'brsmm' model.matrix(object, model = c("mean", "precision", "random"), ...)
object |
A fitted |
model |
Character: |
... |
Ignored. |
The design matrix for the specified submodel.
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) head(model.matrix(fit)) head(model.matrix(fit, model = "random"))dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) head(model.matrix(fit)) head(model.matrix(fit, model = "random"))
Number of observations
## S3 method for class 'brs' nobs(object, ...)## S3 method for class 'brs' nobs(object, ...)
object |
A fitted |
... |
Ignored. |
Integer: number of observations.
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) nobs(fit)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) nobs(fit)
Number of observations in a brsmm fit
## S3 method for class 'brsmm' nobs(object, ...)## S3 method for class 'brsmm' nobs(object, ...)
object |
A fitted |
... |
Currently ignored. |
Integer.
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) nobs(fit)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) nobs(fit)
Produces up to six diagnostic plots for a fitted
"brs" model: residuals vs indices, Cook's
distance, residuals vs linear predictor, residuals vs fitted
values, a half-normal plot with simulated envelope, and
predicted vs observed.
## S3 method for class 'brs' plot( x, which = 1:4, type = "rqr", nsim = 100L, level = 0.9, caption = c("Residuals vs indices", "Cook's distance", "Residuals vs linear predictor", "Residuals vs fitted values", "Half-normal plot", "Predicted vs observed"), sub.caption = NULL, ask = prod(par("mfcol")) < length(which) && dev.interactive(), gg = FALSE, title = NULL, theme = NULL, ... )## S3 method for class 'brs' plot( x, which = 1:4, type = "rqr", nsim = 100L, level = 0.9, caption = c("Residuals vs indices", "Cook's distance", "Residuals vs linear predictor", "Residuals vs fitted values", "Half-normal plot", "Predicted vs observed"), sub.caption = NULL, ask = prod(par("mfcol")) < length(which) && dev.interactive(), gg = FALSE, title = NULL, theme = NULL, ... )
x |
A fitted |
which |
Integer vector selecting which plots to draw
(default |
type |
Character: residual type passed to
|
nsim |
Integer: number of simulations for the half-normal envelope (default 100). |
level |
Numeric: confidence level for the envelope (default 0.9). |
caption |
Character vector of panel captions. |
sub.caption |
Subtitle; defaults to the model call. |
ask |
Logical: prompt before each page of plots? |
gg |
Logical: use ggplot2? (default |
title |
Optional global title for ggplot output. If |
theme |
Optional ggplot2 theme object (e.g., |
... |
Further arguments passed to base |
Invisibly returns x.
brs, residuals.brs,
autoplot.brs
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) plot(fit, which = 1:4)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) plot(fit, which = 1:4)
Produces diagnostic plots for fitted "brsmm" models:
residuals vs indices, Cook's distance, residuals vs linear predictor,
residuals vs fitted values, half-normal envelope, and predicted vs observed.
## S3 method for class 'brsmm' plot( x, which = 1:4, type = c("response", "pearson"), nsim = 100L, level = 0.9, caption = c("Residuals vs indices", "Cook's distance", "Residuals vs linear predictor", "Residuals vs fitted values", "Half-normal plot", "Predicted vs observed", "Random-effects Q-Q", "Random-effects caterpillar"), sub.caption = NULL, ask = prod(par("mfcol")) < length(which) && dev.interactive(), gg = FALSE, title = NULL, theme = NULL, ... )## S3 method for class 'brsmm' plot( x, which = 1:4, type = c("response", "pearson"), nsim = 100L, level = 0.9, caption = c("Residuals vs indices", "Cook's distance", "Residuals vs linear predictor", "Residuals vs fitted values", "Half-normal plot", "Predicted vs observed", "Random-effects Q-Q", "Random-effects caterpillar"), sub.caption = NULL, ask = prod(par("mfcol")) < length(which) && dev.interactive(), gg = FALSE, title = NULL, theme = NULL, ... )
x |
A fitted |
which |
Integer vector selecting which panels to draw
(default |
type |
Residual type passed to |
nsim |
Number of simulations for half-normal envelope. |
level |
Confidence level for the half-normal envelope. |
caption |
Character vector of plot captions. |
sub.caption |
Optional subtitle; defaults to model call. |
ask |
Logical: prompt before each new page? |
gg |
Logical: use ggplot2 backend? |
title |
Optional global title for ggplot output. If |
theme |
Optional ggplot2 theme object (e.g., |
... |
Further arguments passed to base |
Invisibly returns x.
brsmm, residuals.brsmm,
autoplot.brsmm
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) plot(fit, which = 1:4)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) plot(fit, which = 1:4)
Predict from a fitted model
## S3 method for class 'brs' predict( object, newdata = NULL, type = c("response", "link", "precision", "variance", "quantile"), at = 0.5, ... )## S3 method for class 'brs' predict( object, newdata = NULL, type = c("response", "link", "precision", "variance", "quantile"), at = 0.5, ... )
object |
A fitted |
newdata |
Optional data frame for prediction. |
type |
Prediction type: |
at |
Numeric vector of probabilities for quantile predictions (default 0.5). |
... |
Currently ignored. |
Numeric vector or matrix.
brs, fitted.brs,
brs_predict_scoreprob
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) head(predict(fit)) head(predict(fit, type = "precision")) newdat <- data.frame(x1 = c(1, 2)) predict(fit, newdata = newdat)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) head(predict(fit)) head(predict(fit, type = "precision")) newdat <- data.frame(x1 = c(1, 2)) predict(fit, newdata = newdat)
Predict from a brsmm model
## S3 method for class 'brsmm' predict( object, newdata = NULL, type = c("response", "link", "precision", "variance", "quantile"), at = 0.5, ... )## S3 method for class 'brsmm' predict( object, newdata = NULL, type = c("response", "link", "precision", "variance", "quantile"), at = 0.5, ... )
object |
A fitted |
newdata |
Optional data frame. |
type |
Character: |
at |
Numeric vector of probabilities for quantile predictions (default 0.5). |
... |
Currently ignored. |
Numeric vector.
brsmm, fitted.brsmm,
brs_predict_scoreprob
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) head(predict(fit)) head(predict(fit, type = "precision"))dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) head(predict(fit)) head(predict(fit, type = "precision"))
Print a fitted model (brief betareg style)
## S3 method for class 'brs' print(x, digits = max(3, getOption("digits") - 3), ...)## S3 method for class 'brs' print(x, digits = max(3, getOption("digits") - 3), ...)
x |
A fitted |
digits |
Number of significant digits. |
... |
Included for consistency with generic methods. Currently passed to internal methods where applicable. |
Invisibly returns the input object x. The function is called
for its side effect of printing a formatted summary of the fitted model
to the console, including the model call, mean coefficients (with link
function), and precision coefficients (with link function).
summary.brs, print.summary.brs,
brs
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) print(fit)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) print(fit)
Print a fitted brsmm model
## S3 method for class 'brsmm' print(x, digits = max(3, getOption("digits") - 3), ...)## S3 method for class 'brsmm' print(x, digits = max(3, getOption("digits") - 3), ...)
x |
A fitted |
digits |
Number of digits. |
... |
Included for consistency with generic methods. |
Invisibly returns x.
summary.brsmm, print.summary.brsmm,
brsmm
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) print(fit)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) print(fit)
Prints a compact summary of the random-effects study returned by
brsmm_re_study, including per-term standard deviations,
shrinkage ratios, Shapiro-Wilk p-values, and the estimated covariance
and correlation matrices.
## S3 method for class 'brsmm_re_study' print(x, digits = max(3, getOption("digits") - 3), ...)## S3 method for class 'brsmm_re_study' print(x, digits = max(3, getOption("digits") - 3), ...)
x |
A |
digits |
Integer: number of significant digits for rounding
(default |
... |
Currently ignored. |
Invisibly returns x. Called for its side-effect of
printing the study to the console.
brsmm_re_study, brsmm,
ranef.brsmm
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) rs <- brsmm_re_study(fit) print(rs)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) rs <- brsmm_re_study(fit) print(rs)
Print a model summary (betareg style)
## S3 method for class 'summary.brs' print(x, digits = max(3, getOption("digits") - 3), ...)## S3 method for class 'summary.brs' print(x, digits = max(3, getOption("digits") - 3), ...)
x |
A |
digits |
Number of digits. |
... |
Passed to |
Invisibly returns the input object x. The function is called
for its side effect of printing a comprehensive summary to the console,
including the model call, quantile residuals, coefficient tables for mean
and precision submodels with significance stars, goodness-of-fit statistics
(log-likelihood, pseudo R-squared), optimization details, and censoring
information.
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) print(summary(fit))dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) print(summary(fit))
Print summary for brsmm models
## S3 method for class 'summary.brsmm' print(x, digits = max(3, getOption("digits") - 3), ...)## S3 method for class 'summary.brsmm' print(x, digits = max(3, getOption("digits") - 3), ...)
x |
A |
digits |
Number of digits. |
... |
Passed to |
Invisibly returns x.
summary.brsmm, brsmm,
print.brsmm
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) print(summary(fit))dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) print(summary(fit))
Generic function for extracting random effects.
ranef(object, ...)ranef(object, ...)
object |
A fitted model object. |
... |
Additional arguments passed to methods. |
Method-specific; for "brsmm" objects, a matrix or named
numeric vector of group-specific random-effect modes.
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) ranef(fit)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) ranef(fit)
Extract random effects from a brsmm model
## S3 method for class 'brsmm' ranef(object, ...)## S3 method for class 'brsmm' ranef(object, ...)
object |
A fitted |
... |
Currently ignored. |
A matrix or named numeric vector of group-specific random-effect posterior modes.
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) ranef(fit)dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) ranef(fit)
Extract residuals
## S3 method for class 'brs' residuals( object, type = c("response", "pearson", "deviance", "rqr", "weighted", "sweighted"), ... )## S3 method for class 'brs' residuals( object, type = c("response", "pearson", "deviance", "rqr", "weighted", "sweighted"), ... )
object |
A fitted |
type |
Residual type. One of |
... |
Currently ignored. |
For Pearson residuals the variance formula depends on the
reparameterization stored in object$repar:
V = mu(1 - mu) / (1 + phi)
V = mu(1 - mu) * phi
The weighted and sweighted residuals use the digamma/trigamma
formulation from the precision parameterization (repar = 1),
so internal conversion is applied when repar != 1.
Numeric vector of residuals.
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) head(residuals(fit)) head(residuals(fit, type = "pearson"))dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) head(residuals(fit)) head(residuals(fit, type = "pearson"))
Residuals from a brsmm model
## S3 method for class 'brsmm' residuals( object, type = c("response", "pearson", "deviance", "rqr", "weighted", "sweighted"), ... )## S3 method for class 'brsmm' residuals( object, type = c("response", "pearson", "deviance", "rqr", "weighted", "sweighted"), ... )
object |
A fitted |
type |
Character: |
... |
Currently ignored. |
Numeric vector.
brsmm, fitted.brsmm,
plot.brsmm
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) head(residuals(fit)) head(residuals(fit, type = "pearson"))dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) head(residuals(fit)) head(residuals(fit, type = "pearson"))
Summarize a fitted model (betareg style)
## S3 method for class 'brs' summary(object, ...)## S3 method for class 'brs' summary(object, ...)
object |
A fitted |
... |
Ignored. |
A list of class "summary.betaregscale".
brs, print.summary.brs,
brs_est, brs_gof
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) s <- summary(fit) s$coefficients$meandat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) s <- summary(fit) s$coefficients$mean
Summarize a fitted brsmm model
## S3 method for class 'brsmm' summary(object, ...)## S3 method for class 'brsmm' summary(object, ...)
object |
A fitted |
... |
Currently ignored. |
Object of class "summary.brsmm".
brsmm, print.summary.brsmm,
brs_gof, brsmm_re_study
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) s <- summary(fit) s$coefficients$meandat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) s <- summary(fit) s$coefficients$mean
Variance-covariance matrix of estimated coefficients
## S3 method for class 'brs' vcov(object, model = c("full", "mean", "precision"), ...)## S3 method for class 'brs' vcov(object, model = c("full", "mean", "precision"), ...)
object |
A fitted |
model |
Character: which component ( |
... |
Ignored. |
A square numeric matrix.
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) vcov(fit) vcov(fit, model = "mean")dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10) ) prep <- brs_prep(dat, ncuts = 100) fit <- brs(y ~ x1, data = prep) vcov(fit) vcov(fit, model = "mean")
Variance-covariance matrix for brsmm coefficients
## S3 method for class 'brsmm' vcov(object, model = c("full", "mean", "precision", "random"), ...)## S3 method for class 'brsmm' vcov(object, model = c("full", "mean", "precision", "random"), ...)
object |
A fitted |
model |
Character: |
... |
Currently ignored. |
Numeric matrix.
brsmm, coef.brsmm,
confint.brsmm
dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) vcov(fit, model = "mean")dat <- data.frame( y = c( 0, 5, 20, 50, 75, 90, 100, 30, 60, 45, 10, 40, 55, 70, 85, 25, 35, 65, 80, 15 ), x1 = rep(c(1, 2), 10), id = factor(rep(1:4, each = 5)) ) prep <- brs_prep(dat, ncuts = 100) fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep) vcov(fit, model = "mean")