After the recent changes to predict to handle various complex formulas and mismatched factors, predict checks the original covariates for valid factor levels:
However if the siteCovs contain factors that aren't then used in the model for which prediction is being done, these xlevs are being checked against non-existent columns in the newdata:
This results in a warning but the predictions are still generated correctly.
I dealt with this (I think) in the predict methods for occuMulti and occuMS by removing elements from xlevs that were not in the newdata before building the model frame:
After the recent changes to
predict
to handle various complex formulas and mismatched factors,predict
checks the original covariates for valid factor levels:https://github.com/rbchan/unmarked/blob/f3708507fe552c7e040d1edbfa47771dc3126dcc/R/unmarkedFit.R#L1629
However if the
siteCovs
contain factors that aren't then used in the model for which prediction is being done, thesexlevs
are being checked against non-existent columns in the newdata:https://github.com/rbchan/unmarked/blob/f3708507fe552c7e040d1edbfa47771dc3126dcc/R/unmarkedFit.R#L1632
This results in a warning but the predictions are still generated correctly.
I dealt with this (I think) in the predict methods for
occuMulti
andoccuMS
by removing elements fromxlevs
that were not in the newdata before building the model frame:https://github.com/rbchan/unmarked/blob/f3708507fe552c7e040d1edbfa47771dc3126dcc/R/getDesign.R#L629