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

smooth_samples() would fail if supplied data when relocating data columns #255

Closed
gavinsimpson opened this issue Mar 11, 2024 · 0 comments
Closed

Comments

@gavinsimpson
Copy link
Owner

gavinsimpson commented Mar 11, 2024

smooth_samples() was failing when data was supplied that contained more variables than were used in the smooth that was being sampled. Hence this generally fail unless a single smooth was being sampled from or the model contained only a single smooth. The function never intended to retain all the variables in data but was written in such a way that it would fail when relocating the data columns to the end of the posterior sampling object.

library("mgcv")
library("gratia")

df <- data_sim("eg1")
m_gam <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = df, method = "REML")
smooth_samples(m_gam, data = df, seed = 2, n = 1)

fails with

> smooth_samples(m_gam, data = df, seed = 2, n = 1)                                              
Error in `relocate()` at gratia/R/posterior-samples.R:810:5:
! Can't subset columns that don't exist.
✖ Columns `y`, `x1`, `x2`, `x3`, `f`, etc. don't exist.
Run `rlang::last_trace()` to see where the error occurred.
gavinsimpson added a commit that referenced this issue Mar 11, 2024
gavinsimpson added a commit that referenced this issue Mar 11, 2024
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

1 participant