我試圖使用speedlm
(speedglm package)的更新選項,因爲我沒有足夠的RAM一次計算整個模型,而biglm
只使用一個CPU。
下面的代碼是出錯的可重現示例。Speedlm更新「需要呼叫組件的對象」
library(speedglm)
formula <- Sepal.Length ~ Sepal.Width
chunk1 <- iris[1:10,]
chunk2 <- iris[11:20,]
chunk3 <- iris[21:30,]
lmfit <- speedlm(formula, chunk1)
lmfit <- update(lmfit, chunk2)
lmfit <- update(lmfit, chunk3)
,我發現了以下錯誤:
> lmfit <- speedlm(formula, chunk1)
> lmfit <- update(lmfit, chunk2)
> lmfit <- update(lmfit, chunk3)
Error in update.default(lmfit, chunk3) :
need an object with call component
>
如果是由於有update
代替updateWithMoreData
我已經期待着與chunk2更新後的錯誤。
想知道解決這個問題的方法,或者如果我必須使用替代方法。
在此先感謝!
使用updateWithMoreData
得到以下錯誤:
> lmfit <- speedlm(formula, chunk1)
> lmfit <- updateWithMoreData(lmfit, chunk2)
Error: object of type 'symbol' is not subsettable
> lmfit <- updateWithMoreData(lmfit, chunk3)
Error: object of type 'symbol' is not subsettable
>
下面的代碼工作,道具@LyzandeR
> library(speedglm)
> chunk1 <- iris[1:10,]
> chunk2 <- iris[11:20,]
> chunk3 <- iris[21:30,]
> lmfit <- speedlm(Sepal.Length ~ Sepal.Width, chunk1)
>
> for (i in list(11,20, 21:30)){
+ lmfit2 <- updateWithMoreData(lmfit, iris[i,])
+ }
> lmfit2
Linear Regression Model of class 'speedlm':
Call: speedlm(formula = Sepal.Length ~ Sepal.Width, data = chunk1)
Coefficients:
(Intercept) Sepal.Width
2.9876 0.5813
>
也許你想'updateWithMoreData'?根據文檔,'update.speedlm'需要一個公式作爲第二個參數。 – Roland
@Roland謝謝,我完全錯過了文檔中的那個。但它不能解決問題。更新我的問題 – Bas