Title: Quick Bayesian Regression Models Using 'INLA' with 'brms' Syntax
Version: 1.0.1
Date: 2025-11-26
Maintainer: Tony Myers <admyers@aol.com>
Description: Provides a 'brms'-like interface for fitting Bayesian regression models using 'INLA' (Integrated Nested Laplace Approximations) and 'TMB' (Template Model Builder). The package offers faster model fitting while maintaining familiar 'brms' syntax and output formats. Supports fixed and mixed effects models, multiple probability distributions, conditional effects plots, and posterior predictive checks with summary methods compatible with 'brms'. 'TMB' integration provides fast ordinal regression capabilities. Implements methods adapted from 'emmeans' for marginal means estimation and 'bayestestR' for Bayesian inference assessment. Methods are based on Rue et al. (2009) <doi:10.1111/j.1467-9868.2008.00700.x>, Kristensen et al. (2016) <doi:10.18637/jss.v070.i05>, Lenth (2016) <doi:10.18637/jss.v069.i01>, Bürkner (2017) <doi:10.18637/jss.v080.i01>, Makowski et al. (2019) <doi:10.21105/joss.01541>, and Kruschke (2014, ISBN:9780124058880).
License: MIT + file LICENSE
Encoding: UTF-8
Language: en-GB
RoxygenNote: 7.3.2
Depends: R (≥ 4.0.0)
Imports: methods, ggplot2, mvtnorm, cowplot, lme4, patchwork, posterior, scales, shiny, miniUI, future, future.apply, loo, TMB, jsonlite
Suggests: testthat (≥ 3.0.0), INLA, knitr, rmarkdown, DHARMa, MASS, ordinal, rstudioapi, emmeans, bayestestR, gridExtra, data.table, tibble, quantreg, readxl, haven
LinkingTo: Rcpp, RcppEigen, TMB
Config/testthat/edition: 3
URL: https://github.com/Tony-Myers/qbrms
BugReports: https://github.com/Tony-Myers/qbrms/issues
Additional_repositories: https://inla.r-inla-download.org/R/stable/
VignetteBuilder: knitr
NeedsCompilation: yes
Packaged: 2025-12-04 18:58:52 UTC; tonymyers
Author: Tony Myers ORCID iD [aut, cre]
Repository: CRAN
Date/Publication: 2025-12-10 21:10:13 UTC

qbrms: Quick Bayesian Regression Models using INLA

Description

The qbrms package provides a brms-like interface for fitting Bayesian regression models using INLA (Integrated Nested Laplace Approximations). It offers faster model fitting while maintaining familiar brms syntax and output formats.

Details

The main function is qbrms which fits Bayesian models using INLA with brms-like syntax. The package supports:

Author(s)

Tony Myers

See Also

Useful links:


Add comprehensive post-fitting diagnostics

Description

Add comprehensive post-fitting diagnostics

Usage

.add_comprehensive_diagnostics(fit_result, pre_diagnostics, verbose)

Add Reference Distributions

Description

Add Reference Distributions

Usage

.add_reference_distributions(p, xlim, prior_info)

Analyse grouping structure

Description

Analyse grouping structure

Usage

.analyse_group_structure(formula, data, y, min_group_size, verbose)

Description

Apply inverse link function

Usage

.apply_inverse_link(linear_pred, family_name)

Apply Single Prior Specification

Description

Apply Single Prior Specification

Usage

.apply_single_prior_spec_standalone(prior_spec, prior_specs, coef_names)

Apply threshold constraints manually (fallback)

Description

Apply threshold constraints manually (fallback)

Usage

.apply_threshold_constraints(raw_params, n_thresh)

Arguments

raw_params

Raw parameter vector

n_thresh

Number of thresholds

Value

Constrained threshold values


Assess group-specific problems

Description

Assess group-specific problems

Usage

.assess_group_problems(diagnostics, group_info, verbose)

Data augmentation for model stability

Description

Data augmentation for model stability

Usage

.augment_data_for_stability(data, formula, verbose = TRUE)

Intelligent data augmentation

Description

Intelligent data augmentation

Usage

.augment_data_intelligent(formula, data, diagnostics, verbose)

Compute Bayesian R-squared exactly as in brms

Description

Compute Bayesian R-squared exactly as in brms

Usage

.bayes_R2_brms_style(y, ypred)

Check Convergence

Description

Check Convergence

Usage

.check_convergence(model)

Check for global separation issues

Description

Check for global separation issues

Usage

.check_global_separation(diagnostics, success_rate, verbose)

Check for Influential Observations

Description

Check for Influential Observations

Usage

.check_influential_observations(model)

Check Model Fit

Description

Check Model Fit

Usage

.check_model_fit(model)

Check Posterior Distribution

Description

Check Posterior Distribution

Usage

.check_posterior(model)

Check Residuals

Description

Check Residuals

Usage

.check_residuals(model)

Check for sparse outcomes

Description

Check for sparse outcomes

Usage

.check_sparse_outcomes(diagnostics, success_rate, n_obs, verbose)

Choose optimal fitting strategy

Description

Choose optimal fitting strategy

Usage

.choose_fitting_strategy(diagnostics, verbose)

Improved Threshold Prior Computation - ENHANCED VERSION

Description

Improved Threshold Prior Computation - ENHANCED VERSION

Usage

.compute_improved_threshold_priors(y_ordered, verbose = TRUE)

Arguments

y_ordered

Ordered factor response

verbose

Logical; print diagnostics

Value

List with improved threshold priors


Compute Robust Variance-Covariance Matrix - CORRECTED VERSION

Description

Compute Robust Variance-Covariance Matrix - CORRECTED VERSION

Usage

.compute_robust_vcov(obj, opt, verbose = FALSE)

Arguments

obj

TMB object

opt

Optimization result

verbose

Logical; print diagnostics

Value

Variance-covariance matrix with method attribute


Compute Threshold Standard Errors Using Delta Method - NEW FUNCTION

Description

Compute Threshold Standard Errors Using Delta Method - NEW FUNCTION

Usage

.compute_threshold_se_delta_method(
  raw_params,
  post_cov,
  n_thresh,
  verbose = FALSE
)

Arguments

raw_params

Raw parameter vector from optimization

post_cov

Covariance matrix of raw parameters

n_thresh

Number of thresholds

verbose

Logical; print diagnostics

Value

Vector of threshold standard errors


Convert lme4-style formula to INLA format

Description

Convert lme4-style formula to INLA format

Usage

.convert_to_inla_formula(formula)

Create balanced augmented observations

Description

Create balanced augmented observations

Usage

.create_balanced_augmentation(data, formula, n_aug, diagnostics, verbose)

Create Base Density Plot

Description

Create Base Density Plot

Usage

.create_density_base_plot(
  plot_densities,
  colours,
  alpha_levels,
  parameter,
  verbose
)

Create Ordinal Routing Object

Description

Create Ordinal Routing Object

Usage

.create_ordinal_routing_object(family, family_name)

Arguments

family

Original family object

family_name

Extracted family name

Value

Routing object for ordinal regression


Create Prior-Only Plot

Description

Create Prior-Only Plot

Usage

.create_prior_only_plot(
  yrep,
  type = "dens_overlay",
  ndraws = NULL,
  verbose = TRUE
)

Create Synthetic Data for Prior Checks

Description

Create Synthetic Data for Prior Checks

Usage

.create_synthetic_data(formula, n_obs, predictor_values = NULL, verbose = TRUE)

Determine X-axis Limits

Description

Determine X-axis Limits

Usage

.determine_xlim(samples, prior_info)

Internal function to diagnose binomial issues

Description

Internal function to diagnose binomial issues

Usage

.diagnose_binomial_issues(formula, data, verbose = TRUE)

Comprehensive diagnostic assessment

Description

Comprehensive diagnostic assessment

Usage

.diagnose_comprehensive(formula, data, min_group_size, verbose)

Drop random-effect terms from a formula

Description

Drop random-effect terms from a formula

Usage

.drop_random_effects(fml)

Remove random effects from formula for design matrix creation

Description

Remove random effects from formula for design matrix creation

Usage

.drop_random_effects_for_r2(formula)

Estimate random effects variance from data - CORRECTED

Description

Estimate random effects variance from data - CORRECTED

Usage

.estimate_random_effects_variance_from_data_corrected(object, verbose)

Evaluate Prior Density

Description

Evaluate Prior Density

Usage

.evaluate_prior_density(x, prior_info)

Export as JSON

Description

Export as JSON

Usage

.export_as_json(model, include_data, is_fitted)

Export as Markdown

Description

Export as Markdown

Usage

.export_as_markdown(model, include_data, include_diagnostics, is_fitted)

Export as R Script

Description

Export as R Script

Usage

.export_as_r_script(model, include_data, include_diagnostics, is_fitted)

Export as Plain Text

Description

Export as Plain Text

Usage

.export_as_text(model, include_data, include_diagnostics, is_fitted)

Extract group variable from formula

Description

Extract group variable from formula

Usage

.extract_group_variable(formula)

Extract INLA fitted values that include random effects - CORRECTED

Description

Extract INLA fitted values that include random effects - CORRECTED

Usage

.extract_inla_fitted_with_random_effects(object, ndraws, verbose)

Extract INLA marginals with random effects - CORRECTED

Description

Extract INLA marginals with random effects - CORRECTED

Usage

.extract_inla_marginals_with_random_effects(object, ndraws, verbose)

Extract Parameter Distribution Densities

Description

Extract Parameter Distribution Densities

Usage

.extract_parameter_densities(
  object,
  parameter,
  show_prior,
  ndraws,
  prior_ndraws,
  verbose
)

Extract Prior Specifications (Standalone Version)

Description

Extract Prior Specifications (Standalone Version)

Usage

.extract_prior_specs_standalone(prior, coef_names, verbose = TRUE)

Extract random effects variance - CORRECTED

Description

Extract random effects variance - CORRECTED

Usage

.extract_random_effects_variance_corrected(object, verbose)

Extract Response Distribution Densities

Description

Extract Response Distribution Densities

Usage

.extract_response_densities(
  object,
  show_prior,
  show_data,
  ndraws,
  prior_ndraws,
  verbose
)

Aggressive strategy

Description

Aggressive strategy

Usage

.fit_aggressive_strategy(formula, data, verbose, ...)

Enhanced strategy

Description

Enhanced strategy

Usage

.fit_enhanced_strategy(formula, data, regularisation_strength, verbose, ...)

Minimal strategy

Description

Minimal strategy

Usage

.fit_minimal_strategy(formula, data, verbose, ...)

Ridge regression fallback

Description

Ridge regression fallback

Usage

.fit_ridge_fallback(formula, data, verbose)

Core INLA fitting function

Description

Core INLA fitting function

Usage

.fit_with_inla_enhanced(
  formula,
  data,
  intercept_prior,
  slope_prior,
  control_strategy = "standard",
  verbose = TRUE,
  ...
)

Fit model using specified strategy

Description

Fit model using specified strategy

Usage

.fit_with_strategy(
  formula,
  data,
  strategy,
  regularisation_strength,
  diagnostics,
  verbose,
  ...
)

Format Prior Label

Description

Format Prior Label

Usage

.format_prior_label(prior_info)

Simplified prediction function for emmeans (avoids dimension issues)

Description

Simplified prediction function for emmeans (avoids dimension issues)

Usage

.generate_emmeans_predictions_simple(object, ref_data, prob = 0.95)

Generate posterior expected predicted values - CORRECTED for mixed models

Description

Generate posterior expected predicted values - CORRECTED for mixed models

Usage

.generate_posterior_epred_corrected(
  object,
  newdata,
  ndraws,
  is_mixed,
  is_original_data,
  verbose
)

Generate Prior-Only Samples

Description

Generate Prior-Only Samples

Usage

.generate_prior_only_samples(X, prior_specs, family, ndraws, verbose = TRUE)

Generate Prior Predictive Samples

Description

Generate Prior Predictive Samples

Usage

.generate_prior_predictive_samples(formula, data, family, prior, n_samples)

Generate random effects for one posterior draw - CORRECTED

Description

Generate random effects for one posterior draw - CORRECTED

Usage

.generate_random_effects_corrected(object, re_setup, draw_index, verbose)

Generate Response from Family Distribution

Description

Generate Response from Family Distribution

Usage

.generate_response_from_family(linear_pred, family_name, n_obs)

Description

Infer recommended families from a response vector

Usage

.infer_recommended_families(y, tol = 1e-08)

Build Formula

Description

Build Formula

Usage

.mb_build_formula(response, predictors, random_effects = NULL)

Characterise Response Variable

Description

Characterise Response Variable

Usage

.mb_characterise_response(y, var_name)

Create Family Object

Description

Create Family Object

Usage

.mb_create_family_object(family_name)

Generate Model Code

Description

Generate Model Code

Usage

.mb_generate_code(formula, family, prior, data_name)

Get Data from User

Description

Get Data from User

Usage

.mb_get_data()

Get Predictor Variables

Description

Get Predictor Variables

Usage

.mb_get_predictors(data, response)

Get Prior Specifications

Description

Get Prior Specifications

Usage

.mb_get_priors(family_choice, predictors, random_effects)

Get Random Effects Structure

Description

Get Random Effects Structure

Usage

.mb_get_random_effects(data, predictors)

Get Response Variable

Description

Get Response Variable

Usage

.mb_get_response(data)

Present Summary

Description

Present Summary

Usage

.mb_present_summary(formula, family, prior, model_code)

Let User Select Family

Description

Let User Select Family

Usage

.mb_select_family(suggestions, response_info)

Suggest Appropriate Families

Description

Suggest Appropriate Families

Usage

.mb_suggest_families(response_info)

Parse Prior Specification

Description

Parse Prior Specification

Usage

.parse_prior_specification(prior, parameter)

Parse Prior String

Description

Parse Prior String

Usage

.parse_prior_string(prior_str)

Prepare random effects structure - CORRECTED

Description

Prepare random effects structure - CORRECTED

Usage

.prepare_random_effects_corrected(object, newdata, verbose)

Print Diagnostic Summary

Description

Print Diagnostic Summary

Usage

.print_diagnostic_summary(overall_status, results)

Compute geometric covariance from design matrix properties

Description

Compute geometric covariance from design matrix properties

Usage

.qbrms__compute_geometric_covariance(object, V_current)

Compute leverage-aware confidence intervals

Description

Compute leverage-aware confidence intervals

Usage

.qbrms__compute_leverage_uncertainty(Xgrid, V, object, prob = 0.95)

Compute OLS covariance matrix as fallback

Description

Compute OLS covariance matrix as fallback

Usage

.qbrms__compute_ols_covariance(object)

Enhance covariance matrix to ensure proper correlations

Description

Enhance covariance matrix to ensure proper correlations

Usage

.qbrms__enhance_covariance_matrix(object, V_current, verbose = TRUE)

Generate spaghetti draws

Description

Generate spaghetti draws

Usage

.qbrms__generate_spaghetti_draws_corrected(object, Xgrid, V_used, ndraws)

Remove random effects from formula

Description

Remove random effects from formula

Usage

.qbrms__remove_random_effects(formula)

Reconstruct predictions manually - CORRECTED for mixed models

Description

Reconstruct predictions manually - CORRECTED for mixed models

Usage

.reconstruct_predictions_corrected(object, newdata, ndraws, is_mixed, verbose)

Regularize Hessian Matrix for Numerical Stability

Description

Regularize Hessian Matrix for Numerical Stability

Usage

.regularize_hessian(H, par, verbose = TRUE)

Arguments

H

Raw Hessian matrix

par

Parameter vector

verbose

Logical; print progress

Value

Regularized covariance matrix


Remove random effects from formula

Description

Remove random effects from formula

Usage

.remove_random_effects(formula)

Sample from INLA random effects posteriors - CORRECTED

Description

Sample from INLA random effects posteriors - CORRECTED

Usage

.sample_from_inla_random_effects(object, re_setup, verbose)

Sample from Prior Distribution

Description

Sample from Prior Distribution

Usage

.sample_from_prior(prior_info, n_samples)

Safe Prior Sampling

Description

Safe Prior Sampling

Usage

.sample_from_prior_safe(prior_spec)

Summarise Bayesian R-squared values

Description

Summarise Bayesian R-squared values

Usage

.summarise_bayes_r2(r2_values, robust, probs)

Validate qbrmb inputs

Description

Validate qbrmb inputs

Usage

.validate_qbrmb_inputs(formula, data, family, verbose)

Visualise Prior Comparison

Description

Visualise Prior Comparison

Usage

.visualise_prior_comparison(prior_list, parameter, xlim, samples)

Beta Family Constructor (Capital B)

Description

Beta distribution family for response variables in (0,1)

Usage

Beta(link = "logit", link.phi = "log")

Beta(link = "logit", link.phi = "log")

Arguments

link

Link function for the mean parameter (default: "logit")

link.phi

Link function for precision parameter (default: "log")

Value

A family object of class "family".

A family object for use with qbrms()

Examples

## Not run: 
# Beta regression for proportions
fit <- qbrms(proportion ~ predictor, data = data, family = Beta())

## End(Not run)


Gamma family (GLM-style)

Description

Gamma family constructor to avoid conflict with base::gamma.

Usage

Gamma(link = "log")

Arguments

link

Link function (default: "log")

Value

A family object of class "family".


Additional Statistical Families for qbrms

Description

Extended collection of statistical family constructors optimized for INLA integration and CRAN compatibility


Asymmetric Laplace for Quantile Regression

Description

Asymmetric Laplace for Quantile Regression

Usage

asymmetric_laplace()

Value

An object of class "family" representing the Asymmetric Laplace distribution.


Bayesian R-squared for qbrms Models

Description

Compute Bayesian R-squared values for qbrms regression models following the method of Gelman et al. (2019). This corrected version properly handles mixed-effects models to match brms output exactly.

Usage

bayes_R2(
  object,
  summary = TRUE,
  robust = FALSE,
  probs = c(0.025, 0.975),
  ndraws = 1000,
  newdata = NULL,
  verbose = TRUE
)

Arguments

object

A qbrms_fit object.

summary

Logical; if TRUE (default), return summary statistics. If FALSE, return the posterior draws.

robust

Logical; if TRUE, use robust summary statistics.

probs

Numeric vector of quantiles for summary (default: c(0.025, 0.975)).

ndraws

Number of posterior draws to use (default: 1000).

newdata

Optional data frame for predictions. If NULL, uses the original data.

verbose

Logical; print progress information.

Details

This implementation handles mixed-effects models by:

  1. Using INLA's fitted values that include random effects when available

  2. Correctly sampling random effects from their posterior distributions

  3. Properly accounting for the variance decomposition in mixed models

Value

If summary = TRUE, a matrix with summary statistics. If summary = FALSE, a vector of R-squared values from posterior draws.


Bayesian Hypothesis Testing (very simple approximations)

Description

Compute a crude Bayes factor for a point, interval, or comparison hypothesis using approximate posterior draws recovered from a qbrms_fit. This is deliberately simple and intended for exploratory use.

Usage

bayesfactor(
  object,
  hypothesis,
  prior = NULL,
  null = 0,
  direction = "two-sided",
  rope = NULL,
  nsim = 4000,
  verbose = TRUE
)

Arguments

object

A qbrms_fit object.

hypothesis

Character string, for example "Intercept > 0", "b_x = 0", or "b_x > 0.2".

prior

Optional prior information (unused here, kept for API compatibility).

null

Numeric null value for point tests (default 0).

direction

One of "two-sided", "greater", "less" (kept for API compatibility).

rope

Optional numeric length-2 vector c(lower, upper) to define a ROPE for point tests.

nsim

Number of posterior draws to simulate from the fitted summary.

verbose

Logical; print progress information.

Value

An object of class qbrms_bayesfactor.


Beta Binomial Family for Overdispersed Binary Data

Description

Beta Binomial Family for Overdispersed Binary Data

Usage

beta_binomial(link = "logit")

Arguments

link

Link function for probability parameter (default: "logit")

Value

A family object of class "family".


Specify Beta Prior Distribution

Description

Specify Beta Prior Distribution

Usage

beta_prior(alpha = 1, beta = 1)

Arguments

alpha

First shape parameter

beta

Second shape parameter

Value

A prior distribution object


Alternative Beta Parameterizations

Description

Alternative Beta Parameterizations

Usage

beta0(link = "logit")

beta1(link = "logit")

logitbeta(link = "logit")

Arguments

link

Link function (default: "logit")

Value

A family object of class "family".


Create a Bayesian Formula

Description

Function to set up a model formula for use in qbrms, allowing specification of distributional parameters (e.g., sigma) in addition to the mean structure.

Usage

bf(formula, ..., flist = NULL, family = NULL, nl = FALSE)

Arguments

formula

Main model formula (for the mean/location parameter).

...

Additional formulas for distributional parameters (e.g., sigma ~ x).

flist

Optional list of formulas (for internal use).

family

Same as in qbrms() (optional here).

nl

Logical; indicating if the model is non-linear (not yet fully supported).

Details

This function mimics the brms::bf() syntax to allow users familiar with brms to define distributional models.

Supported distributional parameters depend on the family:

Value

An object of class brmsformula (and qbrmsformula) containing the parsed formulas.

Examples

## Not run: 
# Standard model
f1 <- bf(y ~ x)

# Distributional model (heteroscedasticity)
# Sigma varies by group
f2 <- bf(y ~ x, sigma ~ group)

## End(Not run)


Binomial Family

Description

Binomial Family

Usage

binomial()

Value

An object of class "family" representing the Binomial distribution.


Build HTML Table with Enhanced Styling

Description

Build HTML Table with Enhanced Styling

Usage

build_html_table_styled(
  model_info,
  all_predictors,
  display_predictors,
  dv.labels,
  show.ci,
  show.rope,
  show.p_sig,
  show.pd,
  show.bf,
  show.intercept,
  show.r2,
  show.icc,
  show.nobs,
  digits,
  title,
  bootstrap,
  table.style,
  font.family,
  font.size,
  header.bg,
  stripe.bg,
  CSS,
  verbose = FALSE
)

Combine Multiple Prior Specifications

Description

Combine Multiple Prior Specifications

Usage

## S3 method for class 'qbrms_prior_spec'
c(...)

Arguments

...

Prior specification objects created by prior()

Value

A combined prior object


Specify Cauchy Prior Distribution

Description

Specify Cauchy Prior Distribution

Usage

cauchy(location = 0, scale = 1)

Arguments

location

Location parameter (default 0)

scale

Scale parameter (default 1)

Value

A prior distribution object


Quick model diagnostics

Description

Quick model diagnostics

Usage

check_convergence(object)

Arguments

object

A qbrms_fit object.

Value

Invisible TRUE if successful.


Circular Normal Family for Directional Data

Description

Circular Normal Family for Directional Data

Usage

circular_normal(link = "tan_half", link.kappa = "log")

von_mises(link = "tan_half", link.kappa = "log")

Arguments

link

Link function for mean direction

link.kappa

Link function for concentration

Value

A family object of class "family".


Clean up malformed coefficient names from mixed effects models

Description

Clean up malformed coefficient names from mixed effects models

Usage

clean_coefficient_names(coef_table, verbose = FALSE)

Extract Coefficients from qbrms Models

Description

Extract Coefficients from qbrms Models

Usage

## S3 method for class 'qbrms_fit'
coef(object, ...)

Arguments

object

A qbrms_fit object

...

Additional arguments (unused)

Value

Named vector of coefficients


Coefficients for multinomial qbrms fits

Description

Extract a concatenated vector of coefficients from a qbrms_multinomial_fit, combining the per-category binary submodels if present.

Usage

## S3 method for class 'qbrms_multinomial_fit'
coef(object, ...)

Arguments

object

A qbrms_multinomial_fit.

...

Unused.

Value

A named numeric vector of coefficients. If coefficient information is not available, a minimal intercept-only vector is returned.


Coefficients Method for TMB Ordinal Fits

Description

Coefficients Method for TMB Ordinal Fits

Usage

## S3 method for class 'tmb_ordinal_qbrms_fit'
coef(object, ...)

Arguments

object

A tmb_ordinal_qbrms_fit object

...

Additional arguments

Value

Named vector of coefficients


Compare qbrms models

Description

Compares multiple fitted models using information criteria and simple predictive metrics. Preference order for criterion = "auto" is: LOO (from CPO) > WAIC > DIC. When information criteria are unavailable it falls back to predictive metrics (RMSE/MAE).

Usage

compare_models(
  ...,
  criterion = c("auto", "loo", "waic", "dic", "all"),
  compare_predictions = TRUE,
  weights = TRUE
)

Arguments

...

Two or more fitted model objects (qbrms_fit or qbrmO_fit)

criterion

One of "auto","loo","waic","dic","all"

compare_predictions

Logical; if TRUE, include RMSE/MAE comparison

weights

Logical; if TRUE, compute weights when a single criterion is used

Value

An object of class "qbrms_comparison".


Compare Significance Across Multiple Models

Description

Compare the probability of practical significance for parameters across multiple qbrms models.

Usage

compare_significance(
  ...,
  parameters = NULL,
  threshold = "default",
  model_names = NULL
)

Arguments

...

qbrms_fit objects to compare

parameters

Character vector of parameters to compare

threshold

Threshold specification (same as p_significance)

model_names

Character vector of model names

Value

Data frame with comparison results


Compute Data-Driven Threshold Priors

Description

Calculate threshold priors based on empirical quantiles to match brms centering

Usage

compute_adaptive_threshold_priors(y_ordered, method = "quantile")

Arguments

y_ordered

Ordered factor response variable

method

Method for computing adaptive priors ("quantile" or "cumulative_mean")

Value

List with threshold means, standard deviations, and empirical baseline


Conditional effects (generic)

Description

Compute one-dimensional conditional effects / marginal fitted values as a predictor varies while other covariates are held fixed (typically at means / modes). Methods should return an object that plot() can visualise.

Usage

conditional_effects(object, ...)

Arguments

object

A model object.

...

Passed to methods.

Value

An object of class "qbrms_conditional_effects" containing conditional effect estimates. The structure is method-dependent.


Conditional effects for qbrms Gaussian models

Description

Conditional effects for qbrms Gaussian models

Usage

## S3 method for class 'qbrms_fit'
conditional_effects(
  object,
  effects = NULL,
  spaghetti = FALSE,
  ndraws = 200L,
  n_points = 100L,
  at = list(),
  seed = NULL,
  prob = 0.95,
  ...
)

Arguments

object

A qbrms fit object (Gaussian).

effects

Character vector: names of predictors to vary. Supports simple two-way interactions "num:fac" or "fac:num" where one is numeric and the other factor.

spaghetti

Logical; if TRUE draw per-draw "spaghetti" lines. If FALSE, draw a mean line with a credible-interval ribbon.

ndraws

Number of joint coefficient draws for uncertainty (default 200).

n_points

Size of the x-grid across the observed range (default 100).

at

Optional named list of covariate values to hold constant.

seed

Optional integer seed for reproducibility.

prob

Interval probability for ribbons (default 0.95).

...

Ignored.

Value

An object of class "qbrms_conditional_effects" containing a list with one element per effect. Each element is a data frame with columns for the predictor values, point estimates (estimate__), and credible interval bounds (lower__, upper__).


Conditional Effects for TMB Ordinal Models

Description

Conditional Effects for TMB Ordinal Models

Usage

## S3 method for class 'tmb_ordinal_qbrms_fit'
conditional_effects(
  object,
  effects = NULL,
  prob = 0.95,
  ndraws = 100,
  spaghetti = FALSE,
  n_points = 100,
  plot = TRUE,
  at = list(),
  seed = NULL,
  conditions = NULL,
  categorical = TRUE,
  resolution = NULL,
  ...
)

Arguments

object

A tmb_ordinal_qbrms_fit object

effects

Character vector of effect names (defaults to auto-detected)

prob

Confidence level

ndraws

Number of draws

spaghetti

Logical

n_points

Number of points for continuous predictors

plot

Logical, whether to return plots

at

Named list of conditioning values

seed

Random seed

conditions

Ordinal-specific conditions (for backwards compatibility)

categorical

Whether to show categorical plot (for backwards compatibility)

resolution

Grid resolution (for backwards compatibility)

...

Additional arguments

Value

List of conditional effects


Discrete-slice conditional effects (brms-style) for qbrms

Description

Build point/interval summaries at a few values of a numeric moderator, plotted against the factor on the x-axis.

Usage

conditional_effects_slices(
  object,
  effects,
  slices = NULL,
  nslices = 3L,
  prob = 0.95,
  ndraws = 200L,
  at = list(),
  seed = NULL,
  ...
)

Arguments

object

A qbrms_fit object.

effects

Character vector specifying effects to plot. If NULL, all numeric predictors are used.

slices

Named list of variables and values at which to slice the data.

nslices

Number of slices to use for each slicing variable.

prob

Probability mass to include in uncertainty intervals (default 0.95).

ndraws

Number of posterior draws to use for predictions.

at

Named list of values at which to fix other predictors.

seed

Random seed for reproducibility.

...

Additional arguments passed to prediction functions.

Value

An object of class "qbrms_conditional_effects" containing a list with one element per effect. Each element is a data frame with columns for the predictor values, estimates, and credible intervals.


Convert Family Object to INLA-Compatible Specification

Description

Enhanced family conversion supporting all standard and additional families with automatic routing to specialised implementations when enabled.

Usage

convert_family_to_inla(family, quantile = 0.5, allow_ordinal_routing = FALSE)

Arguments

family

A family object, character string, or list specifying the response distribution

quantile

Numeric value between 0 and 1 for quantile regression

allow_ordinal_routing

Logical; if TRUE, enables routing for ordinal families

Value

Character string, list, or routing object specifying family/routing info


Create Dummy Data for Testing

Description

Create dummy data that preserves structure for testing purposes.

Usage

create_dummy_data(
  formula,
  data,
  n_dummy = 10,
  family_name = "gaussian",
  verbose = FALSE
)

Arguments

formula

Model formula.

data

Original data frame.

n_dummy

Number of dummy observations to create.

family_name

The name of the model family (e.g., "gaussian").

verbose

Logical, whether to print messages.

Value

Data frame with dummy structure.


Create Dummy Data for Prior Predictive Checks

Description

Internal function to create dummy data that preserves structure.

Usage

create_dummy_data_for_priors(
  formula,
  data,
  n_dummy,
  family_name,
  verbose = TRUE
)

Arguments

formula

Model formula.

data

Original data.

n_dummy

Number of dummy observations.

family_name

The name of the model family (e.g., "poisson").

verbose

Logical, whether to print messages.

Value

Data frame with dummy structure.


Create Fixed Effects Summary Table

Description

Create Fixed Effects Summary Table

Usage

create_fixed_effects_summary(param_summary, tmb_data)

Arguments

param_summary

Extracted parameter summary

tmb_data

TMB data structure

Value

Data frame with summary statistics


Create qbrms-Compatible Result Object

Description

Create qbrms-Compatible Result Object

Usage

create_ordinal_qbrms_result(
  tmb_fit,
  formula,
  data,
  family,
  prior,
  verbose = FALSE
)

Arguments

tmb_fit

TMB fit results

formula

Original formula

data

Original data

family

Model family

prior

Prior specifications

verbose

Logical; print progress messages

Value

qbrms-compatible result object


Create Prior-Only Object for pp_check

Description

Construct a small qbrms_prior_only object that contains simulated data and prior draws, suitable for passing to pp_check().

Usage

create_prior_object(
  formula,
  family = gaussian(),
  prior = NULL,
  n_obs = 100,
  predictor_values = NULL,
  verbose = TRUE
)

Arguments

formula

Model formula.

family

Model family (default gaussian()).

prior

Prior specifications (default NULL uses defaults).

n_obs

Number of observations to simulate (default 100).

predictor_values

Named list of fixed predictor values (default NULL).

verbose

Logical; print progress messages (default TRUE).

Value

An object of class qbrms_prior_only.


Utility operator

Description

Utility operator

Usage

create_quantile_fit(formula, data, quantile = 0.5, verbose = TRUE)

Cumulative Family for Ordinal Regression

Description

Cumulative Family for Ordinal Regression

Usage

cumulative(link = "logit")

Arguments

link

Link function (default: "logit").

Value

An object of class "family" representing the Cumulative distribution for ordinal models.


Default Priors for qbrms Models

Description

Default Priors for qbrms Models

Usage

default_priors()

Value

A default prior list


Density Plot for qbrms Models

Description

Create density plots of posterior distributions with optional prior and observed-data overlays. Returns a ggplot2 object that can be modified with standard ggplot2 syntax.

Usage

density_plot(
  object,
  parameter = NULL,
  show_prior = FALSE,
  show_data = FALSE,
  ndraws = 100,
  prior_ndraws = 100,
  alpha_levels = list(posterior = 0.8, prior = 0.6, data = 1),
  colours = list(posterior = "#1F78B4", prior = "#E31A1C", data = "#000000"),
  seed = NULL,
  verbose = TRUE
)

Arguments

object

A qbrms_fit object.

parameter

Parameter name to plot. If NULL, plots the response distribution.

show_prior

Logical; if TRUE, overlay the prior density.

show_data

Logical; if TRUE, overlay the observed data density.

ndraws

Number of posterior draws to use (default 100).

prior_ndraws

Number of prior draws to use (default 100).

alpha_levels

Named list controlling transparency for layers.

colours

Named list of colours for layers.

seed

Optional random seed.

verbose

Logical; print progress messages.

Value

A ggplot2 object.


Diagnose Binomial Mixed Effects Models

Description

Diagnose potential issues in binomial mixed effects models before fitting

Usage

diagnose_binomial_mixed(formula, data, verbose = TRUE)

Arguments

formula

Model formula with mixed effects

data

Data frame containing variables

verbose

Logical; print diagnostic information (default: TRUE)

Value

List with diagnostic information


Automated Model Diagnostics and Recommendations

Description

Comprehensive automated diagnostics for qbrms models with actionable recommendations for model improvement.

Usage

diagnose_model(model, checks = "all", verbose = TRUE)

Arguments

model

A fitted qbrms model object

checks

Character vector specifying which checks to perform. Options: "all" (default), "convergence", "fit", "residuals", "posterior", "influential"

verbose

Logical; if TRUE, prints detailed diagnostic information (default: TRUE)

Details

This function performs comprehensive model diagnostics including:

Each check produces a pass/warning/fail status with specific recommendations for addressing any issues detected.

Value

An object of class "qbrms_diagnostics" containing:

Examples

## Not run: 
# Fit a model
fit <- qbrms(mpg ~ hp + wt, data = mtcars, family = gaussian())

# Run diagnostics
diag <- diagnose_model(fit)

# View summary
print(diag)

# View specific recommendations
diag$recommendations

# Create diagnostic plots
plot(diag)

## End(Not run)


Drop Random Effects from Formula

Description

Remove random effects terms from a model formula.

Usage

drop_random_effects(formula)

Arguments

formula

A model formula that may contain random effects.

Value

Formula with random effects terms removed.


Estimated marginal means (compatibility wrapper)

Description

This wrapper lets you call emmeans() on a qbrms_fit without attaching the external emmeans package. For non-qbrms_fit objects, it forwards to emmeans if that package is installed.

Usage

emmeans(object, specs, ...)

Arguments

object

A model object; if it is a qbrms_fit we dispatch to qbrms_emmeans().

specs

Term(s) for which to compute estimated marginal means. For qbrms_fit, this is passed to qbrms_emmeans() unchanged.

...

Additional arguments forwarded either to qbrms_emmeans() or to emmeans::emmeans() as appropriate.

Value

A data frame for qbrms_fit; otherwise whatever emmeans::emmeans() returns.


Exponential Distribution (Prior or Family)

Description

Exponential Distribution (Prior or Family)

Usage

exponential(rate_or_link = "log", link = NULL, ...)

prior_exponential(rate_or_link = 1)

Arguments

rate_or_link

Rate parameter (numeric) or link function (character).

link

Optional link function (if acting as family).

...

Additional arguments.

Value

A family object or prior object depending on inputs.


Export Model Specification

Description

Export model specifications to various formats for sharing, documentation, or reproduction.

Usage

export_model(
  model,
  file,
  format = c("R", "markdown", "text", "json"),
  include_data = TRUE,
  include_diagnostics = FALSE
)

Arguments

model

A fitted qbrms model object or qbrms_model_spec object

file

Character string specifying output file path

format

Character string specifying export format: "R" (R script), "markdown" (Rmd document), "text" (plain text), or "json" (JSON format)

include_data

Logical; if TRUE, includes data summary in export (default: TRUE)

include_diagnostics

Logical; if TRUE and model is fitted, includes diagnostic information (default: FALSE)

Details

This function facilitates model sharing and documentation by exporting:

The exported content can be used to:

Value

Invisibly returns the export content as a character string

Examples

## Not run: 
# Export model specification
spec <- model_builder(data = mtcars, response = "mpg")
export_model(spec, "my_model_spec.R", format = "R")

# Export fitted model
fit <- qbrms(mpg ~ hp + wt, data = mtcars, family = gaussian())
export_model(fit, "my_model.Rmd", format = "markdown", 
             include_diagnostics = TRUE)

# Export as JSON
export_model(spec, "my_model.json", format = "json")

## End(Not run)


Extract Family Name from INLA Family Specification

Description

Extracts the family name from an INLA family specification, handling both character strings and lists (e.g., for quantile regression).

Helper function to extract family name handling both strings and lists.

Usage

extract_family_name(inla_family)

extract_family_name(inla_family)

extract_family_name(inla_family)

Arguments

inla_family

INLA family specification (string or list).

Value

Character string containing the family name.

Character string with family name.

Examples

## Not run: 
# Character family
extract_family_name("gaussian")  # "gaussian"

# List family (from quantile regression)
ald_spec <- convert_family_to_inla(asymmetric_laplace(), quantile = 0.9)
extract_family_name(ald_spec)    # "asymmetric_laplace"

## End(Not run)


Extract Model Information for HTML Table

Description

Extract Model Information for HTML Table

Usage

extract_model_info(
  model,
  ci.lvl,
  rope,
  show.rope,
  show.p_sig,
  show.pd,
  show.bf,
  verbose = FALSE
)

Extract Model Metrics

Description

Extract DIC, WAIC and other metrics from an INLA fit.

Usage

extract_model_metrics(inla_fit)

Arguments

inla_fit

INLA model object.

Value

A list of metrics.


Extract Ordinal Information from Family

Description

Extract ordinal-specific information from a family specification.

Usage

extract_ordinal_info(inla_family)

Arguments

inla_family

INLA family specification.

Value

List with ordinal information or NULL.


Extract Parameter Estimates and Standard Errors - CORRECTED VERSION

Description

Extract Parameter Estimates and Standard Errors - CORRECTED VERSION

Usage

extract_ordinal_parameters(opt, post_cov, tmb_data, verbose = FALSE)

Arguments

opt

TMB optimization result

post_cov

Posterior covariance matrix

tmb_data

TMB data structure

verbose

Logical; print progress messages

Value

List with extracted parameters


Extract Routing Information from Family Specification

Description

Extract Routing Information from Family Specification

Usage

extract_routing_info(family_spec)

Arguments

family_spec

Family specification with routing information

Value

List containing routing details


Family Conversion and Utilities for qbrms Package

Description

Core family conversion functions with comprehensive family support, numerical stability enhancements, and CRAN-ready implementation.


Family conversion utilities for qbrms package

Description

This module provides helper functions for family specification validation and prior predictive sampling. The main family conversion is handled in families.R to avoid duplication.


Get Family Documentation

Description

Get Family Documentation

Usage

family_info(family_name)

Arguments

family_name

Name of the family

Value

Character string with family information


Check if Family Supports Quantile Regression

Description

Determine whether a given family supports quantile regression.

Usage

family_supports_quantile(family_obj)

Arguments

family_obj

Family object or name.

Value

Logical indicating whether the family supports quantile regression.


Fallback model fitting for edge cases

Description

Very simple fitting strategies used as a last resort when primary fitting fails. These provide coefficient means and approximate standard deviations sufficient for downstream summaries and plotting.

Usage

fit_fallback_model(formula, data, family, verbose = TRUE)

Arguments

formula

A model formula.

data

A data.frame.

family

A family object.

verbose

Logical; print progress information.

Value

A list with a summary.fixed data frame (columns mean and sd) and small metadata flags.


Fit Fixed Effects Model (standalone to avoid recursion)

Description

Fit Fixed Effects Model (standalone to avoid recursion)

Usage

fit_fixed_effects_model(
  formula,
  data,
  inla_family,
  control.compute,
  verbose = TRUE,
  ...
)

Fit Mixed Effects Model using INLA with proper formula conversion

Description

Fit Mixed Effects Model using INLA with proper formula conversion

Usage

fit_mixed_effects_model(
  formula,
  data,
  inla_family,
  control.compute,
  verbose = TRUE,
  ...
)

Robust model fitting with better error handling (FIXED - no recursion)

Description

Robust model fitting with better error handling (FIXED - no recursion)

Usage

fit_model_robust_fixed(
  formula,
  data,
  inla_family,
  control.compute,
  verbose = TRUE,
  ...
)

Fit Multinomial Model using INLA or fallback

Description

Fit Multinomial Model using INLA or fallback

Usage

fit_multinomial_model(
  formula,
  data,
  inla_family,
  control.compute,
  verbose = TRUE,
  ...
)

Fit ordinal model with fallbacks

Description

Fit ordinal model with fallbacks

Fit ordinal model with fallbacks (UPDATED)

Usage

fit_ordinal_model(
  formula,
  data,
  inla_family,
  control.compute,
  verbose = TRUE,
  ...
)

fit_ordinal_model(
  formula,
  data,
  inla_family,
  control.compute,
  verbose = TRUE,
  ...
)

Enhanced TMB Model Fitting with Better Error Handling - CORRECTED VERSION

Description

Enhanced TMB Model Fitting with Better Error Handling - CORRECTED VERSION

Usage

fit_ordinal_tmb_model(tmb_setup, verbose = TRUE)

Arguments

tmb_setup

TMB setup list

verbose

Logical; print progress messages

Value

List with TMB fit results


Extract fitted values from qbrms models

Description

Extract fitted values from qbrms models

Usage

## S3 method for class 'qbrms_fit'
fitted(object, ...)

Arguments

object

A qbrms_fit object

...

Additional arguments (currently unused)

Value

Numeric vector of fitted values

Examples

## Not run: 
fit <- qbrms(mpg ~ hp, data = mtcars, family = gaussian())
fitted_values <- fitted(fit)

## End(Not run)


Fitted Values Method for TMB Ordinal Fits

Description

Fitted Values Method for TMB Ordinal Fits

Usage

## S3 method for class 'tmb_ordinal_qbrms_fit'
fitted(object, ...)

Arguments

object

A tmb_ordinal_qbrms_fit object

...

Additional arguments

Value

Fitted values


Format Bayes Factor for Display

Description

Format Bayes Factor for Display

Usage

format_bf(x)

Format numerical values to specified digits

Description

Format numerical values to specified digits

Usage

format_digits(x, digits = 2)

Format Duration

Description

Format duration in seconds to a human-readable string.

Usage

format_duration(seconds)

Arguments

seconds

Numeric duration in seconds.

Value

Character string with formatted duration.


Format Number for Display

Description

Format Number for Display

Usage

format_number(x, digits = 2)

Format data frame with numerical columns

Description

Format data frame with numerical columns

Usage

format_numeric_df(df, digits = 2)

Format Percentage for Display

Description

Format Percentage for Display

Usage

format_percentage(x, digits = 1)

Gamma Distribution (Prior or Family)

Description

Gamma Distribution (Prior or Family)

Usage

gamma(shape_or_link = "log", rate = 1, link = NULL, ...)

gamma_prior(shape_or_link = 2, rate = 1)

Arguments

shape_or_link

Shape parameter (numeric) or link function (character).

rate

Rate parameter.

link

Optional link function (if acting as family).

...

Additional arguments.

Value

A family object or prior object depending on inputs.


Gaussian Family

Description

Gaussian Family

Usage

gaussian()

Value

An object of class "family" representing the Gaussian distribution.


Generalized t Family

Description

Generalized t Family

Usage

gen_student_t(link = "identity", link.sigma = "log", link.nu = "log")

Arguments

link

Link function for location

link.sigma

Link function for scale

link.nu

Link function for degrees of freedom

Value

A family object of class "family".


Generate posterior predictive samples

Description

Generate posterior predictive samples

Usage

generate_posterior_predictive_samples(object, ndraws = 100)

Generate Prior Predictions (Simple)

Description

Generate predictions from a prior-emphasised model fit.

Usage

generate_prior_predictions_simple(
  model,
  data,
  formula,
  family_name,
  ndraws,
  n_cats = NULL
)

Arguments

model

INLA model object.

data

Original data.

formula

Original formula.

family_name

Model family name (string).

ndraws

Number of draws.

n_cats

The number of categories for an ordinal response.

Value

List with yrep matrix and observed y.


Generate prior predictive samples (compat wrapper) - FIXED

Description

Maintains the legacy API: returns a list with $prior_samples as a numeric matrix of size ndraws × nrow(data).

Generate samples from the prior predictive distribution for qbrms models. Returns an ndraws x nobs matrix for compatibility with qbrms structure.

Usage

generate_prior_predictive_samples(
  formula,
  data,
  family = gaussian(),
  prior = NULL,
  ndraws = 100,
  verbose = TRUE,
  ...
)

generate_prior_predictive_samples(
  formula,
  data,
  family = gaussian(),
  prior = NULL,
  ndraws = 100,
  verbose = TRUE,
  ...
)

Arguments

formula

Model formula

data

Data frame containing model variables

family

Model family specification

prior

Prior specifications (currently uses default priors)

ndraws

Number of draws from prior predictive distribution

verbose

Logical; print progress messages

...

Additional arguments (currently ignored)

Details

Uses simple default priors:

For families other than gaussian, binomial, and poisson, falls back to Gaussian-like sampling.

Value

A list with elements:

Matrix of prior predictive samples (ndraws x nrow(data))


Generate CSS for different table styles

Description

Generate CSS for different table styles

Usage

generate_table_css(style, font.family, font.size, header.bg, stripe.bg)

Get Default Prior for Parameter Class

Description

Get Default Prior for Parameter Class

Usage

get_default_prior(class)

Arguments

class

Parameter class

Value

A default prior for that class


Get Enhanced INLA Control Settings for Family-Specific Stability

Description

Provides family-specific INLA control settings to enhance numerical stability and convergence for different distribution families.

Usage

get_enhanced_inla_control(family_name, base_control = NULL)

Arguments

family_name

Character string specifying the family name

base_control

List of base control settings (default: NULL)

Value

List of enhanced INLA control settings


Get Predictor Variables from Formula

Description

Extract predictor variables from formula, categorised by type

Usage

get_predictor_variables(formula, data)

Arguments

formula

Model formula

data

Data frame

Value

List with predictor variable information


Get Random Effects Standard Deviation Summary

Description

Extract random effects standard deviation from INLA hyperparameters.

Usage

get_random_effects_sd_summary(inla_fit, group_var)

Arguments

inla_fit

INLA model object.

group_var

Group variable name.

Value

List with mean, sd, and quantiles of random effects SD.


Generalized Extreme Value Family

Description

Generalized Extreme Value Family

Usage

gev(link = "identity", link.sigma = "log", link.xi = "identity")

gumbel(link = "identity", link.sigma = "log")

Arguments

link

Link function for location

link.sigma

Link function for scale

link.xi

Link function for shape

Value

A family object of class "family".


Handle Missing Data

Description

Process missing data in model variables, similar to brms handling.

Usage

handle_missing_data(formula, data, verbose = TRUE)

Arguments

formula

Model formula.

data

Data frame.

verbose

Logical, whether to print messages.

Value

Data frame with complete cases for model variables.


Highest Density Interval (HDI)

Description

Compute highest density intervals for parameters based on simulated posterior draws from a qbrms_fit.

Usage

hdi(object, parameters = NULL, prob = 0.95, nsim = 4000)

Arguments

object

A qbrms_fit.

parameters

Optional character vector; default uses all fixed effects.

prob

Probability mass for the interval (default 0.95).

nsim

Number of draws to simulate.

Value

A data frame of class qbrms_hdi.


Hurdle Families for Two-Part Models

Description

Hurdle Families for Two-Part Models

Usage

hurdle_poisson(link = "log", link.hu = "logit")

hurdle_negbinomial(link = "log", link.hu = "logit")

Arguments

link

Link function for count component

link.hu

Link function for hurdle component

Value

A family object of class "family".


IID Random Effects

Description

IID Random Effects

Usage

iid(scale.model = "log", diagonal = 1e-06)

Arguments

scale.model

Scaling model for precision

diagonal

Diagonal precision matrix structure

Value

A family object of class "family".


Import Model Specification from JSON

Description

Import a previously exported model specification from JSON format.

Usage

import_model(file)

Arguments

file

Character string specifying JSON file path

Value

A list containing the model specification components

Examples

## Not run: 
# Import model
spec <- import_model("my_model.json")

# Recreate model
fit <- qbrms(
  formula = as.formula(spec$model$formula),
  data = my_data,
  family = get(spec$model$family)()
)

## End(Not run)


Check if family is ordinal

Description

Check if family is ordinal

Usage

is_ordinal(family)

Arguments

family

Family specification

Value

Logical indicating if family is ordinal


K-fold cross-validation for qbrms models (ordinal and standard families)

Description

Performs K-fold cross-validation either from a fitted model or from formula + data. For ordinal (cumulative/ordinal) families, you can choose the re-fit engine used inside CV: TMB (qbrmO) or a robust fallback using MASS::polr that avoids TMB compilation in each fold. Your original fitted model is unchanged.

Usage

kfold_cv(
  object,
  data = NULL,
  family = gaussian(),
  K = 10,
  folds = NULL,
  seed = NULL,
  stratify = TRUE,
  parallel = FALSE,
  workers = NULL,
  keep_fits = FALSE,
  engine = c("auto", "tmb", "polr"),
  verbose = TRUE,
  ...
)

Arguments

object

Either a fitted qbrms/qbrmO object or a formula.

data

Required only if object is a formula. Ignored if object is a fit.

family

Optional family override (used if object is a formula; fits use their own).

K

Number of folds (default 10).

folds

Optional integer vector of length nrow(data) giving fold IDs.

seed

Optional seed for stratified folds.

stratify

Logical; stratify on response if factor/ordered (default TRUE).

parallel

Logical; use future.apply if available (default FALSE).

workers

Optional workers when parallel and no plan is set.

keep_fits

Logical; keep per-fold fits (default FALSE).

engine

Ordinal CV engine: "auto" (default), "tmb", or "polr". Only used for ordinal families during CV refits. "auto" uses getOption("qbrms.kfold.ordinal_engine", "polr").

verbose

Logical; brief progress (default TRUE).

...

Passed to qbrms() when refitting folds (non-ordinal or engine="tmb").

Value

An object of class qbrms_kfold with ELPD, pointwise elpd, SE, etc.


Laplace (Double Exponential) Family

Description

Laplace (Double Exponential) Family

Usage

laplace(link = "identity", link.sigma = "log")

double_exponential(link = "identity", link.sigma = "log")

Arguments

link

Link function for location

link.sigma

Link function for scale

Value

A family object of class "family".


List Available Extended Families

Description

List Available Extended Families

Usage

list_extended_families()

Value

Data frame with family names, categories, and brief descriptions


Lognormal Family Constructor

Description

Lognormal distribution family for positive continuous responses

Usage

lognormal(meanlog_or_link = "identity", sdlog = 1, link = NULL, ...)

lognormal(meanlog_or_link = "identity", sdlog = 1, link = NULL, ...)

lognormal_prior(meanlog_or_link = 0, sdlog = 1)

Arguments

meanlog_or_link

Mean on log scale (numeric) or link function (character).

sdlog

SD on log scale (numeric).

link

Optional link function (if acting as family).

...

Additional arguments.

Value

A family object for use with qbrms()

A family object or prior object depending on inputs.

Examples

## Not run: 
# Lognormal regression 
fit <- qbrms(response ~ predictor, data = data, family = lognormal())

## End(Not run)


Compare models by LOO (default) or WAIC

Description

Compare multiple fitted models and rank them by out-of-sample fit. If you pass qbrms/qbrmO fit objects, this uses the package's loo() / waic() wrappers under the hood. If you pass actual loo objects (from the loo package), it will delegate to loo::loo_compare() automatically.

Usage

loo_compare(..., criterion = c("loo", "waic"), sort = TRUE)

Arguments

...

One or more fitted models (qbrms/qbrmO), or loo objects; you can also pass a single named list of models.

criterion

Character, "loo" (default) or "waic".

sort

Logical; if TRUE (default) the best model is first.

Value

A data.frame with model names, estimate on the ELPD scale (higher is better), standard error (if available), differences vs best, and ranks.


Interactive Model Builder for qbrms (console)

Description

An interactive assistant that guides users through model specification by asking questions about their data, suggesting appropriate families, helping with prior selection, and building qbrms model code.

Usage

model_builder(data = NULL, response = NULL, predictors = NULL, quiet = FALSE)

Arguments

data

A data frame containing the variables to be modelled (optional). If not provided, the user will be prompted to specify it.

response

Character string specifying the response variable name (optional).

predictors

Character vector of predictor variable names (optional).

quiet

Logical; if TRUE, suppresses welcome messages (default: FALSE).

Value

An object with class "qbrms_model_spec" containing:

Examples

## Not run: 
spec <- model_builder()
fit <- eval(parse(text = spec$model_code))

## End(Not run)


Model Fitting Functions for qbrms Package

Description

Core model fitting functionality with qbrm alias and multinomial support

Details

This file contains the main qbrms/qbrm function and all supporting functions


qbrms Model Lab (RStudio Add-in)

Description

Compare plausible families, run prior/posterior checks, plot conditional effects, compute diagnostics, and emit reproducible code. Does not load 'brms'.

Usage

model_lab_addin()

Value

This function is called for its side effects (launching a Shiny gadget in RStudio). It returns NULL invisibly.


Launch Guided Bayesian Workflow (RStudio Add-in)

Description

A comprehensive, step-by-step assistant for Bayesian model building with qbrms.

Usage

model_workflow_addin()

Value

No return value. This function launches an interactive Shiny gadget for model building and code generation.


Multinomial Family

Description

Multinomial Family

Usage

multinomial()

Value

An object of class "family" representing the Multinomial distribution.


Negative Binomial Family

Description

Negative Binomial Family

Usage

neg_binomial()

Value

An object of class "family" representing the Negative Binomial distribution.


Negative Binomial Family (Alias)

Description

Negative Binomial Family (Alias)

Usage

negbinomial()

Value

An object of class "family" representing the Negative Binomial distribution.


Specify Normal Prior Distribution

Description

Specify Normal Prior Distribution

Usage

normal(mean = 0, sd = 1)

Arguments

mean

Mean of the normal distribution (default 0)

sd

Standard deviation of the normal distribution (default 1)

Value

A prior distribution object


Null Coalescing Operator

Description

Returns the first non-NULL value.

Usage

x %||% y

Arguments

x

First value.

y

Second value.

Value

x if not NULL, otherwise y.


Ordinal Plots and Posterior Predictive Checks

Description

File-level imports and utilities for ordinal model plotting functions.


Probability of Direction (pd)

Description

Estimate the probability that a parameter is strictly positive (or strictly negative) under the posterior, based on simulated draws from a qbrms_fit.

Usage

p_direction(object, parameters = NULL, nsim = 4000, null = 0)

Arguments

object

A qbrms_fit object.

parameters

Optional character vector of parameter names. If NULL, all fixed-effect coefficients are used.

nsim

Number of draws to simulate from the fitted summary.

null

Numeric value defining the reference for direction (default 0).

Value

A data frame of class qbrms_p_direction.


Probability of Practical Significance (Enhanced bayestestR-style)

Description

Compute the probability that each parameter is above a threshold in the median's direction, similar to bayestestR::p_significance(). This represents the proportion of the posterior distribution that indicates a "significant" effect in the median's direction.

Usage

p_significance(
  object,
  parameters = NULL,
  threshold = "default",
  nsim = 1000,
  verbose = TRUE
)

Arguments

object

A qbrms_fit object.

parameters

Optional character vector of parameter names; if NULL, all fixed-effect coefficients are used.

threshold

The threshold value that separates significant from negligible effect:

  • "default": Uses 0.1 as threshold range around zero

  • A single numeric value (e.g., 0.1): Creates symmetric range around zero (-0.1, 0.1)

  • A numeric vector of length two (e.g., c(-0.2, 0.1)): Asymmetric threshold

  • A list of numeric vectors: Each vector corresponds to a parameter

  • A named list: Names correspond to parameter names

nsim

Number of draws to simulate for the approximation.

verbose

Logical; print progress information.

Value

A data frame of class qbrms_p_significance with columns Parameter, ps, Median, CI_low, CI_high, Threshold_low, Threshold_high, and Interpretation.


Parse brms Formula Objects

Description

Parse brms formula objects including bf() specifications

Usage

parse_brms_formula(formula)

Arguments

formula

Formula or brms formula object

Value

List with parsed formula information


Parse Formula Components

Description

Parse formula to identify random effects, binomial trials, etc.

Usage

parse_formula_components(formula, data)

Arguments

formula

Model formula

data

Data frame

Value

List with formula components information


Parse Ordinal Formula Components

Description

Parse Ordinal Formula Components

Usage

parse_ordinal_formula(formula, data, verbose = TRUE)

Arguments

formula

Model formula

data

Data frame

verbose

Logical; print progress messages

Value

List with parsed formula components


Plot conditional effects for qbrms models

Description

Plot method for objects returned by conditional_effects and related helpers. For a single effect, this produces either a spaghetti plot of draws or a ribbon / slice plot of summary statistics. For multiple effects it can combine the plots using patchwork if available.

Usage

## S3 method for class 'qbrms_conditional_effects'
plot(x, ...)

Arguments

x

An object of class "qbrms_conditional_effects", typically the result of conditional_effects or conditional_effects_slices.

...

Currently ignored. Included for future extensions and method compatibility.

Value

For a single effect, a ggplot2 object. For multiple effects, either


Plot Method for Diagnostics

Description

Plot Method for Diagnostics

Usage

## S3 method for class 'qbrms_diagnostics'
plot(x, which = "all", ...)

Arguments

x

A qbrms_diagnostics object

which

Character vector specifying which plots to show

...

Additional arguments (unused)

Value

Invisibly returns the input object x.


Plot Method for Enhanced p_significance

Description

Create a visual plot of probability of practical significance results.

Create a visual plot of probability of practical significance results.

Usage

## S3 method for class 'qbrms_p_significance'
plot(x, ...)

## S3 method for class 'qbrms_p_significance'
plot(x, ...)

Arguments

x

A qbrms_p_significance object from p_significance().

...

Additional arguments passed to ggplot2 functions.

Value

A ggplot2 object.

A ggplot2 object.


Plot Parameters with Prior/Posterior Comparison

Description

Create density plots for multiple model parameters, optionally comparing posterior estimates with their priors. Returns a ggplot2 object with faceted parameter plots.

Create density plots for multiple model parameters, optionally comparing posterior estimates with their priors. Returns a ggplot2 object with faceted parameter plots.

Usage

plot_parameters(
  object,
  pars = NULL,
  show_prior = FALSE,
  ndraws = 200,
  prior_ndraws = 200,
  ncol = 2,
  alpha_levels = c(0.8, 0.5),
  colours = c("#1F78B4", "#E31A1C"),
  verbose = TRUE,
  ...
)

plot_parameters(
  object,
  pars = NULL,
  show_prior = FALSE,
  ndraws = 200,
  prior_ndraws = 200,
  ncol = 2,
  alpha_levels = c(0.8, 0.5),
  colours = c("#1F78B4", "#E31A1C"),
  verbose = TRUE,
  ...
)

Arguments

object

A qbrms_fit object.

pars

Optional character vector of parameter names to plot. If NULL, plots all fixed-effect parameters.

show_prior

Logical; if TRUE, overlay prior distributions.

ndraws

Number of posterior draws to use for plotting.

prior_ndraws

Number of prior draws to use if show_prior = TRUE.

ncol

Number of columns for faceting (default 2).

alpha_levels

Numeric vector of length 2 giving alpha levels for c(posterior, prior). Default c(0.8, 0.5).

colours

Character vector of length 2 giving colours for c(posterior, prior). Default c("#1F78B4", "#E31A1C").

verbose

Logical; print progress information.

...

Additional arguments (currently unused).

Value

A ggplot2 object with faceted parameter density plots.

A ggplot2 object with faceted parameter density plots.

Examples

## Not run: 
fit <- qbrms(y ~ x1 + x2, data = my_data, sample_prior = "yes")

# Plot all parameters
plot_parameters(fit)

# Plot specific parameters with priors
plot_parameters(fit, pars = c("x1", "x2"), show_prior = TRUE)

# Customize appearance
plot_parameters(fit, show_prior = TRUE) + 
  theme_bw() + 
  labs(title = "My Parameter Estimates")

## End(Not run)
## Not run: 
fit <- qbrms(y ~ x1 + x2, data = my_data, sample_prior = "yes")

# Plot all parameters
plot_parameters(fit)

# Plot specific parameters with priors
plot_parameters(fit, pars = c("x1", "x2"), show_prior = TRUE)

# Customize appearance
plot_parameters(fit, show_prior = TRUE) + 
  theme_bw() + 
  labs(title = "My Parameter Estimates")

## End(Not run)

Poisson Family

Description

Poisson Family

Usage

poisson()

Value

An object of class "family" representing the Poisson distribution.


Poisson Trick for Multinomial

Description

Poisson Trick for Multinomial

Usage

poisson_trick_multinomial()

Value

An internal family object for multinomial estimation via Poisson.


Posterior and prior predictive checks

Description

Create posterior or prior predictive diagnostic plots for fitted qbrms models.

Usage

pp_check(object, ...)

## S3 method for class 'qbrms_fit'
pp_check(
  object,
  type = "dens_overlay",
  ndraws = 5000,
  seed = NULL,
  show_observed = FALSE,
  ...
)

## S3 method for class 'qbrms_prior'
pp_check(
  object,
  type = "dens_overlay",
  ndraws = 5000,
  seed = NULL,
  show_observed = FALSE,
  ...
)

Arguments

object

A model object.

...

Additional arguments passed to methods.

type

Character string indicating the check type: one of "dens_overlay", "hist", "scatter", "scatter_avg".

ndraws

Integer number of draws to use.

seed

Optional RNG seed.

show_observed

Logical; show observed data where applicable.


Posterior predictive checks for TMB ordinal models

Description

Posterior predictive checks for TMB ordinal models

Usage

## S3 method for class 'tmb_ordinal_qbrms_fit'
pp_check(
  object,
  type = "bars",
  ndraws = 100,
  seed = NULL,
  newdata = NULL,
  prob = 0.9,
  ...
)

Arguments

object

A fitted TMB ordinal qbrms model object

type

Character; type of posterior predictive check

ndraws

Integer; number of posterior draws to use

