How to run a fitlm regression for day of the week dummy variables for financial return data
2 views (last 30 days)
Show older comments
Hi, I am struggling with how to set up my data to run the fitlm function for day of the week dummy variables.
My data that I have set up in a (2500,6) matrix where C1 is the returns data and C2:C6 are column vectors of zeros and ones where C2 - 1 is for Monday C3 - 1 represents tuesday and so on.
My reults are as follows:
Fitlm:
-1.31153554169770 0.953057779050930 -1.37613434413573 0.169037651868845
-0.131905728387301 0.0695763306138066 -1.89584197993226 0.0582218112735167
0.0843907252336952 0.0872037277677016 0.967742175638410 0.333368798643977
0 0 NaN NaN
-0.0247423867293685 0.0984537148158696 -0.251309834023453 0.801617743803277
0.169341528221423 0.0952957370120605 1.77701053091169 0.0758206160733013
0.460051465197619 0.0967773549107878 4.75370984897974 2.23973346792996e-06
How do i correct my input to replace this row of Nan values?
0 Comments
Answers (1)
Spruha
on 28 Jan 2025
Hello harry,
As you mentioned, you are experiencing issues with data setup for “fitml” function, resulting in the output containing NaN.
When you include dummy variables for all categories of a categorical variable (like days of the week) without a reference category, it leads to perfect multicollinearity.
To avoid this, one category is usually omitted, and its effect is captured in the intercept.
Hope this helps.
0 Comments
See Also
Categories
Find more on Analysis of Variance and Covariance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!