Linear regression with more than two unknowns

1 view (last 30 days)
akh1
akh1 on 23 Apr 2014
Edited: Star Strider on 24 Apr 2014
Assuming that I have 10 values of X(measured):Xm and 10 values of Y(measured): Ym. I know the model of Y=f(X) has the form: Y=(a+b)*X+c. Can I determine a, b and c using the cftool or can I only determine a+b and c ?

Answers (1)

Star Strider
Star Strider on 23 Apr 2014
The objective function you supply to any curve-fitting function determines the parameters that will be estimated, so in your example, a, b, and c will all be uniquely estimated. Be sure to get the 95% confidence intervals so you know if they are significant. (I suspect one will not be.) Combining parameters such as you want is generally not recommended, unless a and b (in this example) are used elsewhere in the function either independently or as a factor or argument as (a-b) or some such.
  2 Comments
Image Analyst
Image Analyst on 24 Apr 2014
Edited: Image Analyst on 24 Apr 2014
How can he get a and b each uniquely? As far as I know he can only get the sum a+b, and there are lots of a and b that will sum to whatever coefficient it comes up with.
coeffs = polyfit(Xm, Ym, 1);
a_plus_b = coeffs(1); % Inifinite # of a & b that will sum to coeffs(1).
c = coeffs(2);
Star Strider
Star Strider on 24 Apr 2014
Edited: Star Strider on 24 Apr 2014
The regression function will estimate all the parameters requested of it, but it estimates the individual elements of summed parameters like (a+b) here as best it can. (I used nlinfit here because I’m more familiar with it than the linear solvers.)
f = @(b,x) (b(1) + b(2)).*x + b(3);
b = [3 5 7];
x = 1:10;
y = f(b,x)+rand(1,10)-.5;
[b,R,J,CovB,MSE,ErrorModelInfo] = nlinfit(x, y, f, zeros(3,1));
b
ci = nlparci(b,R,'covar', CovB)
produces:
b =
4.0149e+000
4.0149e+000
6.9965e+000
ci =
3.9709e+000 4.0588e+000
3.9709e+000 4.0588e+000
6.4511e+000 7.5419e+000
Changing the objective function to:
f2 = @(b,x) (b(1) + b(2)).*x + b(3).*b(2).^b(1);
will provide unique solutions:
b =
5.3045e+000
2.5513e+000
6.0922e+000
ci =
5.0843e+000 5.5246e+000
2.4551e+000 2.6474e+000
6.0469e+000 6.1375e+000

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!