ndCurveMaster

4D Curve Fitting: From Polynomial to Optimized Nonlinear Model

In the previous example, we fitted a curve f(x) to data. In this example, we fit a function of three input variables, that is, f(x1, x2, x3), using a polynomial model and then improve it with an optimized nonlinear model.

In other words, we build a 4D curve fitting model with three inputs and one output. This is an example of multivariable curve fitting and multivariable nonlinear regression.

After launching ndCurveMaster, load the file CurveFitting4D.txt, which you can download here: CurveFitting4D.txt.

Next, apply the following settings:

Initial settings for 4D curve fitting in ndCurveMaster

After loading the data, a basic linear model with three independent variables x1, x2, and x3 is obtained:

Basic linear regression model with three input variables

Next, click the Load button located above the model list in the upper-left panel of the program:

Load button in ndCurveMaster

Load the polynomial model poly333.mf5:

Loading the poly333 function set

This is a third-degree polynomial model. More information about this function and available model sets can be found here: https://www.ndcurvemaster.com/help-882/functions.html

After selecting this model, confirm the selection:

Confirmation of the polynomial model selection

As a result, the following third-degree polynomial function is obtained:

Third-degree polynomial model for 4D curve fitting

The function fits the data reasonably well; however, some predictors are not statistically significant.

We will now perform a more thorough search to obtain a more accurate model. Before starting the search, apply the following settings:

Advanced search settings before nonlinear model optimization

Enabling the Random search using only basic forms option ensures that only basic functional forms are explored during the random search phase. In the second, iterative phase, more detailed functions are identified. This approach allows the algorithm to first find general solutions and then refine them, which can improve efficiency.

Set the duration of the first search phase to 1 minute and 15 seconds.

Then click Advanced Search to start the search process.

As shown, at least seven general models were discovered in the first search phase:

General models discovered during the first search phase

These models are shown below:

General multivariable models identified by the search algorithm

The remaining models are more detailed. The most accurate one is model id: 10:

Best optimized nonlinear model for 4D curve fitting

For comparison, model id: 2 (a third-degree polynomial) has the following form:

Y = a0 + a1 · x1 + a2 · x2 + a3 · x3 + a4 · x1 · x2 + a5 · x1 · x3 + a6 · x2 · x3 + a7 · x1 · x2 · x3 + a8 · x1^2 + a9 · x2^2 + a10 · x3^2 + a11 · x1^3 + a12 · x2^3 + a13 · x3^3 + a14 · x1^2 · x2 + a15 · x1 · x2^2 + a16 · x1^2 · x3 + a17 · x1 · x3^2 + a18 · x2 · x3^2 + a19 · x2^2 · x3 + a20 · x1^2 · x2 · x3 + a21 · x1 · x2^2 · x3 + a22 · x1 · x2 · x3^2

For this model, RMSE = 1.97575.

In contrast, the optimized model id: 10 achieves RMSE = 0.00100917.

Interestingly, the statistical significance of all predictors has also improved.

The final form of model id: 10 is:

Y = a0 + a1 · x1^3 + a2 · x2^(2.4) + a3 · x3^3 + a4 · x1^(2.65) · x2^(-2.6) + a5 · x1^(1.95) · x3^-2 + a6 · x2^(1/2) · x3^(0.8) + a7 · x1^(-2.6) · x2^(3/2) · x3^(-2.6) + a8 · x1^(-3/4) + a9 · x2^(0.05) + a10 · x3^(1.85) + a11 · x1^(1.2) + a12 · x2^(0.9) + a13 · x3^(-0.4) + a14 · x1^(-0.8) · x2^(-1.6) + a15 · x1^(1.85) · x2^(-3/4) + a16 · x1 · x3^(-1/3) + a17 · x1^(1/4) · x3^(1.8) + a18 · x2^(-3/4) · x3^(0.65) + a19 · x2^(-0.7) · x3^(-0.6) + a20 · x1^(2.4) · x2^(-2.4) · x3^(2/3) + a21 · x1^(1/4) · x2^(-1/3) · x3^(-0.8) + a22 · x1^(-2/3) · x2^(0.4) · x3^(-1/2)

As shown, ndCurveMaster effectively optimized the exponents of the predictors from model id: 2. This example demonstrates that multivariable nonlinear curve fitting can substantially improve model accuracy compared with a standard polynomial model.

Project file

You can download the ndCurveMaster project file for this example here:

CurveFitting4D.ndc

Frequently Asked Questions

What is 4D curve fitting?

In this example, 4D curve fitting means fitting a model with three input variables and one output variable, that is, a function of the form f(x1, x2, x3).

What is the difference between a polynomial model and an optimized nonlinear model?

A polynomial model uses predefined polynomial terms, while an optimized nonlinear model can adjust functional forms and exponents to describe the data more accurately.

Can ndCurveMaster fit functions with multiple input variables?

Yes. ndCurveMaster can fit multivariable nonlinear models with multiple predictors and can automatically search for improved model structures.

Why was the optimized model better in this example?

The optimized model achieved a much lower RMSE and improved the statistical significance of the predictors, showing that it captured the relationships in the data more effectively than the third-degree polynomial.