I have created a linear regression model which takes in 4 categorical variables (dayofweek, month, isholiday, and period). It uses the dummyvar() function to successfully create a matrix of dummy variables. This is my problem: I went to try and predict a future point using my model but I'm unclear as to how the dummy variable aspect works now. For example, dummyvar() picked up that there are 12 different months in the year and thus it created 12 columns (one for each month). But now that I'm predicting, I don't have 12 months in the samples I'd like to predict. For example, if I want to predict what the dependent variable will be on Halloween, the input vector looks something like this:
[6 10 1 4].
If I use dummyvar() on this vector, I'm obviously not going to get what I want which is a 1 in the "October" column (a 0 in every other month column), and so on.
Is there a way to tell dummyvar to use the dummyvar matrix made earlier as a reference or does some other function do this?