Marginaleffects

Latest version: v0.0.14

Safety actively analyzes 682416 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 6

0.23.0

Breaking change:

* Support for `mlogit` is deprecated. The reason is that the data structure for these models is one observation-choice per row. Every other model-fitting package supported by `marginaleffects` treats rows as individual observations. The observation-choice structure made it harder to track indices and match individual predictions to rows in the original data. This added a lot of complexity to `marginaleffects`, and the results were not always reliable or safe.

Bugs:

* Improved `glmmTMB` support
- Standard errors are produced in models with `type="zprob"`. Thanks to jgeller112 for issue 1189.
- `hypotheses()` bug resolved. Thanks to reikookamoto for the code submission.
* `multinom_weightit` models with `insight` version 0.20.4 and greater would produce an error. Thanks to Noah Greifer.
* `hypotheses(joint = TRUE)` would throw an error if sample sizes could not be computed, even if they were not needed. Thanks to Noah Greifer.
* `hypotheses(joint = TRUE)` respects the `vcov` argument. Thanks to kennchua for report 1214.
* `ordbetareg` models in `glmmTMB` are now supported. Thanks to jgeller112 for code contribution 1221.
* `tidymodels()`: Indexing overrode the value of predictors in the output data frame. The numerical estimates were unaffected. Thanks to agmath for report 1209.

0.22.0

Breaking changes:

* `type="invlink(link)"` is no longer default in `avg_predictions()` or when calling `predictions()` with the `by` argument. It is still default in `predictions()` without the `by` argument. The backtransform strategy is still available with by setting `type="invlink(link)"` explicitly.
* The `type` argument in `plot_comparisons()` now defaults to `NULL`, which is now consistent with `comparisons()` and `avg_comparisons()`. Before, the default was `type="response"`. Thanks to giakhang1906 for report 1202.

New models supported:

* `stpm2`, `pstpm2`, `gsm`, and `aft` models from `rstpm2`. Thanks to aghaynes and mclements.
* `glm_weightit`, `coxph_weightit`, `multinom_weightit`, and `ordinal_weightit` models from `Weightit`. Thanks to ngreifer.
* `glmmgee` from the `glmtoolbox` package. Thanks to adrianolszewski for the request and lhvanegasp for help with implementation.

New features:

* Parallel computation with `future` is more efficient by chunking tasks to avoid passing large objects to every worker for every future. Issue 1158.
* All columns of `newdata` are passed to the `hypothesis` function when `newdata` is supplied explicitly. Thanks to gravesti for report 1175.
* `hypotheses(joint=TRUE)`: do not call `stats::nobs()` unless necessary.
* `hypotheses()` supports formulas in the `hypothesis` argument: `hypotheses(model, hypothesis = ratio ~ reference)`
* Global option: `options("marginaleffects_print_omit" = "s.value")`
* Round significant digits for labels in `plot_predictions(mod, condition = list(x = "fivenum"))`
* `print()` no longer prints `contrast` and `term` columns when values are unique. The labels were often very long, and the content is already explicit in the call itself, so there's no ambiguity.
* No warning raised when `discrete` argument is used with `mgcv::bam` and `mgcv::gam` models objects. Thanks to Aariq for the request.
* `tidymodels` support is improved. Users can now directly feed some of them without specifying `newdata` explicitly. Thanks to davidkane9 for the feature request.

Bugs:

* Average lift and average comparisons with user-supplied functions could be be calculated incorrectly when all predictors were categorical. Thanks to Dpananos for Issue 1151.
* Indexing bug returned `NA` for some commands in `survey` models. Thanks to weikang9009 for report 1161.
* Respect default `tinytable` theme.
* Inverted confidence interval bounds with some inverse link functions. Thanks to strengejacke for report 1204.

0.21.0

New:

* `hypothesis` accepts formulas like: `ratio ~ sequential | group`
* Allow reverse binary contrasts: `comparisons(mod, variables = list(am = 1:0, vs = 0:1))`. Thanks to K. Henry for report 1137.
* `options(marginaleffects_safe = FALSE)` disables some safety checks and allows unadvisable (but potentially) useful features like *many* pairwise comparisons. Thanks to D.Locke for the feature request.
* `newdata="balanced"` is a shortcut to produce estimates at combinations of all categorical predictors, holding numeric predictors at their means. Equivalent to `datagrid(grid_type="balanced")`

Misc:

* Deprecation warning for `specify_hypothesis()`. This function was clearly marked as experimental, and has been available only for one release. It was a bad idea. Users should supply a custom function or a formula to the `hypothesis` argument. The new formula interface, in particular, makes it very easy to conduct group-wise hypothesis tests.
* Type checks are a bit looser to accommodate custom models.

