how to fit a curve in the form of A = (L^x)(D^y)

조회 수: 1 (최근 30일)
Roule
Roule 2016년 2월 22일
댓글: Jos (10584) 2016년 2월 23일
hi, i have some response data as vector A where the variables are L and D.
I just want to find the coefficients for L and D which will fit my data in the form mentioned in the title.
I want to fit a curved line, and not a surface.
I feel it should be fairly simple, but reading a few old answers also didn't help my case.
Is there some easy way to do this?
In case u want to see the data, here it is:
A = [0 0.06 0.12 0.44 0.56 0.94 1 1 0 0.04 0.58 0.74 0.86 1 1]
L = [100 100 100 100 100 100 100 100 43.7 49.7 56 61.5 65 77 93.8]
D = [11.3 10.1 8.9 8.5 8.1 7.7 6.5 5.3 5 5 5 5 5 5 5]
Thanks a lot.
More info:
I wrote the above equation as logA = xlogL + ylogD, and tried to use
X = [ones(size(logL)) logL logD];
b = regress(logA,X);
but Matlab didn't return any coefficients, it just gave b = NaN NaN NaN
  댓글 수: 4
Jos (10584)
Jos (10584) 2016년 2월 22일
log(A(1)) → -Inf, causing the NaNs
Roule
Roule 2016년 2월 22일
ya, instead of 0 i can use a very small number close to zero, or just ignore that particular data point altogether. in cftool, matlab just ignores that log(0).

댓글을 달려면 로그인하십시오.

채택된 답변

Jos (10584)
Jos (10584) 2016년 2월 22일
nlm = fitnlm([L(:) D(:)], A, 'y~(x1^b1)*(x2^b2)',[0 0])
  댓글 수: 2
Roule
Roule 2016년 2월 22일
편집: Roule 2016년 2월 22일
Hey Jos, thanks so much. Your one line really did the work.
I am using 2013a so I had to just replace 'fitnlm' with 'NonLinearModel.fit'. I guess both will give the same results.
However the result shows very low R-squared: 0.48. Is there any way to improve this. I want to use only L and D may be in some other combination if that gives better R-squared value.
Below is the complete output:
nlm =
Nonlinear regression model: y ~ (x1^b1)*(x2^b2)
Estimated Coefficients:
Estimate SE tStat pValue
b1 0.92059 0.34937 2.635 0.02059
b2 -2.5503 0.90462 -2.8192 0.014488
Number of observations: 15, Error degrees of freedom: 13
Root Mean Squared Error: 0.31
R-Squared: 0.48, Adjusted R-Squared 0.44
F-statistic vs. zero model: 30.2, p-value = 1.31e-05
Jos (10584)
Jos (10584) 2016년 2월 23일
I had the same outcome, so that's good. If you think you can come up with a better model you can fit that as well, of course. By the way, always plot your data, your fit and your residuals (fittedY - Y) to see how your model is doing.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by