How can I turn new dummy variables into the same dummy variables I used to create a model?
显示 更早的评论
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?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Analysis of Variance and Covariance 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!