Bugs:

* Fix regression in `mlogit` models due to factor conversion. This raised an error before returning result, so there is no numerical danger.
* `survey` package models work when `row.names(model)` is not coercible to integers. Thanks to ngreifer for report 1131.

0.20.1

* The `comparison` argument of the `comparisons()` function is automatically switched to the `avg` version of the function shortcuts when calling `avg_comparisons()` or setting `by=TRUE`. For example, `comparison="ratio"` becomes `comparison="ratioavg"` when calling `avg_comparisons()`. Note that `comparison="ratioavg"` is equivalent to: `comparison = \(hi,lo) mean(hi)/mean(lo)`
* Fixed a bug ("non-conformable arguments") when using `survreg` objects from `survival::survreg()`.
* Fixed bug in `inferences()` for GLM models and `type="invlink"`, where the wrong scale would be reported for confidence intervals.

0.20.0

Breaking changes:

* The order of the `group` column is preserved when the original variable is a factor. This may change the order of output, which could have an effect on hypothesis tests using the `hypothesis="b1=b3"` syntax.

New:

* New *experimental* function: `specify_hypothesis()` returns functions to be used in the `hypothesis` argument of `predictions()`, `comparisons()`, and `slopes()`. This convenience function can be used to specify complex aggregations and estimands for hypothesis tests (ex: by subgroups or with custom functions).
* `hypothesis` argument accepts "meandev" and "meanotherdev" to compute deviations from the mean estimate.
* Do not raise extraneous warning for `survey` package models when the `by` argument is not used.
* Informative error when `hypotheses()` is called twice on the same object.
* `print("tinytable")` adds footnotes to the table with columns and type information.

Bugs:

* `mlogit` `predict()` method does not play well with `data.table`. Thanks to andrewheiss for report 1086.
* Avoid merging `newdata` in `predictions()` when `hypothesis` can change the meaning of rows. Avoid Issue 1105 reported by strengejacke.
* `inferences()` did not work with the `transform` argument. Thanks to Demetri Pananos for report 1115.

0.19.0

Breaking changes:

* `datagrid()` no longer includes the response variable by default when it is not explicitly specified by the user. Use the new `response` argument to include it.
* `datagrid(grid_type="balanced")` returns factors ordered by level rather than by order of appearance in the original data.
* Order of some rows in the output may differ when using `datagrid()`. Necessary to fix issue 1079 (see below).

New modeling packages supported:

* `flexsurv`: Thanks to mattwarkentin for code contributions in PR 781. https://cran.r-project.org/web/packages/flexsurv/index.html
* `REndo`: https://cran.r-project.org/web/packages/REndo/index.html

New:

* `wts=TRUE` tries to retrieves weights used in a weighted fit such as `lm()` with the `weights` argument or a model fitted using the `survey` package. Thanks to ngreifer for feature request
* `print.marginaleffects()` supports `style="tinytable"`, which returns a `tinytable` object. Call `print(avg_slopes(model))` to get a nice printed table in Quarto or Rmarkdown documents, via Typst, LaTeX or HTML. Default print format can be set using: `options(marginaleffects_print_style="tinytable")`
* `hypothesis` argument accepts a function which takes a `marginaleffects` data frame and returns a transformed data frame with `term` and `estimate` columns.
* `datagrid()` gets a `response` argument (default is `FALSE`) to control if the response variable is included or excluded from the grid-building process.
* The `base::subset()` and `dplyr::filter()` functions can be called with a single argument in `newdata` to select a subset of rows from the dataset used to fit the model.
- Ex: avg_comparisons(fit, variables = "treatment", newdata = subset(treatment == 1))`
* Better warning for unsupported arguments.
* `df` argument in `hypotheses()` accepts a vector of length 2 to control degrees of freedom in F tests.
* `nlme::lme()` objects raise a warning about degrees of freedom. Thanks to and stefgehrig and huftis for discussion in Issue 960.

Major bugs:

* Some results could be mislabelled with factor variables used in combination with `datagrid()` or `condition`. Thanks to snhansen for report 1079.
* `glmmTMB` models now report correct standard errors, and raise a warning that these standard errors only account for uncertainty in fixed effect parameters. Thanks to contributors to Issue 1024 and especially to bbolker for discussion and solution.

Minor bugs:

* Uninformative error when a custom `comparison` function returns `NA` in bayesian models. Thanks to Sandhu-SS for report 1017.
* `datagrid()` returns an object with full attributes when `by` is used. Thanks to Sandhu-SS for report 1058.
* `inferences(method="simulation")` with `inferences()` function. Thanks to davidarmstrong for report 1054.

Page 1 of 6

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.