I am asking a question akin to this one: What does the y-axis "effect" mean after using gratia::draw for a GAM but am wondering the same question for parametric terms not smooths.
My data looks like this:
df<-structure(list(spreg = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L), levels = c("n", "y"), class = "factor"),
Landings = c(48974, 16933, 18389, 16433, 5720, 3775, 1388,
97109, 148609, 104267, 77454, 128938, 108096, 126957, 102396,
16165, 59423, 2892, 4728, 3783, 4785, 11359, 5323, 6106,
167, 568, 480, 2208, 4378, 1908), year = c(2007, 2009, 2011,
2013, 2015, 2018, 2007, 2007, 2007, 2012, 2015, 2018, 2007,
2007, 2012, 2015, 2018, 2008, 2010, 2006, 2008, 2011, 2008,
2011, 2007, 2010, 2007, 2014, 2015, 2014)), row.names = c(1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 28L, 29L,
30L, 31L), class = "data.frame")
My code looks like this:
library(mgcv)
library(gratia)
gam<-gam(Landings~s(year)+spreg,data=df)
draw(parametric_effects(gam))
Partial effect plot looks like this:
I want to report these partial effect plots for parametric terms but I am having trouble finding a good description of the partial effect plots for fixed effects. Is this the estimate and 95% credible interval like the smooth partial effect plots?
The value for the
y
group is literally the estimated value for they
term shown in the output fromsummary()
(or the estimated value for the coefficient labelledspregy
), and the interval is based on the SE shown in that output too. The value forn
is 0 as it is the reference level and hence it has 0 partial effect as the intercept term represents this group and the partial effects shown are for deviations from the intercept. I don't find these plots that useful, butplot.gam()
showed them sodraw()
does as it is a ggplot-based alternative toplot.gam()
.The behaviour of
plot.gam()
anddraw()
follows (or closely follows)termplot()
, with the former literally calling this function for plotting. If you want more useful outputs, packages emmeans or marginaleffects would be my go to options.