Regression coefficients are typically presented as tables that are easy to understand. Sometimes, estimates are difficult to interpret. This is especially true for interaction or transformed terms (quadratic or cubic terms, polynomials, splines), in particular for more complex models. In such cases, coefficients are no longer interpretable in a direct way and marginal effects are far easier to understand. Specifically, the visualization of marginal effects makes it possible to intuitively get the idea of how predictors and outcome are associated, even for complex models.
The ggeffects-package (Lüdecke 2018) aims at easily calculating marginal effects for a broad range of different regression models, beginning with classical models fitted with
glm() to complex mixed models fitted with lme4 and glmmTMB or even Bayesian models from brms and rstanarm. The goal of the ggeffects-package is to provide a simple, user-friendly interface to calculate marginal effects, which is mainly achieved by one function:
ggpredict(). Independent from the type of regression model, the output is always the same, a data frame with a consistent structure.
Weiterlesen „Marginal Effects for Regression Models in R #rstats #dataviz“
A new update of my sjstats-package just arrived at CRAN. This blog post demontrates those functions of the sjstats-package that deal especially with Bayesian models. The update contains some new and some revised functions to compute summary statistics of Bayesian models, which are now described in more detail.
Before we start, we fit some models, including a mediation-object from the mediation-package, which we use for comparison with brms. The functions work with
Weiterlesen „R functions for Bayesian Model Statistics and Summaries #rstats #stan #brms“
I’m pleased to announce an update of my sjstats-package. New features are specifically implemented for the Anova and Bayesian statistic and summary functions. Here’s a short overview of what’s new…
Weiterlesen „Anova-Freak and Bayesian Hipster #rstats“
I’m pleased to announce an update for the sjmisc-package, which was just released on CRAN. Here I want to point out two important changes in the package.
New default option for recoding and transformation functions
First, a small change in the code with major impact on the workflow, as it affects argument defaults and is likely to break your existing code – if you’re using sjmisc: The
append-argument in recode and transformation functions like
row_means() now defaults to
The reason behind this change is that, in my experience and workflow, when transforming or recoding variables, I typically want to add these new variables to an existing data frame by default. Especially in a pipe-workflow, when I start my scripts with importing and basic tidying of my data, I almost always want to append the recoded variables to my existing data, e.g.:
# Example with following steps:
# 1. loading labelled data set
# 2. dropping unused labels
# 3. converting numeric into categorical, using labels as levels
# 4. center some variables
# 5. recode some other variables
center(var7, var9) %>%
rec(var11, rec = "2=0;1=1;else=copy")
Weiterlesen „Data transformation in #tidyverse style: package sjmisc updated #rstats“
Yesterday, at the last meeting of the Hamburg R User Group in this year, I had the pleasure to give a talk about Bayesian modelling and choosing (informative) priors in the rstanarm-package.
You can download the slides of my talk here.
Thanks to the Stan team and Tristan for proof reading my slides prior (<- hoho) to the talk. Disclaimer: Still, I'm fully responsible for the content of the slides, and I'm to blame for any false statements or errors in the code…
I’m pleased to announce the latest update from my sjPlot-package on CRAN. Beside some bug fixes and minor new features, the major update is a new function,
plot_model(), which is both an enhancement and replacement of
sjp.int(). The latter functions will become deprecated in the next updates and removed somewhen in the future.
plot_model() is a „generic“ plot function that accepts many model-objects, like
lmerMod etc. It offers various plotting types, like estimates/coefficient plots (aka forest or dot-whisker plots), marginal effect plots and plotting interaction terms, and sort of diagnostic plots.
In this blog post, I want to describe how to plot estimates as forest plots.
Weiterlesen „„One function to rule them all“ – visualization of regression models in #rstats w/ #sjPlot“
Another quick preview of my R-packages, especially sjPlot, which now also support
brmsfit-objects from the great brms-package. To demonstrate the new features, I load all my „core“-packages at once, using the strengejacke-package, which is only available from GitHub. This package simply loads four packages (sjlabelled, sjmisc, sjstats and sjPlot).
Weiterlesen „More support for Bayesian analysis in the sj!-packages #rstats #rstan #brms“
I’m working on the next update of my sjPlot-package, which will get a generic
plot_model() method, which plots any kind of regression model, with different plot types being supported (forest plots for estimates, marginal effects and predictions, including displaying interaction terms, …).
The package also supports
rstanarm models. Since these are typically presented in a slightly different way (e.g., „outer“ and „inner“ probability of credible intervals), I implemented a special handling for these models, for which I wanted to show a quick preview here:
Weiterlesen „Quick #sjPlot status update… #rstats #rstanarm #ggplot2“
Here’s a small preview of forthcoming features in the ggeffects-package, which are already available in the GitHub-version: For marginal effects from models fitted with
glmer.nb(), confidence intervals are now also computed.
If you want to test these features, simply install the package from GitHub:
Here are three examples:
Weiterlesen „Marginal effects for negative binomial mixed effects models (glmer.nb and glmmTMB) #rstats“
Some time ago I started working with Bayesian methods, using the great rstanarm-package. Beside the fantastic package-vignettes, and books like Statistical Rethinking or Doing Bayesion Data Analysis, I also found the ressources from Tristan Mahr helpful to both better understand Bayesian analysis and rstanarm. This motivated me to implement tools for Bayesian analysis into my packages, as well.
Due to the latest tidyr-update, I had to update some of my packages, in order to make them work again, so – beside some other features – some Bayes-stuff is now avaible in my packages on CRAN.
Weiterlesen „Going Bayes #rstats“