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

cannot draw() a model with ordered factor as a random effect #99

Closed
StefanoMezzini opened this issue Mar 19, 2021 · 1 comment
Closed

Comments

@StefanoMezzini
Copy link

draw() returns the following error when asked to plot a model with an ordered factor as a random effect:
Error in .subset2(x, i, exact = exact) : attempt to select less than one element in integerOneIndex

I'm using gratia 0.5.1.9002, and I have updated all packages after updating R to 4.0.4.

The error occurs with both the github version and the CRAN version of gratia.

Reproducible example below:

library(mgcv)
library(gratia)
library(dplyr)
# re with ordered factors causes an error
gam(uptake ~ s(conc, Type, bs = 'fs', k = 5) + s(Plant, bs = 're'),
    family = Gamma('log'),
    data = CO2) %>%
  draw()

# re with unordered factor is ok
gam(uptake ~ s(Plant, bs = 're'),
    family = Gamma('log'),
    data = mutate(CO2, Plant = factor(Plant, ordered = FALSE))) %>%
  draw()
@StefanoMezzini StefanoMezzini changed the title cannot draw() a model with order factor as a random effect cannot draw() a model with ordered factor as a random effect Mar 19, 2021
gavinsimpson added a commit that referenced this issue Apr 8, 2021
@gavinsimpson
Copy link
Owner

Thanks @StefanoMezzini — that was an easy fix in the end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants