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
> draw(m3_hgam, residuals = TRUE, rug = FALSE, grouped_by = TRUE, parametric = TRUE)
Error in `map()`:
ℹ In index: 1.
Caused by error in `bind_cols()`:
! Can't recycle `level` (size 350) to match `partial` (size 252).
Run `rlang::last_error()` to see where the error occurred.
The text was updated successfully, but these errors were encountered:
The issue here is that the data contains NAs and hence the way parametric_effects() works to reconstruct the fitting data (along the lines of how termplot() does it) produces original data that contains the NA values. However, because the default in mgcv is to use na.action = na.omit, we have the observed incompatibility between the sizes of the variables being combined. If we fit the model with na.action = na.exclude, the issue goes away.
Options to consider to address this:
could run na.omit or complete.cases on the reconstructed data before predict()?
For factor parametric effects this is fine, but what about continuous terms? Are the reconstructed data the full thing passed to the data argument? In which case we only want to run those on the variables used in fitting the model.
could run distinct() on the reconstructed data and pass that to predict()?
could provide a better error message to suggest the source of the problem and suggest refitting with na.action = na.exclude?
From the rate hormone example in my GAM course,
m3_hgam
fails:draw()
throws an error with:The error is
The text was updated successfully, but these errors were encountered: