简体   繁体   中英

Non linear regression using R

I am new to R and I am trying to build a nonlinear correlation in the format below. I have tried a script in R but It is not working and return an error message " singular gradient matrix at initial parameter estimates". Can Someone please help me with the right script to enter in R in order to estimate the updated correlation Coefficients based on new data set?. The data set is made of 3 variables Z,X and Y. I would like to Estimate Z=f(x,y). Thank You

Equation to Fit

z=a+bx+cy+dx^2+ey^2+fxy+gx^3+hy^3+ixy^2+jx^2y  

a   0.065119008
b   -0.002506607
c   0.004586821
d   3.73635E-05
e   8.41116E-07
f   -1.7902E-05
g   -1.28967E-07
h   -1.04123E-10
i   -2.40641E-09
j   4.42138E-08

X   |       Y   |       Z
_______ |       _______ |       _______
60  |       100 |       0.41994
60  |       200 |       0.79807
60  |       300 |       1.18778
60  |       400 |       1.58945
60  |       500 |       2.00336
60  |       600 |       2.42971
60  |       700 |       2.86858
60  |       800 |       3.31989
60  |       900 |       3.78335
60  |       1000    |       4.25842
60  |       1100    |       4.74429
60  |       1200    |       5.23983
60  |       1300    |       5.74359
60  |       1400    |       6.25381
60  |       1500    |       6.76844
60  |       1600    |       7.28523
60  |       1700    |       7.80179
60  |       1800    |       8.31574
60  |       1900    |       8.82475
60  |       2000    |       9.32668
80  |       100 |       0.40357
80  |       200 |       0.76552
80  |       300 |       1.13711
80  |       400 |       1.5185
80  |       500 |       1.90979
80  |       600 |       2.311
80  |       700 |       2.72205
80  |       800 |       3.14274
80  |       900 |       3.57269
80  |       1000    |       4.01141
80  |       1100    |       4.45817
80  |       1200    |       4.91207
80  |       1300    |       5.37202
80  |       1400    |       5.83674
80  |       1500    |       6.30477
80  |       1600    |       6.77453
80  |       1700    |       7.24438
80  |       1800    |       7.71262
80  |       1900    |       8.17761
80  |       2000    |       8.63777
100 |       100 |       0.38847
100 |       200 |       0.73573
100 |       300 |       1.09104
100 |       400 |       1.45447
100 |       500 |       1.82598
100 |       600 |       2.20551
100 |       700 |       2.59287
100 |       800 |       2.9878
100 |       900 |       3.38993
100 |       1000    |       3.79877
100 |       1100    |       4.21372
100 |       1200    |       4.63401
100 |       1300    |       5.0588
100 |       1400    |       5.48709
100 |       1500    |       5.91781
100 |       1600    |       6.3498
100 |       1700    |       6.78184
100 |       1800    |       7.21271
100 |       1900    |       7.64119
100 |       2000    |       8.06612
120 |       100 |       0.37451
120 |       200 |       0.70832
120 |       300 |       1.04892
120 |       400 |       1.39627
120 |       500 |       1.7503
120 |       600 |       2.11085
120 |       700 |       2.47771
120 |       800 |       2.85059
120 |       900 |       3.22913
120 |       1000    |       3.61287
120 |       1100    |       4.00129
120 |       1200    |       4.39376
120 |       1300    |       4.78958
120 |       1400    |       5.18797
120 |       1500    |       5.58809
120 |       1600    |       5.98905
120 |       1700    |       6.38994
120 |       1800    |       6.78981
120 |       1900    |       7.18777
120 |       2000    |       7.58291
140 |       100 |       0.36155
140 |       200 |       0.683
140 |       300 |       1.01021
140 |       400 |       1.34307
140 |       500 |       1.68148
140 |       600 |       2.02523
140 |       700 |       2.37411
140 |       800 |       2.72783
140 |       900 |       3.08602
140 |       1000    |       3.4483
140 |       1100    |       3.81418
140 |       1200    |       4.18314
140 |       1300    |       4.55459
140 |       1400    |       4.9279
140 |       1500    |       5.3024
140 |       1600    |       5.67739
140 |       1700    |       6.05216
140 |       1800    |       6.42596
140 |       1900    |       6.7981
140 |       2000    |       7.16787
160 |       100 |       0.34948
160 |       200 |       0.65953
160 |       300 |       0.97447
160 |       400 |       1.29419
160 |       500 |       1.61852
160 |       600 |       1.94728
160 |       700 |       2.28022
160 |       800 |       2.61706
160 |       900 |       2.95748
160 |       1000    |       3.3011
160 |       1100    |       3.64752
160 |       1200    |       3.99628
160 |       1300    |       4.34688
160 |       1400    |       4.6988
160 |       1500    |       5.05149
160 |       1600    |       5.40438
160 |       1700    |       5.7569
160 |       1800    |       6.10847
160 |       1900    |       6.4585
160 |       2000    |       6.80647
180 |       100 |       0.33822
180 |       200 |       0.6377
180 |       300 |       0.94137
180 |       400 |       1.24907
180 |       500 |       1.56064
180 |       600 |       1.87588
180 |       700 |       2.19455
180 |       800 |       2.51639
180 |       900 |       2.84109
180 |       1000    |       3.16833
180 |       1100    |       3.49772
180 |       1200    |       3.82888
180 |       1300    |       4.16138
180 |       1400    |       4.49478
180 |       1500    |       4.82863
180 |       1600    |       5.16245
180 |       1700    |       5.49577
180 |       1800    |       5.82812
180 |       1900    |       6.15903
180 |       2000    |       6.48806
200 |       100 |       0.32767
200 |       200 |       0.61734
200 |       300 |       0.91058
200 |       400 |       1.20725
200 |       500 |       1.50717
200 |       600 |       1.81015
200 |       700 |       2.11596
200 |       800 |       2.42434
200 |       900 |       2.73502
200 |       1000    |       3.04768
200 |       1100    |       3.36202
200 |       1200    |       3.67767
200 |       1300    |       3.99427
200 |       1400    |       4.31145
200 |       1500    |       4.62882
200 |       1600    |       4.94597
200 |       1700    |       5.26253
200 |       1800    |       5.57809
200 |       1900    |       5.89227
200 |       2000    |       6.2047

I'm not entirely sure what it is you would like to do, or why google was unsatisfactory, but maybe something along these lines will give you an idea:

x <- rep(c(60,80,100,160,200), each = 10)
y <- c(seq(from = 100, to = 2000, length.out = 25),seq(1800, 200, length.out = 25))
z <- rnorm(50, 6)
df <- data.frame(x,y,z)
mod <- lm(z ~ 1 + x + y + I(x^2) + I(y^2) + I(x*y) + I(x^3) + I(y^3) + I(x*y^2) + I(x*y^3), data =df)
summary(mod)
summary(mod)$adj

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM