[問題] 測試資料太乾淨反而找不出解?

作者: LIAR (玻璃做的大叔)   2018-08-12 22:43:19
我最近有一堆壓力的資料要分析,因為推測模式是 y ~ a/(x+b),所以想用nls解。
我先用假的資料
> x=seq(-4,-1.5,0.1)
> y=-1.58/(x-3.78)
> plot(x,y)
> m<-nls(y~a/(x+b))
Error in nls(y ~ a/(x + b)) : number of iterations exceeded maximum of 50
In addition: Warning message:
In nls(y ~ a/(x + b)) : No starting values specified for some parameters.
Initializing ‘a’, ‘b’ to '1.'.
Consider specifying 'start' or using a selfStart model
這樣會有錯誤。
但是如果我把y加上一些noise
> y=-1.58/(x-3.78)+rnorm(length(x),0,0.01)
> m<-nls(y~a/(x+b))
Warning message:
In nls(y ~ a/(x + b)) : No starting values specified for some parameters.
Initializing ‘a’, ‘b’ to '1.'.
Consider specifying 'start' or using a selfStart model
> m
Nonlinear regression model
model: y ~ a/(x + b)
data: parent.frame()
a b
-1.698 -4.339
residual sum-of-squares: 0.001832
Number of iterations to convergence: 9
Achieved convergence tolerance: 3.167e-06
>
這樣就可以解出a,b(理論值是-1.58,-3.78)
我想請問為何太乾淨的資料反而會跑不出來?
不加rnorm的y我甚至有試過直接帶入正確答案當起始值:
start = list(a=-1.58,b=-3.78),但是還是一樣有
number of iterations exceeded maximum of 50
請問測試資料太乾淨反而抓不出模型是正常的嗎?
作者: x88776544pc   2018-08-12 23:10:00
這點在 nls 的說明中 warning這塊有說, 與其方法有關
作者: LIAR (玻璃做的大叔)   2018-08-13 23:17:00
看到了,雖然看不懂XD,eps是甚麼啊?residual sum-of-squares在不同參數下應該會變化吧?為何這樣還是需要noise這點我不懂。
作者: andrew43 (討厭有好心推文後刪文者)   2018-08-14 00:24:00
牛頓法的過程需要超過一個方程式,但若只要單一個方程式就可以完美解釋所有資料,也就不存在另一個不同的方程式
作者: bmka (偶素米蟲)   2018-08-15 13:08:00
沒搞清楚什麼是statistical model

Links booklink

Contact Us: admin [ a t ] ucptt.com