Multiple Linear Regression; Terms in X

11 ビュー (過去 30 日間)
Theo Pap
Theo Pap 2022 年 1 月 25 日
コメント済み: Theo Pap 2022 年 1 月 25 日
I would like to ask why in the carsmall example X has the extra term x1.*x2, like this:
X = [ones(size(x1)) x1 x2 x1.*x2];
Running b = regress(y,X) returns
b = 4×1
60.7104
-0.0102
-0.1882
0.0000
which means that eitherway the last term plays no role.
Thanks :)

回答 (1 件)

Benjamin Thompson
Benjamin Thompson 2022 年 1 月 25 日
It is a bilinear fit so the regression is attempting to find the optimal b vector that fits a two-input function F of X and Y:
YFIT = b(1) + b(2)*X1FIT + b(3)*X2FIT + b(4)*X1FIT.*X2FIT;
Hence, the ones in the first column of X in your example since that is the constant. This technique can also be used to fit to polynomial functions and other nonlinear functions as long as the problem is linear in the coefficients you solve for.
  1 件のコメント
Theo Pap
Theo Pap 2022 年 1 月 25 日
So it is just an extra term for polynomial fit. That's why the yfitted mesh is curved and not a straight plane. Ok, it make sense. Initially it just seemed to me a totally random thing to do. Thanks.

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

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by