seed

Random seed for reproducibility.

newdata

Optional data frame for predictions. If NULL, uses original data.

prob

Probability mass for credible intervals (default 0.95).

...

Additional arguments passed to methods.

Value

A ggplot object showing the posterior predictive check


Prior Predictive Checks Without Data

Description

Generate prior predictive samples for a model defined by formula, without requiring observed data, and return a ggplot object to visualise the implied distribution.

Usage

pp_check_prior(
  formula,
  family = gaussian(),
  prior = NULL,
  n_obs = 100,
  ndraws = 100,
  type = "dens_overlay",
  seed = NULL,
  predictor_values = NULL,
  verbose = TRUE
)

Arguments

formula

Model formula.

family

Model family (default gaussian()).

prior

Prior specifications (default NULL).

n_obs

Number of observations to simulate (default 100).

ndraws

Number of prior draws (default 100).

type

Plot type, one of "dens_overlay" or "hist".

seed

Optional random seed.

predictor_values

Named list of fixed predictor values (default NULL).

verbose

Logical; print progress messages (default TRUE).

Value

A ggplot2 object.


Prepare Data for TMB Ordinal Model

Description

Prepare Data for TMB Ordinal Model

Usage

prepare_ordinal_tmb_data(formula_parts, data, verbose = TRUE)

Arguments

formula_parts

Parsed formula components

data

Data frame

verbose

Logical; print progress messages

Value

List with TMB data structure


Print a qbrmb model fit

Description

Nicely formatted one-line summary plus key diagnostics for a qbrmb_fit.

Prints a summary of a regularised binomial qbrms model.

Usage

## S3 method for class 'qbrmb_fit'
print(x, digits = 2, ...)

## S3 method for class 'qbrmb_fit'
print(x, digits = 2, ...)

Arguments

x

A qbrmb_fit object.

digits

Number of decimal places for output (default: 2).

...

Additional arguments (currently unused).

Value

Invisibly returns the input object x.


Print Method for Diagnostics

Description

Print Method for Diagnostics

Usage

## S3 method for class 'qbrms_diagnostics'
print(x, ...)

Arguments

x

A qbrms_diagnostics object

...

Additional arguments (unused)

Value

Invisibly returns the input object x.


Print Method for qbrms_fit Objects

Description

Prints a summary of a fitted qbrms model object.

Usage

## S3 method for class 'qbrms_fit'
print(x, digits = 2, ...)

Arguments

x

A qbrms_fit object.

digits

Number of decimal places for output (default: 2).

...

Additional arguments (currently unused).

Value

Invisibly returns the input object x.

Examples


if (requireNamespace("INLA", quietly = TRUE)) {
  fit <- qbrms(mpg ~ hp, data = mtcars, family = gaussian(), verbose = FALSE)
  print(fit)
}



Print Method for qbrms_kfold Objects

Description

Print Method for qbrms_kfold Objects

Usage

## S3 method for class 'qbrms_kfold'
print(x, ...)

Arguments

x

A qbrms_kfold object

...

Additional arguments (unused)

Value

Invisibly returns the input object x.


Print Method for qbrms_loo_compare Objects

Description

Print Method for qbrms_loo_compare Objects

Usage

## S3 method for class 'qbrms_loo_compare'
print(x, ...)

Arguments

x

A qbrms_loo_compare object

...

Additional arguments (unused)

Value

Invisibly returns the input object x.


Print Method for qbrms_model_spec

Description

Print Method for qbrms_model_spec

Usage

## S3 method for class 'qbrms_model_spec'
print(x, ...)

Arguments

x

A qbrms_model_spec object

...

Additional arguments (unused)

Value

Invisibly returns the input object x.


Print method for multinomial qbrms fits

Description

Shorthand print method that delegates to summary.qbrms_multinomial_fit().

Usage

## S3 method for class 'qbrms_multinomial_fit'
print(x, digits = 2, ...)

Arguments

x

A qbrms_multinomial_fit.

digits

Integer; number of decimal places to display.

...

Unused.

Value

The input x, returned invisibly.


Print Method for Enhanced p_significance

Description

Print results from probability of practical significance analysis.

Usage

## S3 method for class 'qbrms_p_significance'
print(x, digits = 3, ...)

## S3 method for class 'qbrms_p_significance'
print(x, digits = 3, ...)

Arguments

x

A qbrms_p_significance object from p_significance().

digits

Number of decimal places to display (default 3).

...

Additional arguments passed to print.data.frame().

Value

Invisibly returns the input object.

Invisibly returns the input object.


Print method for qbrms_prior_build objects

Description

Nicely formats the result of prior_build_from_beliefs(), showing the elicited beliefs, implied prior distributions, and (optionally) the corresponding prior code.

Usage

## S3 method for class 'qbrms_prior_build'
print(
  x,
  digits = 3,
  show_data = FALSE,
  show_code = TRUE,
  code_object_name = "priors",
  max_terms = 12,
  ...
)

Arguments

x

An object of class "qbrms_prior_build" as returned by prior_build_from_beliefs.

digits

Integer scalar giving the number of decimal places to display for numeric summaries (default: 3).

show_data

Logical; if TRUE, print a compact summary of the elicitation data used to construct the priors.

show_code

Logical; if TRUE, print the corresponding prior code that can be copied into a modelling script.

code_object_name

Character string giving the name that will be used for the prior object in the displayed code (default: "priors").

max_terms

Integer scalar giving the maximum number of individual terms to display before truncating the printed output (default: 12).

...

Currently ignored. Included for method compatibility.

Value

Invisibly returns the input object x.


Print method for qbrms_prior_code objects

Description

Print method for qbrms_prior_code objects

Usage

## S3 method for class 'qbrms_prior_code'
print(x, ...)

Arguments

x

A qbrms_prior_code object

...

Additional arguments passed to cat

Value

Invisibly returns the input object x.


Print method for qbrms_prior_diagnostics objects

Description

Print method for qbrms_prior_diagnostics objects

Usage

## S3 method for class 'qbrms_prior_diagnostics'
print(x, digits = 3, ...)

Arguments

x

A qbrms_prior_diagnostics object

digits

Number of decimal places to display (default 3) # <– ADD THIS LINE

...

Additional arguments (unused)

Value

The input object, returned invisibly


Print Prior Distribution Objects

Description

Print Prior Distribution Objects

Usage

## S3 method for class 'qbrms_prior_dist'
print(x, ...)

Arguments

x

A qbrms_prior_dist object

...

Unused

Value

Invisibly returns x.


Print Prior List Objects

Description

Print Prior List Objects

Usage

## S3 method for class 'qbrms_prior_list'
print(x, ...)

Arguments

x

A qbrms_prior_list object

...

Unused

Value

Invisibly returns x.


Print Prior Specification Objects

Description

Print Prior Specification Objects

Usage

## S3 method for class 'qbrms_prior_spec'
print(x, ...)

Arguments

x

A qbrms_prior_spec object

...

Unused

Value

Invisibly returns x.


Print method for qbrms formulas

Description

Print method for qbrms formulas

Usage

## S3 method for class 'qbrmsformula'
print(x, ...)

Arguments

x

A qbrmsformula object

...

Unused

Value

Invisibly returns the input object x.


Print Method for summary.qbrms_fit Objects

Description

Print Method for summary.qbrms_fit Objects

Usage

## S3 method for class 'summary.qbrms_fit'
print(x, ...)

Arguments

x

A summary.qbrms_fit object.

...

Additional arguments (currently unused).

Value

Invisibly returns the input object x.


Print Method for TMB Ordinal Fits

Description

Print Method for TMB Ordinal Fits

Usage

## S3 method for class 'tmb_ordinal_qbrms_fit'
print(x, digits = 2, ...)

Arguments

x

A tmb_ordinal_qbrms_fit object

digits

Number of decimal places for output

...

Additional arguments

Value

Invisibly returns the object


Specify Prior for Model Parameters

Description

Specify Prior for Model Parameters

Usage

prior(prior, class = "b", coef = NULL, group = NULL)

Arguments

prior

A prior distribution object.

class

Parameter class ("Intercept", "b", "sd", etc.)

coef

Specific coefficient name (optional)

group

Specific group name for random effects (optional)

Value

A prior specification object


Prior Build from Beliefs

Description

Build priors from elicited beliefs (GLM-aware)

Usage

prior_build_from_beliefs(
  formula,
  data,
  family = gaussian(),
  beliefs = list(),
  outcome_location = NULL,
  outcome_interval = NULL,
  outcome_level = 0.95,
  outcome_sd = NULL,
  standardise = TRUE,
  plausible_range = NULL,
  target_coverage = 0.8,
  tune = FALSE,
  seed = NULL
)

Arguments

formula

Model formula

data

Data frame

family

Model family

beliefs

List of beliefs about parameters

outcome_location

Expected outcome location

outcome_interval

Expected outcome interval

outcome_level

Confidence level for outcome interval

outcome_sd

Outcome standard deviation

standardise

Whether to standardise predictors

plausible_range

Plausible range for outcomes

target_coverage

Target coverage probability

tune

Whether to tune priors

seed

Random seed

Value

An object of class "qbrms_prior_build" containing:


Prior Predictive Checks and Density Plotting

Description

Functions for prior checks and density plotting with ggplot2 extensibility.

Details

This file provides functionality for prior predictive checks and density plotting that integrates with ggplot2 for full customisation.


Format priors as qbrms prior() code

Description

Format priors as qbrms prior() code

Usage

prior_code(build, object_name = "priors", digits = 3, include_comments = TRUE)

Arguments

build

A 'qbrms_prior_build' returned by prior_build_from_beliefs()

object_name

Name of the object on the left-hand side (default "priors")

digits

Number of decimal places to print

include_comments

Logical; if TRUE, prepend a short comment header

Value

A single character string containing formatted R code


Prior predictive diagnostics and sensibility report

Description

Summarise prior predictive draws to check basic support, scale and shape, and (optionally) how simple statistics of the observed data compare with the prior-predictive distribution. Returns an object with a concise verdict.

Usage

prior_pp_diagnostics(
  object,
  level = 0.95,
  support = NULL,
  lower = NULL,
  upper = NULL,
  trials = NULL,
  plausible_lower = NULL,
  plausible_upper = NULL,
  include_observed = TRUE,
  seed = NULL
)

Arguments

object

A qbrms prior object: qbrms_prior_fit, qbrms_prior_only, or a qbrms_fit that contains prior_samples.

level

Credible level for central intervals (default 0.95). Reserved.

support

Optional override of the implied support: one of "real", "positive", "proportion", or "bounded". If NULL, an attempt is made to infer from the family.

lower, upper

Optional numeric bounds used when support = "bounded". If support = "proportion", the default is c(0, 1).

trials

Optional integer vector for binomial data (bounds helper).

plausible_lower, plausible_upper

Optional numeric bounds defining a user-declared “plausible range” for the outcome on the response scale. When both are supplied, the function reports the fraction of prior-predictive mass that falls in [plausible_lower, plausible_upper] and incorporates this into the verdict.

include_observed

Logical; if TRUE and the object contains data, the report compares simple statistics of y to their prior-predictive reference distributions.

seed

Optional seed for reproducibility.

Value

An object of class qbrms_prior_diagnostics.


A convenience wrapper mirroring pp_check's show_observed flag

Description

A convenience wrapper mirroring pp_check's show_observed flag

Usage

prior_pp_summary(
  object,
  show_observed = FALSE,
  plausible_lower = NULL,
  plausible_upper = NULL,
  ...
)

Arguments

object

A qbrms prior object.

show_observed

Logical; compare observed summaries when available.

plausible_lower, plausible_upper

Optional plausible range bounds to score coverage.

...

Passed to prior_pp_diagnostics().

Value

The diagnostics object, invisibly, after printing a summary.


Create Prior Predictive Distribution Plot

Description

Generate predictions from the prior distribution to assess whether priors are reasonable before seeing the data.

Usage

prior_predictive_check(formula, data, family, prior, n_samples = 1000)

Arguments

formula

Model formula

data

Data frame (used for structure, not values)

family

Model family

prior

Prior specification

n_samples

Number of prior predictive samples (default: 1000)

Value

A ggplot object showing the prior predictive distribution

Examples

## Not run: 
prior_predictive_check(
  mpg ~ hp + wt,
  data = mtcars,
  family = gaussian(),
  prior = prior(normal(0, 10), class = "b")
)

## End(Not run)


Complete Prior-to-Posterior Workflow

Description

Fit a model with priors sampled, then produce a comparison density plot that overlays posterior, prior, and observed distributions where available.

Usage

prior_to_posterior_workflow(
  formula,
  data,
  family = gaussian(),
  prior = NULL,
  verbose = TRUE,
  ...
)

Arguments

formula

Model formula.

data

Data frame.

family

Model family (default gaussian()).

prior

Prior specification (default NULL).

verbose

Logical; print progress messages.

...

Additional arguments forwarded to qbrms().

Value

A list of class qbrms_workflow_result with elements fit and plot.


Prior Distribution Specifications

Description

Functions to specify prior distributions for qbrms models


Enhanced Prior Processing with Adaptive Centering - CORRECTED VERSION

Description

Enhanced Prior Processing with Adaptive Centering - CORRECTED VERSION

Usage

process_ordinal_priors_adaptive(
  prior,
  tmb_data,
  data,
  formula_parts,
  verbose = TRUE
)

Arguments

prior

Prior specifications using qbrms prior syntax

tmb_data

Prepared TMB data structure

data

Original data frame

formula_parts

Parsed formula components

verbose

Logical; print progress messages

Value

List of prior parameters for TMB


Alias for qbrms()

Description

qbrm() is a shorter alias for qbrms() with identical functionality.

Enhanced interface to qbrms with all required parameters and built-in diagnostics.

Usage

qbrm(
  formula,
  data,
  family = gaussian(),
  prior = NULL,
  sample_prior = "no",
  verbose = TRUE,
  ...
)

qbrm(
  formula,
  data,
  family = gaussian(),
  prior = NULL,
  sample_prior = "no",
  verbose = TRUE,
  ...
)

Arguments

formula

Model formula in lme4/brms style.

data

Data frame containing the variables in the model.

family

Model family (default: gaussian()).

prior

Prior specifications (default: NULL).

sample_prior

Whether to sample from priors ("no", "yes", "only"). Default: "no".

verbose

Logical; print diagnostic information (default: TRUE).

...

Additional arguments passed to qbrms().

Value

An object of class "qbrms_fit", same as qbrms().

A qbrms_fit object with model results.

See Also

qbrms


Quick Bayesian Ordinal Regression Models with Adaptive Centering

Description

Fits ordinal regression models using Template Model Builder (TMB) with Laplace approximation and adaptive threshold centering to match brms output.

Usage

qbrmO(
  formula,
  data,
  family = cumulative(),
  prior = NULL,
  verbose = FALSE,
  threshold_method = "quantile",
  control = list(),
  ...
)

Arguments

formula

Model formula with ordinal response on the left-hand side.

data

Data frame containing the variables in the model.

family

Ordinal family specification. Currently supports cumulative().

prior

Prior specifications using qbrms prior syntax.

verbose

Logical; print progress messages during fitting.

threshold_method

Method for threshold centering ("quantile" or "cumulative_mean").

control

List of control parameters for TMB optimization.

...

Additional arguments passed to TMB functions.

Value

An object of class c("tmb_ordinal_qbrms_fit", "qbrms_fit")


Enhanced binomial mixed-effects modelling

Description

Fits a regularised binomial (or Bernoulli) mixed-effects model using INLA, with enhanced diagnostics, stability checks and strategy selection.

Usage

qbrmb(
  formula,
  data,
  family = "binomial",
  strategy = "auto",
  regularisation_strength = 0.1,
  use_data_augmentation = TRUE,
  min_group_size = 5,
  verbose = FALSE,
  diagnostics = FALSE,
  silent = FALSE,
  ...
)

Arguments

formula

Model formula with random effects in lme4-style syntax.

data

Data frame containing the variables in the model.

family

Model family (currently "binomial" or "bernoulli"; default "binomial").

strategy

Fitting strategy: "auto", "enhanced", "aggressive", or "minimal".

regularisation_strength

Regularisation strength in the interval [0, 1] (default 0.1).

use_data_augmentation

Logical; if TRUE, add pseudo-observations for additional numerical stability.

min_group_size

Minimum group size before triggering diagnostic warnings.

verbose

Logical; if TRUE, show detailed progress and diagnostics while fitting.

diagnostics

Logical; if TRUE, compute and store extended diagnostics in the returned object.

silent

Logical; if TRUE, suppress printed output except errors.

...

Additional arguments passed to INLA::inla().

Value

An object of class c("qbrmb_fit", "qbrms_fit", "list") containing the fitted model, diagnostics and metadata.


Aggressively regularised binomial mixed-effects model

Description

Convenience wrapper around qbrmb using the "aggressive" strategy with a higher default regularisation strength.

Usage

qbrmb_aggressive(formula, data, verbose = FALSE, ...)

Arguments

formula

Model formula with random effects (lme4-style).

data

Data frame containing the variables in the model.

verbose

Logical; if TRUE, show detailed diagnostics.

...

Additional arguments passed to qbrmb.

Value

An object of class c("qbrmb_fit", "qbrms_fit", "list").

Examples


if (requireNamespace("INLA", quietly = TRUE)) {
  set.seed(123)
  data <- data.frame(
    y     = rbinom(100, 1, 0.2),
    x     = rnorm(100),
    group = factor(rep(1:10, each = 10))
  )
  # qbrmb_aggressive requires a mixed model with random intercepts
  fit <- qbrmb_aggressive(y ~ x + (1 | group), data = data, verbose = FALSE)
}



Regularised binomial mixed-effects (enhanced strategy)

Description

Convenience wrapper around qbrmb using the "enhanced" regularisation strategy and a stronger default regularisation strength.

Usage

qbrmb_regularised(formula, data, verbose = FALSE, ...)

Arguments

formula

Model formula with random effects (lme4-style).

data

Data frame containing the variables in the model.

verbose

Logical; if TRUE, show detailed diagnostics.

...

Additional arguments passed to qbrmb.

Value

An object of class c("qbrmb_fit", "qbrms_fit", "list").


Quick Bayesian Regression Models with Automatic Routing

Description

Enhanced qbrms interface with automatic routing to specialised implementations. Supports ordinal regression via TMB, quantile regression, and all standard INLA families.

Usage

qbrms(
  formula,
  data,
  family = gaussian(),
  prior = NULL,
  sample_prior = "no",
  quantile = 0.5,
  control.compute = list(dic = TRUE, waic = TRUE, cpo = TRUE),
  verbose = getOption("qbrms.verbose", FALSE),
  ...
)

Arguments

formula

Model formula in lme4/brms style

data

Data frame containing the variables in the model

family

Model family (default: gaussian()). Ordinal families automatically route to qbrmO()

prior

Prior specifications (default: NULL)

sample_prior

Whether to sample from priors ("no", "yes", "only"). Default: "no"

quantile

For asymmetric_laplace family, which quantile to estimate (default: 0.5)

control.compute

INLA control settings for model information criteria

verbose

Logical; print diagnostic information (default: getOption("qbrms.verbose", FALSE))

...

Additional arguments passed to fitting functions

Value

An object of class "qbrms_fit" (or "qbrmO_fit" for ordinal models). The object is a list containing:

See Also

qbrmO for direct ordinal model fitting


Internal globals for qbrms

Description

Declares symbols that are used non-standardly (e.g. in NSE, Shiny) so that R CMD check does not flag them as undefined global variables.


Internal import directives for qbrms

Description

Internal import directives for qbrms


Model comparison criteria for qbrms models

Description

Compute approximate DIC, LOO and WAIC for qbrms model fits.

Usage

waic(object, ...)

loo(object, ...)

dic(object, ...)

## S3 method for class 'qbrms_fit'
waic(object, ...)

## S3 method for class 'qbrms_fit'
loo(object, ...)

## S3 method for class 'qbrms_fit'
dic(object, ...)

Arguments

object

A qbrms_fit object.

...

Additional arguments passed to internal methods or underlying tools.

Details

These functions provide generic interfaces (dic(), loo(), waic()) and S3 methods for qbrms_fit objects that extract the corresponding criteria from the underlying INLA fit where available.

Value

For dic(), loo() and waic() methods on qbrms_fit objects, a list containing the corresponding criterion (for example, list(dic = ...), list(looic = ..., elpd_loo = ...), or list(waic = ...)). If the criterion cannot be computed, NA_real_ is returned.


Bayesian Analysis Functions (qbrms)

Description

Posterior analysis tools for qbrms models: Bayes factors, probability of direction, ROPE, HDI, and estimated marginal means.


Fixed Regularised Binomial Mixed Effects Fitting

Description

Fits binomial mixed effects models with regularisation, with all parameters handled correctly.

Usage

qbrms_binomial_regularised(
  formula,
  data,
  regularise = TRUE,
  sample_prior = "no",
  verbose = TRUE,
  ...
)

Arguments

formula

Model formula with mixed effects structure.

data

Data frame containing the variables.

regularise

Logical; if TRUE, apply regularisation techniques.

sample_prior

Whether to sample from priors ("no", "yes", "only"). Default: "no".

verbose

Logical; print progress information.

...

Additional arguments passed to qbrms().

Value

A qbrms_fit object with additional regularisation metadata.


Estimated Marginal Means for qbrms models

Description

Compute estimated marginal means (least-squares means) for factor terms and their combinations for a qbrms_fit, using a multivariate-normal approximation to the posterior of the fixed effects.

Usage

qbrms_emmeans(object, specs, at = NULL, nsim = 1000, prob = 0.95, ...)

Arguments

object

A qbrms_fit.

specs

Character vector naming factor(s) for EMMs, or a string containing a formula with a right-hand side (for example, "~ group" or "y ~ group"). If multiple terms are provided, a full grid is used.

at

Optional named list giving values at which to hold other predictors. Numerics are fixed at their means if not supplied; factors at their modal level.

nsim

Number of posterior draws for uncertainty.

prob

Interval mass (default 0.95).

...

Additional arguments (currently not used).

Value

A data frame of class qbrms_emmeans.


Get captured fit log from a qbrms object (if available)

Description

Get captured fit log from a qbrms object (if available)

Usage

qbrms_fit_log(x)

Arguments

x

A qbrms_fit / qbrmO_fit object returned by qbrm()/qbrms()

Value

A character vector of captured console lines, or NULL if none


Ordinal regression via binary decomposition (fallback)

Description

Splits an ordered response with K levels into K-1 binary problems (thresholds y > c_j) and fits a simple binomial GLM for each split.

Usage

qbrms_ordinal_binary(formula, data, verbose = FALSE, ...)

Arguments

formula

Model formula with an ordered response on the LHS.

data

Data frame.

verbose

Logical; print progress messages.

...

Ignored (compat).

Value

An object of class c("ordinal_binary_qbrms_fit","qbrms_fit") with:


Set qbrms verbosity for the current session

Description

Set qbrms verbosity for the current session

Usage

qbrms_set_verbosity(verbose = FALSE)

Arguments

verbose

Logical. If TRUE, fitting prints progress; if FALSE, fitting is silent.

Value

Invisibly returns the previous value.


Quick Density Comparison

Description

Quick Density Comparison

Usage

quick_density_comparison(object, parameter = NULL, ...)

Arguments

object

A qbrms_fit object.

parameter

Optional parameter name to focus the comparison.

...

Additional arguments forwarded to density_plot().

Value

A ggplot2 object.


Random Walk Families

Description

Random Walk Families

Usage

rw1(scale.model = "log", diagonal = 1e-06)

rw2(scale.model = "log", diagonal = 1e-06)

Arguments

scale.model

Scaling model for precision

diagonal

Diagonal precision matrix structure

Value

A family object of class "family".


Check if Family Requires Routing to Specialist Implementation

Description

Check if Family Requires Routing to Specialist Implementation

Usage

requires_routing(family_spec)

Arguments

family_spec

Family specification from convert_family_to_inla()

Value

Logical indicating if routing is required


Check if Family Requires Special Handling

Description

Check if a family specification requires the data augmentation method.

Usage

requires_special_handling(inla_family)

Arguments

inla_family

INLA family specification.

Value

Logical indicating if special handling is needed.


Extract residuals from qbrms models

Description

Extract residuals from qbrms models

Usage

## S3 method for class 'qbrms_fit'
residuals(object, type = "response", ...)

Arguments

object

A qbrms_fit object

type

Character string indicating type of residuals (default: "response")

...

Additional arguments (currently unused)

Value

Numeric vector of residuals

Examples

## Not run: 
fit <- qbrms(mpg ~ hp, data = mtcars, family = gaussian())
resid_values <- residuals(fit, type = "response")

## End(Not run)


ROPE analysis

Description

Compute the posterior mass inside a Region Of Practical Equivalence (ROPE) for selected parameters.

Usage

rope_analysis(object, parameters = NULL, rope = c(-0.1, 0.1), nsim = 4000)

Arguments

object

A qbrms_fit.

parameters

Optional character vector of parameter names. If NULL, all fixed-effect coefficients are used.

rope

Numeric length-2 vector c(lower, upper).

nsim

Number of posterior draws to simulate.

Value

A data frame of class qbrms_rope.


Safe construction of model matrices

Description

Attempt to build model.matrix() with additional checks for size and rank, and fall back to an intercept-only matrix on failure.

Usage

safe_model_matrix(formula, data, max_cols = 100)

Arguments

formula

A model formula.

data

A data.frame.

max_cols

Integer; warn if more than this many columns are produced.

Value

A numeric matrix suitable for downstream computations.


Sanitize Formula (Distributional Safety Catch)

Description

Checks if the input is a complex distributional formula (from bf()). If so, it extracts the main formula and warns the user that distributional parameters are ignored in this version.

Usage

sanitize_formula(formula)

Arguments

formula

A formula object or a qbrmsformula list.

Value

A standard R formula object.


Set Up TMB Model Object

Description

Set Up TMB Model Object

Usage

setup_ordinal_tmb(tmb_data, prior_params, control, verbose = TRUE)

Arguments

tmb_data

Prepared TMB data structure

prior_params

Processed prior parameters

control

Control parameters for TMB

verbose

Logical; print progress messages

Value

List with TMB setup information


Simplex Family for Compositional Data

Description

Simplex Family for Compositional Data

Usage

simplex(link = "logit", link.precision = "log")

Arguments

link

Link function for the mean (default: "logit")

link.precision

Link function for precision parameter (default: "log")

Value

A family object of class "family".


Skew Normal Family

Description

Skew Normal Family

Usage

skew_normal()

Value

An object of class "family" representing the Skew Normal distribution.


Student's t Family for Robust Regression

Description

Student's t-distribution family for robust regression with heavier tails than Gaussian to handle outliers.

Functions that act as both family constructors (for qbrm) and prior specifications (for prior), depending on arguments.

Usage

student_t(
  link_or_df = "identity",
  location = 0,
  scale = 1,
  link = NULL,
  link.sigma = "log",
  link.nu = "log",
  ...
)

student()

student_t(
  link_or_df = "identity",
  location = 0,
  scale = 1,
  link = NULL,
  link.sigma = "log",
  link.nu = "log",
  ...
)

student_t_prior(
  link_or_df = 3,
  location = 0,
  scale = 1,
  link.sigma = "log",
  link.nu = "log"
)

Arguments

link_or_df

For family: link function (character). For prior: degrees of freedom (numeric).

location

Location parameter (prior only).

scale

Scale parameter (prior only).

link

Optional link function (if acting as family).

link.sigma

Link for sigma (family only).

link.nu

Link for nu (family only).

...

Additional arguments.

Value

An object of class "family" specifying the Student-t distribution.

An object of class "family" specifying the Student-t distribution.

A family object or prior object depending on inputs.

Examples

# Create a Student-t family object
fam <- student_t()
print(fam$family)


Summary Method for qbrmb_fit Objects

Description

Provides a detailed summary of a regularised binomial qbrms model.

Usage

## S3 method for class 'qbrmb_fit'
summary(object, digits = 2, ...)

Arguments

object

A qbrmb_fit object.

digits

Number of decimal places for output (default: 2).

...

Additional arguments (currently unused).

Value

An object of class "summary.qbrmb_fit" containing model summary information.


Summary Method for qbrms_fit Objects

Description

Provides a detailed summary of a fitted qbrms model.

Usage

## S3 method for class 'qbrms_fit'
summary(object, ..., digits = 2)

## S3 method for class 'qbrms_fit'
summary(object, ..., digits = 2)

Arguments

object

A qbrms_fit object

...

Additional arguments

digits

Number of digits for output (default 2)

Value

An object of class "summary.qbrms_fit" containing:

Examples


if (requireNamespace("INLA", quietly = TRUE)) {
  fit <- qbrms(mpg ~ hp, data = mtcars, family = gaussian(), verbose = FALSE)
  summary(fit)
}



Summary method for multinomial qbrms fits

Description

Print a readable summary of a qbrms_multinomial_fit, including its reference category, the list of categories, and per-category fixed-effect summaries when available.

Usage

## S3 method for class 'qbrms_multinomial_fit'
summary(object, digits = 2, ...)

Arguments

object

A qbrms_multinomial_fit.

digits

Integer; number of decimal places to display.

...

Unused.

Value

The input object, returned invisibly.


Summary Method for Enhanced p_significance

Description

Provide a summary of probability of practical significance results.

Usage

## S3 method for class 'qbrms_p_significance'
summary(object, ...)

## S3 method for class 'qbrms_p_significance'
summary(object, ...)

Arguments

object

A qbrms_p_significance object from p_significance().

...

Additional arguments (currently unused).

Value

Invisibly returns the input object.

Invisibly returns the input object.


Summary Method for TMB Ordinal Fits

Description

Summary Method for TMB Ordinal Fits

Usage

## S3 method for class 'tmb_ordinal_qbrms_fit'
summary(object, digits = 2, ...)

Arguments

object

A tmb_ordinal_qbrms_fit object

digits

Number of decimal places for output

...

Additional arguments

Value

Invisibly returns the object


Create HTML Table for qbrms Models with Enhanced Styling

Description

Generate APA-style HTML tables for qbrms model outputs with customizable styling options.

Usage

tab_model(
  ...,
  show.ci = TRUE,
  ci.lvl = 0.95,
  show.rope = FALSE,
  rope = c(-0.1, 0.1),
  show.p_sig = FALSE,
  show.pd = FALSE,
  show.bf = FALSE,
  digits = 2,
  title = "Model Results",
  file = NULL,
  CSS = NULL,
  dv.labels = NULL,
  pred.labels = NULL,
  show.intercept = TRUE,
  show.r2 = FALSE,
  show.icc = FALSE,
  show.nobs = TRUE,
  bootstrap = TRUE,
  table.style = "default",
  font.family = "system-ui, -apple-system, sans-serif",
  font.size = "14px",
  header.bg = "#f8f9fa",
  stripe.bg = "#f9f9f9",
  verbose = FALSE
)

Arguments

...

One or more qbrms_fit objects to display in the table

show.ci

Logical; show credible intervals (default TRUE)

ci.lvl

Credible interval level (default 0.95)

show.rope

Logical; show ROPE analysis (default FALSE)

rope

Numeric vector c(lower, upper) for ROPE bounds

show.p_sig

Logical; show probability of practical significance (default FALSE)

show.pd

Logical; show probability of direction (default FALSE)

show.bf

Logical; show Bayes factors (default FALSE)

digits

Number of decimal places (default 2)

title

Character; table title

file

Character; file path to save HTML output (optional)

CSS

Character; custom CSS styling (optional)

dv.labels

Character vector of dependent variable labels

pred.labels

Named character vector for predictor labels

show.intercept

Logical; show intercept row (default TRUE)

show.r2

Logical; show R-squared if available (default FALSE)

show.icc

Logical; show ICC for mixed models (default FALSE)

show.nobs

Logical; show number of observations (default TRUE)

bootstrap

Logical; use Bootstrap CSS framework (default TRUE)

table.style

Character; table style theme. Options: "default", "minimal", "academic", "modern"

font.family

Character; CSS font family (default "system-ui")

font.size

Character; base font size (default "14px")

header.bg

Character; header background colour (default "#f8f9fa")

stripe.bg

Character; striped row background colour (default "#f9f9f9")

verbose

Logical; print progress (default FALSE)

Value

An object of class "qbrms_html_table" containing the HTML code


Test the corrected implementation with a mixed-effects example

Description

Test the corrected implementation with a mixed-effects example

Usage

test_corrected_bayes_R2()

Examples

## Not run: 
# Test with mixed-effects model
library(qbrms)

# Create sample data with strong group effects
set.seed(123)
n_groups <- 10
n_per_group <- 20
n_total <- n_groups * n_per_group

data <- data.frame(
  group = factor(rep(1:n_groups, each = n_per_group)),
  x = rnorm(n_total),
  group_effect = rep(rnorm(n_groups, 0, 2), each = n_per_group)
)

# Generate response with strong group effects
data$y <- 2 + 0.5 * data$x + data$group_effect + rnorm(n_total, 0, 0.5)

# Fit mixed-effects model
fit_mixed <- qbrms(y ~ x + (1|group), data = data, family = gaussian())

# Compute Bayesian R-squared (should now match brms closely)
r2_corrected <- bayes_R2(fit_mixed, verbose = TRUE)
print(r2_corrected)

# Should show high R-squared due to strong group effects

## End(Not run)

Specify Uniform Prior Distribution

Description

Specify Uniform Prior Distribution

Usage

uniform(min = -Inf, max = Inf)

Arguments

min

Lower bound (default -Inf)

max

Upper bound (default Inf)

Value

A prior distribution object


Validate Family-Specific Data Constraints

Description

Validates that response data meets family-specific constraints and automatically adjusts boundary values when possible.

Usage

validate_family_data(y, family_name, tolerance = 1e-06)

Arguments

y

Response variable vector

family_name

Character string specifying the family name

tolerance

Tolerance for boundary adjustments (default: 1e-6)

Value

Invisibly returns TRUE if validation passes


Validate Family Quantile Combination

Description

Check if a family supports quantile regression with a given quantile value. Throws informative errors for invalid combinations.

Usage

validate_family_quantile(family_name, quantile)

Arguments

family_name

Character string specifying the family name.

quantile

Numeric quantile value (or NULL).

Value

TRUE if the combination is valid (invisibly), throws error otherwise.


Validate data before model fitting

Description

Perform lightweight diagnostics on the response and predictors to catch common issues that derail model fitting (missingness, zero variance, impossible values for specific families, simple multicollinearity flags, and sample-size sanity checks).

Usage

validate_model_data(formula, data, family, verbose = TRUE)

Arguments

formula

A model formula.

data

A data.frame containing the variables in the model.

family

A family object such as gaussian(), binomial(), or poisson(). Used for basic, family-specific checks.

verbose

Logical; print a summary of issues found.

Value

A list with elements valid (logical), errors (character vector), warnings (character vector), and n_complete (integer count of complete cases across the variables in the model).


Extract Variance-Covariance Matrix from qbrms Models

Description

Extract Variance-Covariance Matrix from qbrms Models

Usage

## S3 method for class 'qbrms_fit'
vcov(object, ...)

Arguments

object

A qbrms_fit object

...

Additional arguments (unused)

Value

Variance-covariance matrix


Variance-Covariance Matrix Method for TMB Ordinal Fits

Description

Variance-Covariance Matrix Method for TMB Ordinal Fits

Usage

## S3 method for class 'tmb_ordinal_qbrms_fit'
vcov(object, ...)

Arguments

object

A tmb_ordinal_qbrms_fit object

...

Additional arguments

Value

Variance-covariance matrix


Display HTML Table in Viewer

Description

Display HTML Table in Viewer

Usage

view_table(x)

Arguments

x

A qbrms_html_table created by tab_model().


Visualise Prior Distributions

Description

Create visual representations of prior distributions to aid in prior specification and sensitivity analysis.

Usage

visualise_prior(
  prior,
  parameter = NULL,
  xlim = NULL,
  add_reference = TRUE,
  samples = 10000
)

Arguments

prior

Prior specification in qbrms format, or a list of prior specifications to compare

parameter

Character string specifying which parameter to visualise (e.g., "b", "sd", "sigma"). If NULL, visualises all priors.

xlim

Numeric vector of length 2 specifying x-axis limits. If NULL, automatically determined.

add_reference

Logical; if TRUE, adds reference distributions for comparison (default: TRUE)

samples

Number of samples to draw for visualisation (default: 10000)

Details

This function helps users:

Supported prior distributions include:

Value

A ggplot object showing the prior distribution(s)

Examples

## Not run: 
# Visualise a single prior
prior <- prior(normal(0, 10), class = "b")
visualise_prior(prior)

# Compare different priors
prior_list <- list(
  "Weak" = prior(normal(0, 10), class = "b"),
  "Medium" = prior(normal(0, 5), class = "b"),
  "Strong" = prior(normal(0, 1), class = "b")
)
visualise_prior(prior_list)

# Visualise with custom limits
visualise_prior(prior, xlim = c(-20, 20))

## End(Not run)


Weibull Survival Family

Description

Weibull Survival Family

Usage

weibull(link = "log", link.shape = "log")

Arguments

link

Link function for scale (default: "log")

link.shape

Link function for shape (default: "log")

Value

A family object of class "family".


Zero-Inflated Negative Binomial Family

Description

Zero-Inflated Negative Binomial Family

Usage

zero_inflated_negbinomial(link = "log", link.zi = "logit")

zinb(link = "log", link.zi = "logit")

Arguments

link

Link function for mean (default: "log")

link.zi

Link function for zero-inflation (default: "logit")

Value

A family object of class "family".


Zero-Inflated Poisson Family

Description

Zero-Inflated Poisson Family

Usage

zero_inflated_poisson(link = "log", link.zi = "logit")

zip()

Arguments

link

Link function for mean (default: "log")

link.zi

Link function for zero-inflation (default: "logit")

Value

A family object of class "family".