non-linear fitting with min(sse) of x

3 views (last 30 days)
Hi there, I have X1, X2 and Y1 data set and a function of x=f(y,B), but not y=g(x,B), where B is a vector of parameters. Unfortunately, the inverse function of f can't be solved analytically. So I am stuck with x=f(y,B).
The problem is I want to estimate the parameter values of the function, based on X1 and Y1, so that I can use it to estimate Y2 from X2, numerically.
Is it possible at all to estimate parameter values based on SSE regarding Y1, and not X1? NonLinearModel.fit and nlinfit do not seem to offer the option.
Cheers, PA
  3 Comments
Pakorn
Pakorn on 24 Nov 2012
I am terribly sorry. I want to estimate B based on min(SSE regarding Y1). That is I have x=f(y,B), but I want to calculate SSE on the horizontal axis (axis of Y1). Normal functions doesn't seem to offer this.
There is a good reason for this. I want to predict Y2 (response variable) from X2 (explanatory variable), but I only have x=f(x,B). Function with B estimated based on min(SSE regarding Y1) will predict Y2 more correctly, with respect to X1-Y1 relationship, since it minimises the error of the (soon-to-be-predicted) Y values.
Matt J
Matt J on 24 Nov 2012
Then see my Answer below.

Sign in to comment.

Accepted Answer

Matt J
Matt J on 23 Nov 2012
Edited: Matt J on 24 Nov 2012
If you have the Optimization Toolbox, maybe you can express g(x,B) in the following way and pass it to your favorite solver,
g=@(x,B) fsolve(@(y) f(y,B)-x , y0);
You could also generalize this by making the initial guess y0 a more general function of (x,B), if you know a good custom initialization scheme.
  4 Comments
Matt J
Matt J on 24 Nov 2012
Edited: Matt J on 24 Nov 2012
No, nothing I've given here has anything to do with solving for Y2 or assumes anything is given. It's just a way of computing the inverse g(x,B) for any pair (x,B) without knowing its explicit analytical form. I illustrate below with a simple function f(y,B)= y.^2 +B and compare it with its known analytical inverse gtrue(x,B)=sqrt(x-B). Instead of FSOLVE though, I use FMINSEARCH because I don't have the Optimization Toolbox.
f=@(y,B) y.^2+B;
y0=@(x,B) max(B,sqrt(abs(x))); %A heuristic initializer
g=@(x,B) fminsearch(@(y) (f(y,B)-x).^2, y0(x,B));
gtrue=@(x,B) sqrt(x-B);
We can now check whether g(x,B) and gtrue(x,B) give the same approximate values for different pairs of inputs x and B:
>> gtrue(1,1), g(1,1)
ans =
0
ans =
-8.8818e-16
>> gtrue(2,1), g(2,1)
ans =
1
ans =
1.0000
>> gtrue(5,3), g(5,3)
ans =
1.4142
ans =
1.4142
>> gtrue(15,5), g(15,5)
ans =
3.1623
ans =
3.1623
Pakorn
Pakorn on 24 Nov 2012
Edited: Pakorn on 24 Nov 2012
Right,thank you very much. You are very much appreciated. Ps. Btw, the code I put above should work, right?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!