cmu-delphi / epipredict

Tools for building predictive models in epidemiology.
https://cmu-delphi.github.io/epipredict/
Other
8 stars 9 forks source link

Singular design matrix: training fails on literally constant data #266

Open dsweber2 opened 11 months ago

dsweber2 commented 11 months ago

This is possibly more a problem with parsnip, but not being able to predict a literally flat value is not great.

dajmcdon commented 9 months ago

Really, this may or may not be a problem depending on the engine. With lm(), when X has more than 1 constant column, the associated coefficients will be NA but prediction is possible. glmnet() silently ignores them and estimates their coefficients to be 0.

On the other hand, if y = constant, then lm() will run, but glmnet() errors out.

This needs a reprex showing where / when it fails.

Additionally, erroring out here may well be desirable, depending on the message. The goal of epipredict is not to "always give predictions". If there's a problem with the data, the user should be told.