How to deal with constant variables?

machine_learning
predictive_model
regression

#1

Hi guys, I have a set of train and test data and I have to build a regression model using them. All the predictors are binary variables. Some of the predictors are constant (have a single value) in the train dataset but not in the test dataset. How do I train a model a model in such situation without dropping any predictor ?


#2

I don’t think so there is option other than removing the constant column in the train and the test dataset.


#3

Would adding random noise to it help ?

Thanks


#4

Adding noise wouldn’t but if your column is not exactly a zero variance column but a near zero, then you might want to look at these two papers that describe the methods to deal with them.

  1. Zorn, C. (2005). A solution to separation in binary response models. Political Analysis, 13(2), 157-170

  2. Gelman, A., Jakulin, A., Pittau, M.G. and Su, Y.S. (2008). A weakly informative default prior distribution for logistic and other regression models. The Annals of Applied Statistics, 1360-1383


#5

Thanks @NSS