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:
multiple variable exponential regression

Subject: multiple variable exponential regression

From: TARUN REDDY

Date: 4 Nov, 2013 19:32:07

Message: 1 of 2

Hello,
I was using other nonlinear regression methods but was getting an imaginary solution (a+ib) form

I need to solve y = a0 + (a1*(x1^b1)) + (a2*(x2^b2)) + (a3*(x3^b3))

a0, a1, a2, a3 are known

I have data set for y, x1, x2, x3

I need to calculate b1, b2, b3

I was using following code till (this yields imaginary solutions)

opts = statset ('nlinfit');
opts.RobustWgtFun = 'bisquare';
beta0 = [0, 0, 0, 0];
modelfun
= @(b, x)((100 - 15*(x(2, :).^b(1)))) - (40*((x(3, :).^b(2)))) - (15*((x(4, :).^b(3))))
x = TestData;
y = x(1, :);

[beta, R, J, CovB, MSE] = nlinfit(x, y, modelfun, beta0, opts);
SSresidual=sum(R.^2);
SStotal =sum((y-mean(y)).^2);
rsquare =1-(SSresidual/SStotal);

Subject: multiple variable exponential regression

From: Tom Lane

Date: 6 Nov, 2013 17:30:21

Message: 2 of 2

> I was using other nonlinear regression methods but was getting an
> imaginary solution (a+ib) form
...
> modelfun = @(b, x)((100 - 15*(x(2, :).^b(1)))) - (40*((x(3, :).^b(2)))) -
> (15*((x(4, :).^b(3)))) x = TestData;
> y = x(1, :);
>
> [beta, R, J, CovB, MSE] = nlinfit(x, y, modelfun, beta0, opts);

One thing I see here is that you have not removed the y column from x, so
x(1,:) will refer to the same thing as y. In general, if you have any
negative x values this could yield imaginary results as the nlinfit function
manipulates the b values. You could use abs() in your modelfun to avoid
that, but I don't know if that makes sense in your application.

-- Tom

Tags for 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