How to make intercept 0 in fitlm?

40 views (last 30 days)
Kash Costello
Kash Costello on 12 Jun 2018
Commented: Kash Costello on 13 Jun 2018
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!

Accepted Answer

Rik
Rik on 12 Jun 2018
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

More Answers (0)

Community Treasure Hunt

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

Start Hunting!