Thread Subject:
lsqcurvefit

Subject: lsqcurvefit

From: Hugh

Date: 25 Sep, 2012 17:07:07

Message: 1 of 3

Hi there,

In the code below I pass daily yields to lsqcurvefit.

Just want to check what lsqcurvefit does?

Does it try and fit the all the parmatmers at the same time? I.e. for each set of test parameters it fits calculates the sum of suared errors for every day (giving a daily SSE) then sums these daily SSE to give a total SSE and then try to minimise that.

Or does it find the best fit for each day and then average?

I'm assuming the former but just want to check.

.........................................................................................
%% data fitting parameters
[1] clc
[2] close all
[3] clear screen
[4] data= dlmread('yield.txt','\t');
[5] ydata=data(2:end,:);
[6] k=size(ydata);
[7] for i=1:k(1)
[8] xdata(i,:)=data(1,:);
[9] end
[10] c0 = [1 1 1 1 1 1];
[12] lbn = []; % lower bound
[13] ubn = []; % upper bound
[14] options = [15]optimset('LargeScale','on','MaxFunEvals',100000,'TolFun',1e-5,'MaxIter',10000);
[16] % datafitting
[17] [cn,error]=lsqcurvefit(@PrimePerm,c0,xdata,ydata,lbn,ubn,options);
.........................................................................................

Subject: lsqcurvefit

From: Steve Grikschat

Date: 26 Sep, 2012 14:47:08

Message: 2 of 3

"Hugh" wrote in message <k3sobr$59e$1@newscl01ah.mathworks.com>...
> Hi there,
>
> In the code below I pass daily yields to lsqcurvefit.
>
> Just want to check what lsqcurvefit does?
>
> Does it try and fit the all the parmatmers at the same time? I.e. for each set of test parameters it fits calculates the sum of suared errors for every day (giving a daily SSE) then sums these daily SSE to give a total SSE and then try to minimise that.

This is correct. The function you provide must compute each day's residuals: F(x,X). Lsqcurvefit internally computes

|| Y - F(x,X)||^2

Hope this helps.
+Steve

Subject: lsqcurvefit

From: Hugh

Date: 26 Sep, 2012 15:07:05

Message: 3 of 3

Thanks Steve

"Steve Grikschat" wrote in message <k3v4hc$2s3$1@newscl01ah.mathworks.com>...
> "Hugh" wrote in message <k3sobr$59e$1@newscl01ah.mathworks.com>...
> > Hi there,
> >
> > In the code below I pass daily yields to lsqcurvefit.
> >
> > Just want to check what lsqcurvefit does?
> >
> > Does it try and fit the all the parmatmers at the same time? I.e. for each set of test parameters it fits calculates the sum of suared errors for every day (giving a daily SSE) then sums these daily SSE to give a total SSE and then try to minimise that.
>
> This is correct. The function you provide must compute each day's residuals: F(x,X). Lsqcurvefit internally computes
>
> || Y - F(x,X)||^2
>
> Hope this helps.
> +Steve

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Contact us