How to calculate regression with dummy variables?

19 ビュー (過去 30 日間)
JFz
JFz 2018 年 7 月 17 日
編集済み: the cyclist 2018 年 7 月 17 日
Hi, I am trying to use 2nd degree polynomial regression with dummy variables. Which function should I use? Thanks for any help!

採用された回答

the cyclist
the cyclist 2018 年 7 月 17 日
編集済み: the cyclist 2018 年 7 月 17 日
If you have the Statistics and Machine Learning Toolbox, take a look at the fitlm function.
You might also find the dummyvar command useful for creating dummy variables.
Take a look at Regression with Categorical Covariates for an example.
  2 件のコメント
JFz
JFz 2018 年 7 月 17 日
Thanks! But fitlm is linear model. I need polynomial (2 degree or 3 degree). What function should I use? Should I use fitnlm or polyfit? Thanks again! Jennifer
the cyclist
the cyclist 2018 年 7 月 17 日
編集済み: the cyclist 2018 年 7 月 17 日
Do you mean that you have polynomials for your independent variables, like
y = a + b*x + c*x^2
That is a linear model. "Linear" refers to the coefficients, not the powers (or whatever) of the variables.
On the other hand, something like
y = a + x^b
is nonlinear in the coefficient. Yes, you would need fitnlm for something like that.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSupport Vector Machine Regression についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by