title: Find equations to fit non-linear non-parametric model
body: <p>My goal is to find a correlation between <code>UNBALANCE_2</code>, <code>UNBALANCE_1</code>, <code>ANGLE_1</code>, <code>ANGLE_2</code> and <code>W</code> and make a prediction, so I'm decided to use regression, right now I have a problem to identify correct equations for my model.</p>
  
  <p>What I did I was used <code>nls</code>, but still no results </p>
  
  <pre><code>model_nls &lt;- nls(W ~ b1*UNBALANCE_2^2+b2*UNBALANCE_1+b3*ANGLE_1+b4*ANGLE_2,start = list(b1 = 17,b2 = 7, b3 = 0, b4 = 0), data = sub12)
  summary(model_nls)
  
  Formula: W ~ b1 * UNBALANCE_2^2 + b2 * UNBALANCE_1 + b3 * ANGLE_1 + b4 * 
      ANGLE_2
  
  Parameters:
      Estimate Std. Error t value Pr(&gt;|t|)    
  b1 1.751e+01  7.198e-01   24.33   &lt;2e-16 ***
  b2 6.887e+00  1.336e-01   51.54   &lt;2e-16 ***
  b3 2.387e-03  6.295e-05   37.92   &lt;2e-16 ***
  b4 2.384e-03  6.405e-05   37.22   &lt;2e-16 ***
  ---
  Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
  
  Residual standard error: 0.7923 on 11264 degrees of freedom
  
  Number of iterations to convergence: 1 
  Achieved convergence tolerance: 1.048e-09
  </code></pre>
  
  <pre><code>summary(sub12)
    UNBALANCE_1         ANGLE_1        UNBALANCE_2        ANGLE_2             W      
   Min.   :0.00100   Min.   :  0.00   Min.   :0.0010   Min.   :  0.00   Min.   :1.0  
   1st Qu.:0.06400   1st Qu.: 85.97   1st Qu.:0.0700   1st Qu.: 87.38   1st Qu.:2.0  
   Median :0.09900   Median :169.60   Median :0.1060   Median :171.70   Median :2.0  
   Mean   :0.09966   Mean   :175.40   Mean   :0.1057   Mean   :176.00   Mean   :1.9  
   3rd Qu.:0.13600   3rd Qu.:266.70   3rd Qu.:0.1430   3rd Qu.:264.00   3rd Qu.:2.0  
   Max.   :0.19500   Max.   :360.00   Max.   :0.1950   Max.   :360.00   Max.   :6.0
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/OlV2I.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OlV2I.png" alt="enter image description here"></a>
  Next used simple <code>gam</code> model</p>
  
  <pre><code>model &lt;- gam(W ~  s(UNBALANCE_2) + s(ANGLE_1) + s(UNBALANCE_1) + s(ANGLE_2), data = sub12, family = quasipoisson)
  summary(model)
  
  Call: gam(formula = W ~ s(UNBALANCE_2) + s(ANGLE_1) + s(UNBALANCE_1) + 
      s(ANGLE_2), family = quasipoisson, data = sub12)
  Deviance Residuals:
       Min       1Q   Median       3Q      Max 
  -0.77207  0.04447  0.06886  0.08413  2.39954 
  
  (Dispersion Parameter for quasipoisson family taken to be 0.1908)
  
      Null Deviance: 1989.01 on 11267 degrees of freedom
  Residual Deviance: 1983.803 on 11251 degrees of freedom
  AIC: NA 
  
  Number of Local Scoring Iterations: 5 
  
  Anova for Parametric Effects
                    Df  Sum Sq Mean Sq F value  Pr(&gt;F)  
  s(UNBALANCE_2)     1    0.33 0.32869  1.7230 0.18933  
  s(ANGLE_1)         1    0.01 0.00592  0.0310 0.86020  
  s(UNBALANCE_1)     1    0.72 0.71901  3.7691 0.05223 .
  s(ANGLE_2)         1    0.00 0.00419  0.0220 0.88222  
  Residuals      11251 2146.28 0.19076                  
  ---
  Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
  
  Anova for Nonparametric Effects
                 Npar Df  Npar F   Pr(F)  
  (Intercept)                             
  s(UNBALANCE_2)       3 1.62467 0.18132  
  s(ANGLE_1)           3 2.20440 0.08536 .
  s(UNBALANCE_1)       3 2.46577 0.06032 .
  s(ANGLE_2)           3 0.99663 0.39323  
  ---
  Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
  
  sigma(model)/mean(x12$W)
  [1] 0.2230563
  </code></pre>
  
  <pre><code>plot((glm(W ~ UNBALANCE_1 + ANGLE_1 + UNBALANCE_2 + ANGLE_2, data = x13, family = poisson)))
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/t7sA9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/t7sA9.png" alt="enter image description here"></a></p>
  
  <p>Please help to figure out:  </p>
  
  <ol>
  <li><p>Sure should I use <code>sin</code> function in my model ? </p></li>
  <li><p>Does it possible to make a valuable prediction, when <code>p</code> value indicates very weak correlation between parameters? </p></li>
  <li><p>As for 3 model residuals are very high indicates that model qualitatively wrong? what should I do ? </p></li>
  </ol>
  
  <p>Thank you for your help. </p>