Trying to make a regression model; question about fitlm and intercept!

Hi.
So I am trying to make a simple regression model for my measurement data. I used the following code:
function regg2
x=[19.8044 19.8044 19.8044 19.8044 19.8044 19.8044 19.8044 19.8044 35.278 35.278 35.278 35.278 35.278 35.278 20.0042 20.0042 20.0042 20.0042 20.0042 20.0042 25.3008 25.3008 25.3008 25.3008 25.3008]';
y=[4.5 7 2 2 4 6 5 6.8 1 0 0 0.4 1 0 10 2 5 8.1 1.9 2 4.6 3.6 10 1.6 0.8]';
mdl= fitlm(x,y)
plotAdded(mdl)
And I get this nice little figure:
But I discussed this with my teacher and he seem to think it is not correct. He says that my model should have an intercept. The fitlm gives me intercept of 10 which means that b0 is approx. 1. But it does not seem to be the case.
I am sorry if I am a bit unclear. But the idea is to make a simple linear regression model and get the standard equation which would normally be:
y=b0+b1*x1
Am I misunderstanding the method? Am I wrong? If I am wrong, how should I go about my code to get my regression model and a similar figure?
Thanks in advance!

 Accepted Answer

... intercept of 10 which means that b0 is approx. 1
That does not appear to be correct. The intercept, ‘b0’ in your equation would be the y-intercept, and 10 would appear to be reasonable (from visual extrapolation only). The slope ‘b1’ appears to be about -0.3 (again visually).

2 Comments

I did the calculation in 3 different ways and get the same answer. 10 as b0 and approx 0.3 as b1. So you are probably right.
Thank you.
If my Answer helped you solve your problem, please Accept it!
.

Sign in to comment.

More Answers (0)

Asked:

on 12 May 2020

Commented:

on 14 May 2020

Community Treasure Hunt

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

Start Hunting!