0
我想了解R函數predict.lm
如何在R中工作。所以,我在控制檯中輸入函數的名稱來查看代碼,將代碼複製到新的腳本和呼叫Pred提供給新的功能:R - `qr.lm`函數在哪裏
pred <- function (object, newdata, se.fit = FALSE, scale = NULL, df = Inf,
interval = c("none", "confidence", "prediction"), level = 0.95,
type = c("response", "terms"), terms = NULL, na.action = na.pass,
pred.var = res.var/weights, weights = 1, ...)
{
<here goes the body of the predict.lm function which
I do not copy to the post so it remains readable>
}
然後我擬合模型來檢查一切正常,並要求使用新功能pred
的預測是predict.lm
功能的副本:
fit <- lm(Sepal.Length ~ Species, data = iris)
new_obs = data.frame(Species = "versicolor")
print(pred(fit, newdata = new_obs, interval = "prediction"))
但後來我得到這個錯誤:
Error in pred(fit, newdata = newobs, interval = "prediction" :
could not fund function "qr.lm"
我已經搜索了功能qr.lm
,但是我找不到它。我只找到qr
函數。
qr.lm
函數在哪裏?我如何訪問它?
也許感興趣https://stackoverflow.com/questions/19226816/how-can-i-view-the-source-code-for-a-function – user20650