From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Solving simultaneously for two unknowns for fitting the data with a model
Date: Wed, 7 Nov 2012 23:19:14 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 25
Message-ID: <k7eq9i$r1n$>
References: <k79lb7$gtr$> <k79udt$g69$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1352330354 27703 (7 Nov 2012 23:19:14 GMT)
NNTP-Posting-Date: Wed, 7 Nov 2012 23:19:14 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2236182
Xref: comp.soft-sys.matlab:782277

Thank you for the reply, I think it is optimal in my case to solve for the p and k independently to using fminsearch! Thanks,


"Roger Stafford" wrote in message <k79udt$g69$>...
> "Suyash" wrote in message <k79lb7$gtr$>...
> > Suppose my model is an equation similar to a power function, Y = k.(Ix^p - Th^p) in which, k, p, and Th are constants. I know the values of Ix and corresponding Y. Both Ix and Y are an array. I want to fit my data (Ix ~ Y) with the equation I mentioned earlier (i.e.  Y = k.(Ix^p - Th^p) ). How do iterate simultaneously on the values of p and k to find the best least-squares fit? 
> - - - - - - - - -
>   You are given the vectors Ix and Y and the fixed scalar Th and wish to adjust the parameters k and p so as to minimize the quantity
>  S = sum(k*(Ix.^p-Th^p)-Y).^2 .
> Do I state your problem correctly?
>   For any given value of p the value of k which minimizes S is
>  k = sum(Y.*(Ix.^p-Th^p))/sum((Ix.^p-Th^p).^2)
> as one can see by taking the partial derivative of S with respect to k.
>   By substituting this expression for k one obtains S as a function of the single parameter p.  If you know of upper and lower bounds for p, you can then use matlab's 'fminbnd' to find a minimum.
>   Alternatively you can use 'fminsearch' to find the minimum using either the single-variable problem with p using the above substitution for k, or the two-variable problem with both p and k as variables.  (The single-variable usage is probably more efficient in this case.)
> Roger Stafford