Incorporating Multiple Dummy Variables In A Regression Model
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Chris Herdelin
am 21 Mär. 2021
Kommentiert: Chris Herdelin
am 21 Mär. 2021
I was able to incorporate Dummy2008 into the regression model, but including all four dummies resulted in the error below. How do I code the four dummy variables so that I can include all of them in the model?
X2 = [CPI IP Tbill Dummy2008 Dummy2009 Dummy 2010 Dummy 2011];
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
0 Kommentare
Akzeptierte Antwort
dpb
am 21 Mär. 2021
Firstly, all have to be column vectors; secondly you'll have to have the same number of observations for each to build an array. You either truncate to the minimum number or augment with missing values or interpolated or somesuch to the longest.
regress treats NaN values in X or y as missing values. regress omits observations with missing values from the regression fit.
fitlm lets you input a vector/array of values to omit; I do not recall at the moment if it also treats NaN the same way automagically.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!