The Best Nonlinear Regression Model of My Data

by M. Shalahuddin Yahya Sunarko   Last Updated April 16, 2018 07:19 AM

I have a set of data of my final year project, here is my data:

v   v_sd    E   t   Rc  Pc  H   MB
0.00    0.00    173.00  22.2    0.6053  1   3.841   0.00
0.00    0.00    166.00  10.5    0.7484  1   1.743   0.00
0.00    0.00    158.00  5.6 0.495   1   0.885   0.00
0.00    0.00    176.00  2.7 0.0491  1   0.475   0.00
0.00    0.00    170.33  1.3 0   1   0.221   0.00
0.00    0.00    165.00  0.7 0   1   0.116   0.00
0.00    0.00    310.00  22.2    0   1   6.882   0.00
0.00    0.00    302.33  10.5    0.6173  1   3.174   0.00
0.00    0.00    294.00  5.6 0.7605  1   1.646   0.00
0.00    0.00    287.00  2.7 0.3927  1   0.775   0.00
0.00    0.00    280.00  1.3 0   1   0.364   0.00
0.00    0.00    274.00  0.7 0   1   0.192   0.00
0.00    0.00    414.33  22.2    0   1   9.198   0.00
0.00    0.00    401.67  10.5    0.4791  1   4.218   0.00
0.00    0.00    400.00  5.6 0.655   1   2.240   0.00
0.00    0.00    399.00  2.7 0.6041  1   1.077   0.00
0.00    0.00    389.00  1.3 0.1283  1   0.506   0.00
0.00    0.00    381.33  0.7 0   1   0.267   0.00
0.00    0.00    562.00  22.2    0   1   12.476  0.00
0.00    0.00    550.33  10.5    0.0464  1   5.778   0.00
0.00    0.00    547.00  5.6 0.6045  1   3.063   0.00
0.00    0.00    539.33  2.7 0.7214  1   1.456   0.00
0.00    0.00    535.00  1.3 0.2418  1   0.696   0.00
0.00    0.00    519.00  0.7 0   1   0.363   0.00
0.00    0.00    151.33  22.2    0.6077  1   3.360   0.00
0.00    0.00    154.00  10.5    0.7386  1   1.617   0.00
0.00    0.00    157.00  5.6 0.4945  1   0.879   0.00
0.00    0.00    159.33  2.7 0.0141  1   0.430   0.00
0.00    0.00    165.67  1.3 0   1   0.215   0.00
0.00    0.00    173.00  0.7 0   1   0.121   0.00
0.00    0.00    260.00  22.2    0.0482  1   5.772   0.00
0.00    0.00    265.33  10.5    0.6259  1   2.786   0.00
0.00    0.00    270.00  5.6 0.7268  1   1.512   0.00
0.00    0.00    277.00  2.7 0.4095  1   0.748   0.00
0.00    0.00    287.00  1.3 0   1   0.373   0.00
0.00    0.00    291.67  0.7 0   1   0.204   0.00
0.00    0.00    388.00  22.2    0   1   8.614   0.00
0.00    0.00    396.33  10.5    0.5059  1   4.161   0.00
0.00    0.00    402.33  5.6 0.65    1   2.253   0.00
0.00    0.00    407.33  2.7 0.6064  1   1.100   0.00
0.00    0.00    427.67  1.3 0.0791  1   0.556   0.00
0.00    0.00    429.33  0.7 0   1   0.301   0.00
0.00    0.00    540.33  22.2    0   1   11.995  0.00
0.00    0.00    558.67  10.5    0.0414  1   5.866   0.00
0.00    0.00    567.00  5.6 0.6068  1   3.175   0.00
0.00    0.00    579.67  2.7 0.7427  1   1.565   0.00
0.00    0.00    589.33  1.3 0.3841  1   0.766   0.00
0.00    0.00    601.00  0.7 0.01    1   0.421   0.00
0.00    0.00    147.33  22.2    0.5964  1   3.271   0.00
0.00    0.00    153.00  10.5    0.7536  1   1.607   0.00
0.00    0.00    169.67  5.6 0.5736  1   0.950   0.00
0.00    0.00    167.33  2.7 0.0773  1   0.452   0.00
0.00    0.00    153.67  1.3 0   1   0.200   0.00
0.00    0.00    154.67  0.7 0   1   0.108   0.00
0.00    0.00    267.67  22.2    0.0432  1   5.942   0.00
0.00    0.00    268.33  10.5    0.6127  1   2.817   0.00
0.00    0.00    275.00  5.6 0.7382  1   1.540   0.00
0.00    0.00    277.67  2.7 0.3836  1   0.750   0.00
0.00    0.00    276.67  1.3 0   1   0.360   0.00
0.00    0.00    285.00  0.7 0   1   0.200   0.00
0.00    0.00    376.33  22.2    0   1   8.355   0.00
0.00    0.00    380.33  10.5    0.5045  1   3.993   0.00
0.00    0.00    398.67  5.6 0.6486  1   2.233   0.00
0.00    0.00    401.00  2.7 0.6109  1   1.083   0.00
0.00    0.00    401.00  1.3 0.0891  1   0.521   0.00
0.00    0.00    417.33  0.7 0   1   0.292   0.00
0.00    0.00    556.67  22.2    0   1   12.358  0.00
0.00    0.00    564.67  10.5    0.0359  1   5.929   0.00
0.00    0.00    587.00  5.6 0.6114  1   3.287   0.00
0.00    0.00    587.67  2.7 0.7364  1   1.587   0.00
0.00    0.00    609.00  1.3 0.4427  1   0.792   0.00
0.00    0.00    633.33  0.7 0.0145  1   0.443   0.00

I want to get the nonlinear regression fit of Rc ~ H using nls() in R at range of H >= 1 and H <= 3.5. The first thing I have already done is filtering my data using:

mydata <- subset(mydata, H>=1 & H<=3.5)

Plotted <code>H</code> at x-axis and <code>Rc</code> at y-axis

As you can see in picture above, my data looks like Gamma PDF curve, so I use it's equation as the formula and replaced the Gamma function from the Gamma PDF Equation with A (as someone suggests). I got the starting value from just guessing.

fit <-nls(Rc ~ (beta^alpha)*((H - mu)^(alpha-1))*(exp(-beta*(H - mu))) / A + k,
      mydata, start = c(alpha = 3, beta = 3, k = 0.6, A = 1, mu = 1))

(I think it is really bad I used k variable, because the Rc in the full data can be goes to zero.)

Plotted the regression line of the code above

The fitted line shape result using nls() with Gamma-PDF-equation-like does not looks like what I want. What I want is looks like picture below (red line):

What I want

The important thing of the fitted curve should be like what I green-circled in picture above. Maybe someone could suggest me the best model/equation/formula (with the good starting value for nls())?

Note: Rc is NOT a probability value.



Answers 1


If you want a regression to zero at each extremity of the curve, you may want to try Gaussian Process Regression (aka. Kriging) with 0-mean.

When extrapolating, Gaussian Process Regressors return quickly to their mean (whether fixed as here, or estimated): as the predicted point is further from data point, the kernel value is lower.

Pop
Pop
April 16, 2018 06:46 AM

Related Questions






How to choose between linear or nonlinear mixed model?

Updated December 25, 2016 08:08 AM