Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Error from exponential regression

Subject: Error from exponential regression

From: Liqing

Date: 6 Aug, 2008 01:07:03

Message: 1 of 5

Hi,

I have two columns of data: x and y. I fitted y against x
with exponential regression. The resulting equation is:
y = a*exp(b*x).

My question is how can I estimate the standard deviation
of a and b?

Your help is greatly appreciated!

Subject: Error from exponential regression

From: Bruno Luong

Date: 6 Aug, 2008 05:29:02

Message: 2 of 5

"Liqing " <liqingj@gmail.com> wrote in message
<g7atfm$a9$1@fred.mathworks.com>...
> Hi,
>
> I have two columns of data: x and y. I fitted y against x
> with exponential regression. The resulting equation is:
> y = a*exp(b*x).
>
> My question is how can I estimate the standard deviation
> of a and b?
>

You forgot to tell us what kind of noise you have on the
data, and how do you fit your data.

But even for Gaussian noise, the trust region of the
(non-linear) model would not be a nice ellipsoid. You need
to approximate it somehow with Jacobian of the model or
Hessian of the cost function or using any high order term.

Bruno

Subject: Error from exponential regression

From: John D'Errico

Date: 6 Aug, 2008 08:20:03

Message: 3 of 5

"Liqing " <liqingj@gmail.com> wrote in message
<g7atfm$a9$1@fred.mathworks.com>...
> Hi,
>
> I have two columns of data: x and y. I fitted y against x
> with exponential regression. The resulting equation is:
> y = a*exp(b*x).
>
> My question is how can I estimate the standard deviation
> of a and b?
>
> Your help is greatly appreciated!

I describe how to do this in my optimization
tip and tricks file. Find it here:

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?
objectId=8553&objectType=FILE

Make up some data as an example...

x = rand(100,1)*4-2;
y = 1.5*exp(.5*x) + randn(size(x))/10;
plot(x,y,'o')

% Now, fit it using the model y=a*exp(b*x)
abfun = @(ab) ab(1)*exp(ab(2)*x)-y;

abstart = [1 1]';
abEst = fminsearch(@(ab) sum(abfun(ab).^2),abstart)

% abEst =
% 1.493
% 0.50739
% (reasonably close)

% Compute the Jacobian matrix, evaluated at
% the final estimate. (If you don't know how
% to do this yourself, download my derivest
% tools from the file exchange.) Thus, either

jac = [exp(abEst(2)*x),abEst(1)*exp(abEst(2)*x).*x];

% or ...

jac = jacobianest(abfun,abEst);

% Compute the residuals
res = abfun(abEst);

% Compute the standard error of the residuals.
% Note that I've divided by n-2, since there are
% 2 parameters that we estimated.
ser = sqrt(sum(res.^2)/(length(x)-2));

% Compute a covariance matrix of the parameters
% (yeah, I know I used inv.)
Cab = ser^2*inv(jac'*jac);

% The parameter standard deviations...
Sab = sqrt(diag(Cab))

Sab =
     0.011591
    0.0060296

% +/- 2*sigma bounds on ab
[abEst-2*Sab,abEst,abEst+2*Sab]
ans =
       1.4699 1.493 1.5162
      0.49533 0.50739 0.51945
 

You can find derivest here:

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?
objectId=13490&objectType=FILE#

HTH,
John

Subject: Error from exponential regression

From: Liqing

Date: 6 Aug, 2008 14:32:02

Message: 4 of 5

Hi Bruno,

Thank you for the reply.

Sincerely,

LQ

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in
message <g7bcqu$k8i$1@fred.mathworks.com>...

> >
>
> You forgot to tell us what kind of noise you have on the
> data, and how do you fit your data.
>
> But even for Gaussian noise, the trust region of the
> (non-linear) model would not be a nice ellipsoid. You
need
> to approximate it somehow with Jacobian of the model or
> Hessian of the cost function or using any high order
term.
>
> Bruno

Subject: Error from exponential regression

From: Liqing

Date: 6 Aug, 2008 14:36:02

Message: 5 of 5

Hi John,

You really helped me out!!! It works great. Thank you for
your time and kind help!

BTW, I notice that you wrote many high rated .m files. I
appreciate your great contribution to the community.

Sincerely,

LQ


"John D'Errico" <woodchips@rochester.rr.com> wrote in
message <g7bmrj$35f$1@fred.mathworks.com>...

> I describe how to do this in my optimization
> tip and tricks file. Find it here:
>
>
http://www.mathworks.com/matlabcentral/fileexchange/loadFil
e.do?
> objectId=8553&objectType=FILE
>

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us