W/o the data itself can't really tell, but certainly doesn't appear that the plot is the actual LS quadratic for the data given, no.
...
Oh, reread the post again to see if missed something -- and I see I did, and it's undoubtedly the cause of the problem--
plot(xRange,polyval(flip(Reg.Coefficients.Estimate)));
is a problem. First, POLYVAL is missing an array of x values at which to be evaluated so that'll have not worked at all as is; I'm guessing that what you had was
plot(xRange,polyval(flip(Reg.Coefficients.Estimate,xRange)));
and xRange is just the two end points of X. If so, you simply displayed the line between those points and not the actual curvefit result between...that would produce the symptom as it appears what little curvature there is is upwards at the ends so those two fitted points would be expected to be above the observed data there, thus raising the whole line above the group as whole.
But, I'd suggest for only eight points and with the very little evidence of curvature that the quadratic is overfitting the data.
If you do want the extra diagnostics and all of the linear model tool, use feval or predict to evaluate it, though.
would have drawn the curve thru the points as they're kept as part of the object. Or,
would include confidence bounds to indicate something about the fit quality...
But, I'll grant it's really, really tough to find this out from the documentation; you have to dig into the LinearMddel class description itself to actually get to the properties and list of properties and a succinct comprehensive list of methods and what they do; all the examples are somewhat helpful in seeing an overview but trying to find something specific is pretty-much obfuscated by all the clutter.
If you also happen to have the Curve Fit TB, the cfit object is somewhat easier to use, albeit without all the statistics stuff.
Or, if you only need the fit and results and don't care about the niceties of significance and all that, then just the venerable ol' polyfit|polyval are as simple as it gets (the coefficients are even in self-consistent order then :)).
Best Answer