I had created contrast variables for few categorical variables in the data set. I split the data into Training and Test data. The contrast levels are dropped when the model is run. I could not proceed with the predict because the model is failed. Below is the code. Month & day are categorical variables and I have contrasted them using Simple coding method.
# Split the data
Train <- dat[1:80,] #First 80 records - Training data
Test <- dat[81:111,] # Rest of the records - Test data
# Regression
fit <- lm(Ozone~Wind+Solar.R+Month+Day+Temp, data=Train)
summary(fit)
When I run the model with Train data set, I get the error 'contrasts dropped from factor Month due to missing levels'. Can you please clarify how do we train the model with the contrast variable present and predict for the test set?