Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The ordering of plots in draw.gam doesn't always match the order in which the smooths entered the model #154

Closed
gavinsimpson opened this issue Mar 18, 2022 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@gavinsimpson
Copy link
Owner

I think something must be going on to reorder the smooth column somewhere in all the group_by, mapping, nesting/unnesting, binding, etc that happens in draw.gam()

An easy solution should be to use smooths() to reorder the column into the order that the smooths entered the model.

@gavinsimpson gavinsimpson added the bug Something isn't working label Mar 18, 2022
@gavinsimpson gavinsimpson added this to the 0.8 milestone Mar 18, 2022
@gavinsimpson
Copy link
Owner Author

As an extreme example, see this for the Swiss extreme rainfall example data set used in the second edition of Simon Wood's book:

require("gamair")
library("gratia")
library("mgcv")

data(swer, package = "gamair")

m <- gam(list(exra ~ s(nao) + s(elevation) + climate.region + s(N, E),
                   ~ s(year) + s(elevation) + climate.region + s(N, E),
                   ~ climate.region),
         family = gevlss(),
         data = swer)

draw(m)

with the draw(m) resulting in

swer-draw-output

Where the smooths for the scale parameter of the GEV come before those for the location parameter, and are in the wrong order within those parameters!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant