Incorporating Multiple Dummy Variables In A Regression Model

9 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

dpb
dpb il 21 Mar 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.

Più risposte (0)

Prodotti


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by