Skip to content

partial effects plots

9 messages · Daniel Lüdecke, Ben Bolker, John Fox +2 more

#
Hello all,

I have fit a GLMM to presence/absence data (family = binomial) from an acoustic telemetry study. I have five fixed effects-Year (a factor), Day of Year, Hour of Day, Sex (a factor), and water temperature-and one random effect-Fish ID (a factor). I am looking to create partial effects plots for the covariates. Can anyone direct me to some sample code or suggest a package to help me get started. My Google searches haven't been very fruitful.

I would appreciate any assistance on this matter. Thank you for your time!


Best,

Laura


#############################
Laura M. Lee
USFWS - Northeast Fishery Center
P.O. Box 75
308 Washington Ave.
Lamar, PA  16848
Phone: 570-726-4247 x 50122
Laura_Lee at fws.gov<mailto:Laura_Lee at fws.gov>
#############################
#
? Start with emmeans or effects packages? In particular

library(effects)

plot(allEffects(fitted_model))
On 7/30/24 15:44, Lee, Laura M via R-sig-mixed-models wrote:
#
I'm not sure if the partial effects plots differ from what emmeans, ggeffects, effects etc. plot by default.
Isn't another name for "partial effects plots" the "added variables plot", implemented in car::avPlot() / car::avPlots()?

Not sure if mixed models are supported, though.

-----Urspr?ngliche Nachricht-----
Von: R-sig-mixed-models <r-sig-mixed-models-bounces at r-project.org> Im Auftrag von Ben Bolker
Gesendet: Dienstag, 30. Juli 2024 22:18
An: r-sig-mixed-models at r-project.org
Betreff: [EXT] Re: [R-sig-ME] partial effects plots

   Start with emmeans or effects packages? In particular

library(effects)

plot(allEffects(fitted_model))
On 7/30/24 15:44, Lee, Laura M via R-sig-mixed-models wrote:
_______________________________________________
R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models

--

_____________________________________________________________________

Universit?tsklinikum Hamburg-Eppendorf; K?rperschaft des ?ffentlichen Rechts; Gerichtsstand: Hamburg | www.uke.de
Vorstandsmitglieder: Prof. Dr. Christian Gerloff (Vorsitzender), Joachim Pr?l?, Prof. Dr. Blanche Schwappach-Pignataro, Corinna Wriedt
_____________________________________________________________________
#
? OK, in this case you'll need to be able to generate partial 
residuals, which may be doable via the package at 
https://github.com/hohenstein/remef
On 7/30/24 16:30, Daniel L?decke wrote:
#
Dear Ben, Daniel, and Laura,

First, added-variable (partial-regression) plots are often confused with 
component + residuals (partial-residual) plots, but they are not the same.

Second, "effect" plots are essentially component + residuals plots 
(possibly without the residuals).

Finally, it's possible to show partial residuals in effect plots for 
mixed models constructed by the effects package.

I hope this helps,
  John
#
Dear all,
yes, partial *residuals* are possible with the effects package (see https://cran.r-project.org/web/packages/effects/vignettes/partial-residuals.pdf) or ggeffects (https://strengejacke.github.io/ggeffects/articles/introduction_partial_residuals.html).

I don't think partial *regression* plots are possible for any of those packages (maybe for the effects package, I'm not sure).

Laura, maybe you can clarify what kind of plots you would like to have? Terminology may be unclear here. I'm not sure if I confused partial *effects* with partial *regression* plots. Beside the mentioned functions in the car-package, this website describes partial-effects plots: https://rpubs.com/milesdwilliams15/328471

Best
Daniel

-----Urspr?ngliche Nachricht-----
Von: John Fox <jfox at mcmaster.ca> 
Gesendet: Dienstag, 30. Juli 2024 23:08
An: Ben Bolker <bbolker at gmail.com>; Daniel L?decke <d.luedecke at uke.de>; Laura_Lee at fws.gov
Cc: r-sig-mixed-models at r-project.org
Betreff: [EXT] Re: [R-sig-ME] Re: partial effects plots

Dear Ben, Daniel, and Laura,

First, added-variable (partial-regression) plots are often confused with component + residuals (partial-residual) plots, but they are not the same.

Second, "effect" plots are essentially component + residuals plots (possibly without the residuals).

Finally, it's possible to show partial residuals in effect plots for mixed models constructed by the effects package.

I hope this helps,
  John

--
John Fox, Professor Emeritus
McMaster University
Hamilton, Ontario, Canada
web: https://www.john-fox.ca/
--
On 2024-07-30 4:52 p.m., Ben Bolker wrote:
--

_____________________________________________________________________

