You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The marginaleffects package has a plot_predictions() function which combines (from a gratia viewpoint) data_slice() with fitted_values().
It has a condition argument which allows the user to either specify up to four covariates via a character vector or a named list (names of the list are covariate labels). The order of the covariates in the vector/list are used for:
x-axis,
colour / shape,
facet variable 1
if only three covariates specified this is passed to facet_wrap(), or
if four covariates are specified this is is the column facet variable in facet_grid()
facet variable 2, for the rows of facet_grid().
The character vector form requires some defaults for generating data:
if the covariate is numeric (which the first covariate should really be for a GAM) then we would spread n values evenly over that covariate. For numeric covariates 2-4, then we should compute a smaller set of values (Tukey's fivenum is the default in plot_predictions()). The list version in plot_predictions() allows greater customisation of the generated numbers.
for factors, just use the levels of the named factor
The list form allows more flexibility; not sure I will implement everything. It allows:
name of covariate as a length 1 character vector. If this is used, then the behaviour for that covariate is as per the character vector form, above,
a function, the output of which defines the values used in the data slice for the covariate,
a character string of in-built summaries ("minmax", "threenum", "quartile", where "threenum" is -SD, mean, +SD.
Can't call this plot_predictions as that will clash with marginaleffects and users (including me) should want to use both packages for interrogating GAMs. Also, following my design principles for the package, it would be good to return a data frame of the required predicted values (with attributes to inform on conditioning variables) and then have a draw() method for that object. Will need a subsetting method for [ if I do this...
The text was updated successfully, but these errors were encountered:
The marginaleffects package has a
plot_predictions()
function which combines (from a gratia viewpoint)data_slice()
withfitted_values()
.It has a
condition
argument which allows the user to either specify up to four covariates via a character vector or a named list (names of the list are covariate labels). The order of the covariates in the vector/list are used for:facet_wrap()
, orfacet_grid()
facet_grid()
.The character vector form requires some defaults for generating data:
n
values evenly over that covariate. For numeric covariates 2-4, then we should compute a smaller set of values (Tukey'sfivenum
is the default inplot_predictions()
). The list version inplot_predictions()
allows greater customisation of the generated numbers.The list form allows more flexibility; not sure I will implement everything. It allows:
"minmax"
,"threenum"
,"quartile"
, where"threenum"
is -SD, mean, +SD.Can't call this
plot_predictions
as that will clash with marginaleffects and users (including me) should want to use both packages for interrogating GAMs. Also, following my design principles for the package, it would be good to return a data frame of the required predicted values (with attributes to inform on conditioning variables) and then have adraw()
method for that object. Will need a subsetting method for[
if I do this...The text was updated successfully, but these errors were encountered: