Incorporating Multiple Dummy Variables In A Regression Model

2 ビュー (過去 30 日間)
Chris Herdelin
Chris Herdelin 2021 年 3 月 21 日
コメント済み: Chris Herdelin 2021 年 3 月 21 日
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.

採用された回答

dpb
dpb 2021 年 3 月 21 日
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.
  1 件のコメント
Chris Herdelin
Chris Herdelin 2021 年 3 月 21 日
This is great, thanks! I was able to run the regression!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultiple Linear Regression についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by