查找方程以拟合非线性非参数模型

时间:2019-05-23 14:18:20

标签: r non-linear

我的目标是找到UNBALANCE_2UNBALANCE_1ANGLE_1ANGLE_2W之间的相关性并做出预测,所以我决定使用回归,现在我在确定模型的正确方程式时遇到问题。

我曾经用过nls,但仍然没有结果

model_nls <- 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(>|t|)    
b1 1.751e+01  7.198e-01   24.33   <2e-16 ***
b2 6.887e+00  1.336e-01   51.54   <2e-16 ***
b3 2.387e-03  6.295e-05   37.92   <2e-16 ***
b4 2.384e-03  6.405e-05   37.22   <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
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

enter image description here 接下来使用简单的gam模型

model <- 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(>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
plot((glm(W ~ UNBALANCE_1 + ANGLE_1 + UNBALANCE_2 + ANGLE_2, data = x13, family = poisson)))

enter image description here

请帮助找出:

  1. 我应该在模型中使用sin函数吗?

  2. p值指示参数之间的相关性很弱时,是否可以做出有价值的预测?

  3. 对于3个模型残差非常高,表明该模型在质量上是错误的吗?我该怎么办 ?

感谢您的帮助。

0 个答案:

没有答案