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
I encountered an issue while trying to run a significance test between two fitted surfaces using difference_smooths(). The test involves a GAM fit using a simple factor-by interaction smooth (Z ~ s(X, Y, bs = "tp", by = group)) with two groups. The error suggests a size mismatch in the vec_rbind() function from the vctrs package, likely during the call to dplyr::bind_rows().
Additional question: Are there other ways of running such a significance test? I would also like to try qgam.
Error in `vec_rbind()`:
! `value` (size 20000) doesn't match `x` (size 10000).
ℹ In file slice-assign.c at line 313.
ℹ Install the winch package to get additional debugging info the next time you get this error.
ℹ This is an internal error that was detected in the vctrs package.
Please report it at <https://github.com/r-lib/vctrs/issues> with a reprex (<https://tidyverse.org/help/>) and the full backtrace.
Backtrace:
▆
1. ├─base::source(...)
2. │ ├─base::withVisible(eval(ei, envir))
3. │ └─base::eval(ei, envir)
4. │ └─base::eval(ei, envir)
5. ├─gratia::difference_smooths(...) at c:\Users\me\Code\R-test-plot.R:25:1
6. ├─gratia:::difference_smooths.gam(...)
7. │ └─dplyr::bind_rows(out)
8. │ └─vctrs::vec_rbind(!!!dots, .names_to = .id, .error_call = current_env())
9. └─rlang:::stop_internal_c_lib(...)
10. └─rlang::abort(message, call = call, .internal = TRUE, .frame = frame)
Warning messages:
1: In grepl(mgcv_by_smooth_labels(select, by_var, f1), cnames, fixed = TRUE) :
argument 'pattern' has length > 1 and only the first element will be used
2: In grepl(mgcv_by_smooth_labels(select, by_var, f2), cnames, fixed = TRUE) :
argument 'pattern' has length > 1 and only the first element will be used
Additionally, the following warning messages appear:
Warning messages:
1: In grepl(mgcv_by_smooth_labels(select, by_var, f1), cnames, fixed = TRUE) :
argument 'pattern' has length > 1 and only the first element will be used
2: In grepl(mgcv_by_smooth_labels(select, by_var, f2), cnames, fixed = TRUE) :
argument 'pattern' has length > 1 and only the first element will be used
This is because you are being too specific about the smooths that you want to difference. The function only works for factor by smooths (at the moment), so there is no need to specify the the specific smooth:level combination. All you need is:
difference_smooths(fit, select="te(X,Y)")
for your example.
I should try to catch this issue and do something more user-friendly than the current vctrs error.
As for qgam() models; while I haven't tried it, I don't recall anything specific that would stop difference_smooths() from working unless the model you fitted was for multiple $\tau$ values - qgam() models inherit from class "gam" so I would expect difference_smooths() to just work. Reality might be a bit different though, so if it doesn't work let me know and I'll make it work.
Description:
I encountered an issue while trying to run a significance test between two fitted surfaces using
difference_smooths()
. The test involves a GAM fit using a simple factor-by interaction smooth (Z ~ s(X, Y, bs = "tp", by = group)
) with two groups. The error suggests a size mismatch in thevec_rbind()
function from thevctrs
package, likely during the call todplyr::bind_rows()
.Additional question: Are there other ways of running such a significance test? I would also like to try
qgam
.Code to Reproduce:
Error Message:
Additionally, the following warning messages appear:
Session Info:
Thank you for your attention!
The text was updated successfully, but these errors were encountered: