Skip to content

modelbased

0.18.0Package record

Estimation of Model-Based Predictions, Contrasts and Means

3packages dependsuggested by 10
287.6Kdownloads / year
–test coverage
13/13flavors OK

Overview

About

Implements a general interface for model-based estimations for a wide variety of models, used in the computation of marginal means, contrast analysis and predictions. For a list of supported models, see 'insight::supported_models()'.

Changes in 0.18.0

Breaking Changes

  • For ordinal models (for example from MASS::polr(), ordinal::clm() or ordinal::clmm()), estimate_contrasts() and estimate_slopes() with backend = "emmeans" now return probabilities by default and for predict = "response", as estimate_means() already does. Contrasts compare the focal levels within each response category, and slopes are the slopes of the probability of each response category. Before, both returned values on the latent scale, and the table footer of estimate_contrasts() said they were on the response scale. The ordinal modes of *emmeans* ("prob", "cum.prob", "exc.prob", "linear.predictor", "latent" and "mean.class") can be passed to predict. Use predict = "latent" to get the former results.
Show all changes in 0.18.0Hide the rest of the changes in 0.18.0

Changes

  • Post-processing in estimate_contrasts() including group-variable (e.g., post_process = ~ pairwise | group_var) now no longer prints levels from group_var in both the group and comparison columns (i.e. redundant labels have been removed from the output).
  • estimate_contrasts() with custom comparisons (e.g., when comparison = "(b1 - b12) = (b4 - b18)") can yield incorrect results when estimate = "average" and predictions are filtered (e.g. when contrast = c("x=c(2,4)")). This does not happen in general, but may happen. Therefore, now an informative warning is printed in such edge-cases.
  • Added a new vignette, "The Modelisation Approach", which demonstrates a complete analytical workflow from setting up models using DAGs to extracting meaningful predictions, slopes, and interaction contrasts using modelbased post-estimation functions.
  • estimate_means() with backend = "emmeans" now supports ordinal models, e.g. from MASS::polr() or ordinal::clm(). predict accepts the ordinal modes of *emmeans* ("prob", "cum.prob", "exc.prob", "linear.predictor", "latent" and "mean.class"). For "prob", the output has one row per response category, in a Response column. For "cum.prob", "exc.prob" and "linear.predictor", the output has one row per threshold, in a Threshold column. For ordinal models, the default is now predict = "prob", which returns the same probabilities as the "marginaleffects" backend.
  • For ordinal models, plot() of estimate_means() output with backend = "emmeans" now maps the Response or Threshold column to the color with one by variable and to the facets with more. The "marginaleffects" backend already does this for Response.
  • With backend = "emmeans", plot() now shows predicted probabilities on a percent y-axis, "cum.prob" and "exc.prob" included. This applies to binomial, beta, ordinal, and multinomial models.
  • comparison = "ratio" is a new shortcut to compute pairwise comparisons as ratios.
  • The printed footer of estimate_prediction() and similar functions now names prediction intervals as such (#485).

Bug fixes

  • estimate_means(), estimate_contrasts() and estimate_slopes() now filter the response categories of ordinal models, for example from MASS::polr(), ordinal::clm() or ordinal::clmm(). The filter is a by term that names the response with values, for example by = c("Infl", "Sat = 'Low'"). The output then has only the rows of these response categories. The filter works with backend = "emmeans" and predict = "prob" (the default). Before, means and contrasts of factors ignored the filter, and slopes and contrasts of slopes stopped with an unclear error. If predict has another value, these functions now stop with a clear error. If a value is not a response category, they also stop with an error.
  • For non-linear models, the footer of predictions or contrasts on the link-scale no longer says "FALSE-transformed" or "TRUE-transformed". This footer appears, for example, with estimate_link(), or with estimate_means() and predict = "link". Without transform, the footer now says "link-scale". Except with backend = "emmeans", a function as transform gives "transformed link-scale". estimate_contrasts() with predict = "link" and a function as transform (for example transform = exp) no longer fails with an error. If the output of an earlier call is the data argument, the footer of estimate_expectation(), estimate_prediction() and estimate_link() now names the right scale.
  • With backend = "marginaleffects", estimate_means(), estimate_slopes() and estimate_contrasts() no longer drop or rename a by variable with a name such as type, n or value. They also no longer mislabel other columns because of such a name. Before, for example, estimate_means() dropped a by variable named type and renamed n to n_Obs. It also labeled a variable named Median as Mean, and the means as Coefficient. This fix does not yet apply to Bayesian models or to inequality comparisons (for example comparison = "inequality").
  • Fixed printing error for brms-Wiener models without component column.
  • With backend = "marginaleffects", a by variable with the name of the estimate column (for example Mean) or of the t column is now returned as <name>.1. The output column keeps its name. This also holds for p with estimate_slopes() and estimate_contrasts(), and for SE, CI_low and CI_high with estimate_slopes(). Before, for example, estimate_means() kept a by variable named Mean and renamed the means to Mean.1, and estimate_contrasts() renamed the p-values to p.1. As for the fix above, this does not yet apply to Bayesian models or to inequality comparisons. It also does not apply to estimate_contrasts() on the output of estimate_relation().
  • With backend = "marginaleffects", estimate_means(), estimate_contrasts() and estimate_slopes() now stop with an informative error when a variable has a name that *marginaleffects* uses for its own columns, and ask users to rename the variable. Before, these names gave wrong estimates, standard errors or confidence intervals, missing columns, or unclear errors. The names are:
  • by variables of estimate_means(), and of estimate_contrasts() when the contrast variable is a factor: Predicted, SE, CI_low, CI_high, df, rowid and s.value.
  • a factor contrast variable of estimate_contrasts(): SE, CI_low, CI_high, df and rowid.
  • other predictors of estimate_means() and estimate_contrasts(): SE, CI_low, CI_high and df.
  • by variables of estimate_slopes(): df, rowid, s.value, predicted, predicted_hi and predicted_lo.

Bayesian models are not checked yet. For them, these names can still give

missing columns or unclear errors.

  • With backend = "marginaleffects", estimate_contrasts() now returns a by variable named Level1 or Level2 as Level1.1 or Level2.1, next to the Level1 and Level2 columns of the contrasts. It also returns the contrasts for a by variable named hypothesis and for a contrast variable named Parameter. Before, the output had two columns with the same name, the contrast labels were not split into Level1 and Level2, or the call failed with an unclear error. If <name>.1 is already a variable name, the suffix is the next free number, for example p.2. As for the fixes above, the Level1, Level2 and hypothesis fixes do not yet apply to Bayesian models or to inequality comparisons.
  • If a variable has the name of an output column, estimate_contrasts() and estimate_slopes() with backend = "marginaleffects" now keep the values and the order of that column. This applies to the contrast variable, and to by variables of contrasts and of contrasts of slopes. It also applies to by variables of contrasts with a custom comparison, for example comparison = "b2=b1". Before, a contrast variable named t turned the t column into a factor. A contrast variable named p replaced the p-values with missing values and moved the p column to the front. In contrasts, a by variable named Slope gave two Difference columns. In contrasts of slopes, it replaced the differences with missing values. With comparison = "ratio", a by variable named Ratio or Slope gave two Ratio columns. Now a by variable named Ratio becomes Ratio.1 there.
  • estimate_slopes() with backend = "marginaleffects" now adjusts the p-values for p_adjust = "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "sidak" and "tukey". Before, all but "tukey" failed with the error "replacement has 0 rows", and "tukey" returned the unadjusted p-values. For "tukey", estimate_slopes() and get_marginaltrends() now use the Sidak adjustment and say so in a message. The Tukey adjustment is only appropriate for pairwise comparisons, but these slopes are each tested against 0. emmeans::test() makes the same substitution. Slopes that are compared, for example with the comparison or post_process argument, keep the Tukey adjustment.
  • estimate_means() with backend = "emmeans" now shows the response level names for models from ordinal::clmm(). Before, the Response column showed 1, 2, 3, and the Threshold column showed 1|2, 2|3.
  • Fixed issue in estimate_contrasts() with wrong assignment of estimates in custom comparisons (e.g., when comparison = "(b1 - b12) = (b4 - b18)"), when some of the indexed coefficients contained the same digit (in this case, 1 in b1 and b12).
  • Fixed issues in offset handling when the offset was specified via the offset argument in the model call instead of inside the formula.
  • Fixed issues with using offsets and predicting grand mean (i.e. when model contains offset and by = NULL).
  • plot() now gives an informative error when there is nothing to put on the x-axis, e.g. for predictions from intercept-only models, or for estimate_prediction() without the by argument.
  • Fixed an "invalid regular expression" error in estimate_contrasts() for multivariate models (for example from *brms*) with many observations. estimate_contrasts() now uses the names of the response variables, not their observed values, to find the response in the contrast labels.
  • estimate_contrasts() now returns separate Response1 and Response2 columns for multivariate *brms* models with dots in the response names, for example mvbind(Sepal.Length, Petal.Length) ~ Species. Before, the response names stayed in the Level1 and Level2 columns, because *brms* removes the dots from the response names.
  • The grid argument of visualisation_recipe() and plot() now changes the facet grid of plots with four or more by variables. Before, these functions applied the facet argument to the facet grid instead. If facet was not set, grid gave an error.

From NEWS.md in the release

Install

Health

CRAN checks
13OK
Slowest check: 4.8 min · r-oldrel-windows-x86_64
Status changes
  • OK13 OK2026-08-05
  • NOTE12 OK, 1 NOTE2026-08-01
  • OK13 OK2026-07-23
  • ERROR12 OK, 1 ERROR2026-07-21
  • OK14 OK2026-03-10
Advisories

none known

Documentation

In release 0.18.0
READMEYes · 2,357 wordsVignettesYes · 1 · dynamicNEWSYes · 100% structured · mentions 0.18.0Citation fileYes · cites a publicationWebsiteYes · pkgdown
Cites a JOSS paper
Help pages
25 (3 internal)includes a package overview page
Examples that run
94%15 run in a plain check (13 of them under a condition) · 1 never run
Exported functions with examples
93%
Documented parameters
99%
Return-value docs
79%
Help pages citing references
28%

Downloads

287.6K
CRAN downloads in the past year
Rank #680 · ~788/day · ~24K/mo
Daily download trend is not available in this view yet.
26.6K30 days
79.8K90 days
287.6K1 year
Compare downloads with other packages →
Also on3.4K r2u3 autocran4.8K conda_forge87 c2d4u

Repository

263Stars
23Forks
16Open issues
4Open PRs
16Releases
1,883Commits
17Commit identities
contrastsmarginalmeansmarginal-effectspredictestimateeasystatsr
License file reads as GPL-3.0 · 1,883 commits · Last activity 2026-10-21 · 0% stars, 30d · Discussions: 8 posts
Responsiveness
How these are sampled
PRs merged (all time)
95%
Median days to close, 50 most recently updated closed issues
3
Median days to close, 50 most recently updated closed PRs
0

Stars over time

2025-10-09 · 2542026-09-16 · 263
PracticesBeta

15 development-tooling and community-health practices detected across 6 families in the upstream repository

Checks run against github.com/easystats/modelbased on 2026-10-18.

Continuous integration (1)
GitHub Actions
Governance and community (5)
Code of conductContributing guideFundingSupport guide

Funding links: GitHub Sponsors

The repository owner accepts GitHub Sponsors

Docs source (3)
README.Rmdpkgdown

GitHub Pages site last deployed 2026-10-18

pkgdown site last built 2026-10-18

Coverage (1)
Coverage reporting
Show all practicesHide 2 practices
CRAN release process (1)
cran-comments.md
Lint, format, editor (4)
lintrLint workflowAirRStudio project
How this is detected·Detection ruleset v3 (2026-09-26)
AI coding toolsBeta

This repository shows signs of AI coding tools.

  • GitHub Copilotfirst seen 2025-10-05
    Pull request: opened by its own account
    Commits: 4 by its own account · at least 4 crediting it in the message
  • Gemini CLIfirst seen 2026-02-05
    Seen in the repository: GEMINI.md
    Named in .Rbuildignore: GEMINI.md
Counts are commits, not lines of code. Commits by a tool's accounts count once across all of its accounts. Commits crediting it are the largest count among its credit lines, a minimum.How this is detected·Detection ruleset v4 (updated 2026-09-27)

Dependencies

Reverse dependencies
3direct
2indirect
Imports 3
Suggested by 10
Show all 13 packagesHide all 13 packages
Depends, Imports or LinkingTo, most downloaded first
Suggests, most downloaded first

Datasets

People & History

People (5)
Author, Maintainer since 0.1.0 (2020)
Author · added in 0.6.0
Author · added in 0.10.0
Releases (30)

Pick two releases to compare their code metrics.

  • 0.18.0Latest
    record
    2026-10-18 · current release · diff ↗ ·
    listed once in CRAN's queue
    Seen in one reading of CRAN's incoming queue, at 2026-10-18 16:17 UTC, so it stayed less than the time between readings.
  • 0.17.0
    record
    2026-08-28 · diff ↗
  • 0.16.0
    record
    2026-06-30 · diff ↗
  • 0.15.0
    record
    2026-05-10 · diff ↗
  • R
    R 4.6.0 released · 2026-04-24
  • 0.14.0
    record
    2026-02-17 · diff ↗ ·
    added 1 export
    collapse_by_group
  • 0.13.1
    record
    2025-12-08 · diff ↗
  • 0.13.0
    record
    2025-08-30 · diff ↗ ·
    added 1 export
    residualize_over_grid
  • 0.12.0
    record
    2025-07-10 · diff ↗ ·
    added 1 export
    display
  • 0.11.2
    record
    2025-05-31 · diff ↗
  • 0.11.0
    record
    2025-05-02 · diff ↗ ·
    added 1 export
    pool_slopes
  • R
    R 4.5.0 released · 2025-04-11
  • 0.10.0
    record
    2025-03-10 · diff ↗ ·
    removed 1 export
    visualisation_matrix
    added 2 exports
    pool_contrasts, pool_predictions
  • 0.9.0
    record
    2025-02-05 · diff ↗ ·
    removed 5 exports
    estimate_response, get_marginaleffects, model_emcontrasts, model_emmeans, model_emtrends
    added 4 exports
    get_marginalcontrasts, get_marginalmeans, get_marginaltrends, print_html
  • 0.8.9
    record
    2024-10-26 · diff ↗
  • 0.8.8
    record
    2024-06-11 · diff ↗
Show 24 earlier eventsHide 24 earlier events
  • R
    R 4.4.0 released · 2024-04-24
  • 0.8.7
    record
    2024-02-15 · diff ↗
  • R
    R 4.3.0 released · 2023-04-21
  • 0.8.6
    record
    2023-01-13 · diff ↗
  • 0.8.5
    record
    2022-08-18 · diff ↗ ·
    added 1 export
    print_md
  • unarchivedReturned to CRAN
    2022-05-30
  • archivedRemoved from CRAN
    2022-05-30
    check problems were not corrected in time
  • 0.8.1
    record
    2022-05-30 · diff ↗
  • R
    R 4.2.0 released · 2022-04-22
  • 0.8.0
    record
    2022-03-31 · diff ↗ ·
    removed 2 exports
    data_matrix, model_marginaleffects
    added 4 exports
    get_emcontrasts, get_emmeans, get_emtrends, get_marginaleffects
  • 0.7.2
    record
    2022-02-28 · diff ↗ ·
    added 3 exports
    model_marginaleffects, standardize, unstandardize
  • 0.7.1
    record
    2022-01-13 · diff ↗ ·
    added 3 exports
    data_matrix, model_emcontrasts, model_emtrends
  • 0.7.0
    record
    2021-06-06 · diff ↗ ·
    removed 2 exports
    as.numeric_ifnumeric, data_restoretype
    added 6 exports
    describe_nonlinear, estimate_expectation, estimate_grouplevel, model_emmeans, reshape_grouplevel, visualisation_recipe
  • R
    R 4.1.0 released · 2021-05-18
  • 0.6.0
    record
    2021-04-12 · diff ↗ ·
    removed 1 export
    reshape_draws
    added 3 exports
    data_restoretype, estimate_prediction, estimate_relation
  • 0.5.1
    record
    2021-01-27 · diff ↗
  • 0.5.0
    record
    2021-01-15 · diff ↗
  • 0.4.0
    record
    2020-12-06 · diff ↗
  • 0.3.0
    record
    2020-09-27 · diff ↗
  • R
    R 4.0.0 released · 2020-04-24
  • 0.1.2
    record
    2020-03-12 · diff ↗
  • 0.1.1
    record
    2020-01-27 · diff ↗
  • 0.1.0
    record
    2020-01-12
  • R
    R 3.6.0 released · 2019-04-26
Across CRAN, the median accepted release of the past year spent 26 hours in the queue, 90% under 11 days.How queue time is measured

Package metadata

First published
2020-01-12
Total releases
30 / 6 yrs
License
GPL-3 OSI
Minimum R
≥ 4.0
Bundled data
33 KB / 5 files
Download size
624 KB
Appears in task views

Cite

Cite this package

Run in R for the authors' entry:

citation("modelbased")

The package provides a citation file, so citation() returns the authors' own entry.

It points to 10.21105/joss.07969.

Cite the R Observatory

For a number measured here: a download total, a coverage figure, an archival date.

APA

Balamuta, J. J. (2026). R Observatory: Metrics for modelbased version 0.18.0 [Data set]. HJJB, LLC. Data release v2026-10-22. https://doi.org/10.5281/zenodo.21843040

From data release v2026-10-22, which the citation names so these numbers can be found later. More on citing and the projects behind them.

Report a problem with this page →

Privacy choices

These apply to this browser and are stored on this device only. Nothing about your choice is sent to us.

Read the privacy policy