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

draw() fails with parametric = TRUE if there aren't any parametric effects to actually plot #282

Closed
gavinsimpson opened this issue Apr 26, 2024 · 0 comments
Assignees
Labels
bug Something isn't working plotting
Milestone

Comments

@gavinsimpson
Copy link
Owner

Consider this example from the GAM course:

# load data
rats_url <- "https://bit.ly/rat-hormone"
rats <- read_table(rats_url, col_types = "dddddddddddd-")
# ignore the warning - it"s due to trailing white space at the ends of each
#   row in the file

rats <- rats %>%
    mutate(treatment = fct_recode(factor(group, levels = c(1, 2, 3)),
                                  Low = "1",
                                  High = "2",
                                  Control = "3"),
           treatment = fct_relevel(treatment, c("Control", "Low", "High")),
           subject = factor(subject))

m1_gam <- gam(response ~ treatment:transf_time +
                  s(subject, bs = "re") +
                  s(subject, transf_time, bs = "re"),
              data = rats, method = "REML")

If we now plot this including the random effects:

> draw(m1_gam, parametric = TRUE)
Interaction terms are not currently supported.
Error in `unnest()`:
! Can't select columns that don't exist.Column `data` doesn't exist.
Run `rlang::last_trace()` to see where the error occurred.

The first warning is right - we don't allow plotting of interaction parametric effects, but as these are the only effects something goes wrong and we get an error.

@gavinsimpson gavinsimpson added bug Something isn't working plotting labels Apr 26, 2024
@gavinsimpson gavinsimpson added this to the 0.10 milestone Apr 26, 2024
@gavinsimpson gavinsimpson self-assigned this Apr 26, 2024
gavinsimpson added a commit that referenced this issue May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working plotting
Projects
None yet
Development

No branches or pull requests

1 participant