Closed gavinsimpson closed 1 year ago
The issue here is that the data contains NA
s 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