How to make intercept 0 in fitlm?

조회 수: 35 (최근 30일)
Kash Costello
Kash Costello 2018년 6월 12일
댓글: Kash Costello 2018년 6월 13일
Hello,
i have this code here. I got my result for this code but I want the intercept to be 0. Does anyone know how to do that?
A = [3 ; 6 ; 9 ; 12 ; 15 ; 18 ; 21 ; 24];
b = [13.65249633; 27.43151638; 40.81176096; 54.58291934; 69.15880849; 82.02503856; 95.68163465; 1.10E+02];
mdl = fitlm(A,b,'linear','RobustOpts','off')
Result: Estimate SE tStat pValue
______ ______ ______ ________
(Intercept) -0.14799 0.27475 -0.53862 0.60954
x1 4.579 0.018137 252.47 2.6057e-13
is it possible to make the Estimated intercept 0? I am pretty sure that the estimated x1 will change in value and that's actually what I'm aiming for...
Thanks a lot!

채택된 답변

Rik
Rik 2018년 6월 12일
If you just want the value for x1:
A = [3 ; 6 ; 9 ; 12 ; 15 ; 18 ; 21 ; 24];
b = [13.65249633; 27.43151638; 40.81176096; 54.58291934;...
69.15880849; 82.02503856; 95.68163465; 1.10E+02];
x1=A\b;
If you want to force the intercept to 0, you can find the solution in the fitlm doc:
mdl = fitlm(A,b,'linear','Intercept',false)%'RobustOpts','off' is the default
  댓글 수: 1
Kash Costello
Kash Costello 2018년 6월 13일
Thank you so much! I got it :D

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resampling Techniques에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by