Skip to content

Commit

Permalink
extension vignette
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Jan 10, 2024
1 parent 27a5e47 commit f28ed19
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.qmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


![](man/figures/zoo_banner.png)

Parameter estimates are often hard to interpret substantively, especially when they are generated by complex models with non-linear components, interactions, or transformations. Instead of reporting unintuitive parameters, data analysts would rather focus on simple quantities of interest, which have straightforward scientific interpretations. Unfortunately, meaningful estimands---and their standard errors---are often tedious to compute, and the terminology used to describe them varies tremendously across fields.
Expand Down Expand Up @@ -66,4 +68,4 @@ The `marginaleffects` package and the Marginal Effects Zoo book will always be f
<img src="https://img.shields.io/badge/license-GPLv3-blue">
<a href = "https://marginaleffects.com" target = "_blank"><img src="https://img.shields.io/static/v1?label=Website&message=Visit&color=blue"></a>
<br><br>
</div>
</div>
13 changes: 12 additions & 1 deletion vignettes/extensions.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,17 @@ predictions(model, newdata = mtcars) |> head()

Note that, for custom model, we typically have to supply values for the `newdata` and `variables` arguments explicitly.


### Merging your extension in `marginaleffects`

If you write a working extension for a package on CRAN, please consider submitting your code for inclusion in the package. Other users could greatly benefit from your work!

The steps to do so are pretty much the same as outlined above. However,

1. Instead of calling `options(marginaleffects_model_classes)`, you need to add your model class to the permanent list of supported models in `R/sanitize_model.R`
2. Add the package to the supported models vignette by editing this file: `data-raw/supported_models.csv`
3. Add the valid prediction `type` values to `R/type_dictionary.R` Note that the first row you insert will be the default prediction type, so please choose something standard and intuitive like "response".

## Modify or extend supported models

Let's say you want to estimate a model using the `mclogit::mblogit` function. That package is already supported by `marginaleffects`, but you want to use a `type` (scale) of predictions that is not currently supported: a "centered link scale."
Expand Down Expand Up @@ -205,4 +216,4 @@ Finally, we can call any `slopes` function and obtain results. Notice that our o
avg_predictions(model)
avg_predictions(model_custom)
```
```

0 comments on commit f28ed19

Please sign in to comment.