Universit?tsklinikum Hamburg-Eppendorf; K?rperschaft des ?ffentlichen Rechts; Gerichtsstand: Hamburg | www.uke.de
Vorstandsmitglieder: Prof. Dr. Christian Gerloff (Vorsitzender), Joachim Pr?l?, Prof. Dr. Blanche Schwappach-Pignataro, Corinna Wriedt
_____________________________________________________________________
#
Dear Daniel,
On 2024-07-31 2:37 a.m., Daniel L?decke wrote:
This document says that, "Partial effect plots go by serval [sic] names 
(partial residual plots, added variable plots, adjusted variable plots, 
etc.)."  "Partial residual plots" and "added variable plots" have 
conventional definitions, and they are not the same.

The document goes on to define a function that computes added-variable 
(partial-regression) plots for linear models fit by unweighted least 
squares. One can more generally compute AV plots for linear models fit 
by weighted least squares and for generalized linear models (see, e.g., 
the avPlots() function in the far package). I'm unaware of a 
generalization beyond that.

Best,
  John
#
Thanks, everyone, for your quick response. I am interested in the relationship between the outcome and each explanatory variable. I am interested in creating plots similar to Figures 4a and 4b in the paper at  https://www.frontiersin.org/journals/marine-science/articles/10.3389/fmars.2023.1154689/full#h10.

I tried running peplot() using the code from the link Daniel (https://rpubs.com/milesdwilliams15/328471), but could not get it to work.

I was able to extract effects using the 'remef' package (https://github.com/hohenstein/remef), but I am not sure where to go from there.


Best,

Laura



-----Original Message-----
From: Daniel L?decke <d.luedecke at uke.de>
Sent: Wednesday, July 31, 2024 2:38 AM
To: 'John Fox' <jfox at mcmaster.ca>; 'Ben Bolker' <bbolker at gmail.com>; Lee, Laura M <laura_lee at fws.gov>
Cc: r-sig-mixed-models at r-project.org
Subject: [EXTERNAL] AW: [EXT] Re: [R-sig-ME] Re: partial effects plots



 This email has been received from outside of DOI - Use caution before clicking on links, opening attachments, or responding.



Dear all,
yes, partial *residuals* are possible with the effects package (see https://cran.r-project.org/web/packages/effects/vignettes/partial-residuals.pdf) or ggeffects (https://strengejacke.github.io/ggeffects/articles/introduction_partial_residuals.html).

I don't think partial *regression* plots are possible for any of those packages (maybe for the effects package, I'm not sure).

Laura, maybe you can clarify what kind of plots you would like to have? Terminology may be unclear here. I'm not sure if I confused partial *effects* with partial *regression* plots. Beside the mentioned functions in the car-package, this website describes partial-effects plots: https://rpubs.com/milesdwilliams15/328471

Best
Daniel

-----Urspr?ngliche Nachricht-----
Von: John Fox <jfox at mcmaster.ca>
Gesendet: Dienstag, 30. Juli 2024 23:08
An: Ben Bolker <bbolker at gmail.com>; Daniel L?decke <d.luedecke at uke.de>; Laura_Lee at fws.gov
Cc: r-sig-mixed-models at r-project.org
Betreff: [EXT] Re: [R-sig-ME] Re: partial effects plots

Dear Ben, Daniel, and Laura,

First, added-variable (partial-regression) plots are often confused with component + residuals (partial-residual) plots, but they are not the same.

Second, "effect" plots are essentially component + residuals plots (possibly without the residuals).

Finally, it's possible to show partial residuals in effect plots for mixed models constructed by the effects package.

I hope this helps,
  John

--
John Fox, Professor Emeritus
McMaster University
Hamilton, Ontario, Canada
web: https://www.john-fox.ca/
--
On 2024-07-30 4:52 p.m., Ben Bolker wrote:
--

_____________________________________________________________________

Universit?tsklinikum Hamburg-Eppendorf; K?rperschaft des ?ffentlichen Rechts; Gerichtsstand: Hamburg | http://www.uke.de/
Vorstandsmitglieder: Prof. Dr. Christian Gerloff (Vorsitzender), Joachim Pr?l?, Prof. Dr. Blanche Schwappach-Pignataro, Corinna Wriedt ___________
#
Hi Laura,

These plots can be produced with the gratia package:
https://gavinsimpson.github.io/gratia/

Please note that these plots are based on GAMMs and not GLMMs. The easiest
way to see this is that the effect of each variable on the x-axis does not
follow a simple parametric form (e.g., linear or curvilinear) but is
non-linear and recovered from the data (using a spline). If you want to
produce such a plot, you need to fit a GAM, which you can do using package
mgcv.

Best,
Henrik


Am Mi., 31. Juli 2024 um 14:09 Uhr schrieb Lee, Laura M via
R-sig-mixed-models <r-sig-mixed-models at r-project.org>: