formula for nonlinear regression model

Asked by Maura Monville

Maura Monville (view profile)

on 14 Aug 2019
Latest activity Commented on by SYED IMTIAZ ALI SHAH

SYED IMTIAZ ALI SHAH (view profile)

on 14 Aug 2019
Accepted Answer by SYED IMTIAZ ALI SHAH

SYED IMTIAZ ALI SHAH (view profile)

Dear MatLab Experts,
I have four column vectors with 14 elements representing respectively:
Area, Max.Diameter, Min.Diameter, Field Size Factor (FSF) of custom-made collimators.
I believe the FSF depends somehow on the other three quantities. The dependence is not linear.
I woud like to tryto model the FSF as a power law involving products of the other quantities.
For instance, FSF ~a*(Max.Diam*Min.Diam)^b + c*(Area/Max.Diam)^d + e*(Area/Min.Diam)^f + g*(Max.Diam/Min.Diam)^h + i
where a, b,c,d,e,f,g,h,i are the unknown model coefficients.
I am pretty sure most of the terms are useless. Perobably just one is necessary for the model. However, I do not know which one is the most important term. I expect the modeling function will figure that out.
My problem is that I do not know how to write the above formula in the proper format expected by the nonlinear regression functions.
I need some help to set up the above outlined particular model.
Thank you very much in advance.
Best regards,
Maura E. M.

Products

Answer by SYED IMTIAZ ALI SHAH

SYED IMTIAZ ALI SHAH (view profile)

on 14 Aug 2019

Is this what you want?
x = MaxFDiam .* MinFDiam + Area ./ MaxFDiam + Area ./ MinFDiam + MaxFDiam ./ MinFDiam; % your formula
Linear model Poly7:
Your resultant equation with coefficients.
f(x) = p1*x^7 + p2*x^6 + p3*x^5 + p4*x^4 + p5*x^3 +
p6*x^2 + p7*x + p8
Coefficients (with 95% confidence bounds):
p1 = 2.961e-18 (-5.495e-18, 1.142e-17)
p2 = -6.914e-15 (-2.189e-14, 8.064e-15)
p3 = 6.708e-12 (-4.044e-12, 1.746e-11)
p4 = -3.496e-09 (-7.522e-09, 5.297e-10)
p5 = 1.054e-06 (2.132e-07, 1.895e-06)
p6 = -0.0001832 (-0.0002798, -8.656e-05)
p7 = 0.01691 (0.01138, 0.02244)
p8 = 0.3618 (0.2454, 0.4782)
Goodness of fit:
SSE: 5.048e-06
R-square: 0.9998
RMSE: 0.0009173  Show 1 older comment
SYED IMTIAZ ALI SHAH

SYED IMTIAZ ALI SHAH (view profile)

on 14 Aug 2019
I use the Curve Fitting Toolbox which uses the Polyfit function. Means you can use both Polyfit and Curve Fitting Toolbox (It is more convenient).
I just used your equation without any coefficient and power, and let matlab find these automatically for me (without telling matlab).
As I am not a professional statistician, I don't fully understand the error, I used the equation derived from this toolbox in many practical experiments and it gave me best results.
Moreover some of the coefficients look somewhat odd to me also.
Maura Monville

Maura Monville (view profile)

on 14 Aug 2019
Yes. The coefficients are very small. But the fit is close to perfection.
I have sdeveloped a Monte Carlo simulation that reproduces the trend of the experimental measurements but not as accurately as your model.
I tried to fit a much simpler linear model using 'fitlm'. The result was bad although the R^2 was more than 0.9. But some P_values were 'NaN'.
I am going to accept your very good solution. Although I really would like to learn how to play with nonlinear models.
Thank you.
Regards,
maura E. M.
SYED IMTIAZ ALI SHAH

on 14 Aug 2019
You are welcome.