필터 지우기
필터 지우기

Column of ONES in multiple regression

조회 수: 8 (최근 30일)
Nuchto
Nuchto 2013년 1월 30일
What is the meaning of adding a column of ones in the multiple regression? Thanks a lot, G.

채택된 답변

Shashank Prasanna
Shashank Prasanna 2013년 1월 30일
편집: Shashank Prasanna 2013년 1월 30일
The columns of ones is for the intercept or the constant term as already pointed out above.
Ax = b
[a11 a12 1] [x1] [b1]
[a21 a22 1] [x2] = [b2]
[a31 a32 1] [x3] [b3]
It is basically for the x3 term in the model
b = a1*x1 + a2*x2 + 1*x3
=> b = a1*x1 + a2*x2 + x3
Since all regress does is A\b to solve the system, the ones have to explicitly be added.
In any case I recommend the use of the new LinearModel.fit function instead of regress, since it does this for you and also directly provides the fit statistics.

추가 답변 (2개)

Image Analyst
Image Analyst 2013년 1월 30일
편집: Image Analyst 2013년 1월 30일
That means that your equation (model) will have a constant offset, like the "a3" in y = a1 * x1 + a2 * x2 + a3. In the manual method of making the arrays for least squares regression, you make a "tall" array of your measured (observed) values for x1 and x2
x1(1), x2(1), 1
x1(2), x2(2), 1
x1(3), x2(3), 1
x1(4), x2(4), 1
...
x1(n), x2(n), 1
Then you do the matrix math and you get estimates for all the "a" coefficients of your model.
  댓글 수: 2
Nuchto
Nuchto 2013년 1월 30일
편집: Nuchto 2013년 1월 30일
Unfortunately I couldn't follow your answer ;( Why is a constant offset necessary? Wouldn't it be there anyway without specifying it (zero)?
Image Analyst
Image Analyst 2013년 2월 2일
No there wouldn't. You'd have an equation like this:
y = a1 * x1 + a2 * x2
instead of this:
y = a1 * x1 + a2 * x2 + a3
If you want, in the first equation you can say that the offset is zero but I don't know how that helps. I hope you can see that the second equation is different than the first equation. The second equation will give you an offset. If, for x = [0 1 2 3 4] you had y = [10 11 12 13 14], then you'd have y=x+10. If you didn't have the 1's you'd get an equation like y=12*x or something - totally different.

댓글을 달려면 로그인하십시오.


Oleg Komarov
Oleg Komarov 2013년 1월 30일
In regress(), you need to add a column of ones to allow for an intercept in the regression. Otherwise, you constrain the fit to go through the origin.
  댓글 수: 4
Nuchto
Nuchto 2013년 2월 2일
I would need a more basic explanation. I am not a mathematician... What does the "fit to go through the origin" mean?
Shashank Prasanna
Shashank Prasanna 2013년 2월 2일
편집: Shashank Prasanna 2013년 2월 2일
It means the constant acts as an intercept term I found a random image which might make things clearer to you:
the 10 is the intercept or in your case the value of the coefficient of ONE. Without the 10, the line would pass through the origin.
If you look at my example below in my plot, it becomes clearer how the ONEs contribute to the intercept 'x3'

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by