From: strat on
Hello all,

I need your help for a nonlinear regression problem. I have a function y=f(x1,x2). I have estimate a linear regression y=c+a*x1+b*x2 using the following commands
X = [ones(size(x1)) x1 x2];
[b,Ibeta,res,Ires,stats] = regress(y,X,0.05) and i have estimated c,a,b
(Hope i have no errors so far)
Now i would like to estimate a function f=c+a*x1^a1+b*x2^a2, which is nonlinear, so i can check which is the best method (linear or nonlinear).
How i can do this? I have seen the functions 'nlitfit', ' lsqnonlin' etc but i haven't made it.Can you please help me?

Best,
stratos
From: Wayne King on
"strat " <e-goum(a)hotmail.com> wrote in message <hsoi08$1vo$1(a)fred.mathworks.com>...
> Hello all,
>
> I need your help for a nonlinear regression problem. I have a function y=f(x1,x2). I have estimate a linear regression y=c+a*x1+b*x2 using the following commands
> X = [ones(size(x1)) x1 x2];
> [b,Ibeta,res,Ires,stats] = regress(y,X,0.05) and i have estimated c,a,b
> (Hope i have no errors so far)
> Now i would like to estimate a function f=c+a*x1^a1+b*x2^a2, which is nonlinear, so i can check which is the best method (linear or nonlinear).
> How i can do this? I have seen the functions 'nlitfit', ' lsqnonlin' etc but i haven't made it.Can you please help me?
>
> Best,
> stratos

Hi Stratos, I'm trying to understand your model f=c+a*x1^a1+b*x2^a2. Specifically, are a1 and a2 parameters of your model or just known powers that the predictor variables are being raised to? If they are just powers like:
f=c+a*x1^2+b*x2^3

and your parameters are [c,a,b] then you still have a regression model that is linear in the parameters. You can just construct your design matrix with the 2nd and 3rd columns as x1^2 and x2^3.

Or is it the case that a1 and a2 are parameters that you are trying to estimate?

If you really need to fit a nonlinear model, what do you mean by you've seen nlinfit, but that you "haven't made it." Are you having trouble with the concept of a function handle as an input?

Wayne
From: strat on
> Hi Stratos, I'm trying to understand your model f=c+a*x1^a1+b*x2^a2. Specifically, are a1 and a2 parameters of your model or just known powers that the predictor variables are being raised to? If they are just powers like:
> f=c+a*x1^2+b*x2^3
>
> and your parameters are [c,a,b] then you still have a regression model that is linear in the parameters. You can just construct your design matrix with the 2nd and 3rd columns as x1^2 and x2^3.
>
> Or is it the case that a1 and a2 are parameters that you are trying to estimate?
>
> If you really need to fit a nonlinear model, what do you mean by you've seen nlinfit, but that you "haven't made it." Are you having trouble with the concept of a function handle as an input?
>--------------------------------------------------------------------

Hi, I am trying to estimate a model that fits the best in data so i have to estimate the coefficients c,a,b,a1,a2 of the model f=c+a*x1^a1+b*x2^a2. They are not known.
Nlinfit has a parameter called 'fun'. Here you type a function. I have read a matlab example that uses the hugen function but i can't understand how it works.
What i need is to estimate the coefficients of that model f=c+a*x1^a1+b*x2^a2. I have made it with the linear f=c+a*x1+b*x2, but i want to see also the nonlinear.
From: ImageAnalyst on
On May 16, 9:30 am, "strat " <e-g...(a)hotmail.com> wrote:
> What i need is to estimate the coefficients of that model f=c+a*x1^a1+b*x2^a2. I have made it with the linear f=c+a*x1+b*x2, but i want to see also the nonlinear.
-------------------------------------
You can also linearize the equation by taking the log of it. Then
just use the regular polyfit() to solve for the new coefficients
(which are combinations of your original coeffs), and a few algebraic
equations to get back your original coefficients. That's a well known
and handy trick that often produces fairly good results. Just an
option for you to consider if you can't ever get nlfit to work.

From: strat on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <0aa32862-68b6-4a76-b068-56a6ce7827a4(a)u7g2000vbq.googlegroups.com>...
> On May 16, 9:30 am, "strat " <e-g...(a)hotmail.com> wrote:
> > What i need is to estimate the coefficients of that model f=c+a*x1^a1+b*x2^a2. I have made it with the linear f=c+a*x1+b*x2, but i want to see also the nonlinear.
> -------------------------------------
> You can also linearize the equation by taking the log of it. Then
> just use the regular polyfit() to solve for the new coefficients
> (which are combinations of your original coeffs), and a few algebraic
> equations to get back your original coefficients. That's a well known
> and handy trick that often produces fairly good results. Just an
> option for you to consider if you can't ever get nlfit to work.
----------------------------------------------------------------

I have used the polyfit but i think it works only when i have one independent variable (x). I have two x1,x2. I don't want to linearize, i just want it just it is f=c+a*x1^a1+b*x2^a2.