【发布时间】:2017-07-22 11:52:54
【问题描述】:
library(splines)
set.seed(3)
x <- rnorm(100)
plot(x)
lines(ns(x))
这很好用,但如果我尝试添加特定的结,即
lines(ns(x, knots = c(1, 2, 3, 50)))
运行上面的代码给我以下错误:
Error in qr.default(t(const)) :
NA/NaN/Inf in foreign function call (arg 1)
编辑:
按照 Peter 的建议,50 的结太大了,所以我将代码修改为:
> lines(ns(x, knots = sort(x, decreasing = TRUE)[1:10]))
Error in qr.default(t(const)) :
NA/NaN/Inf in foreign function call (arg 1)
现在我想在x 的 10 个最高值处放置 10 个结。但是我仍然遇到错误?这是为什么呢?
【问题讨论】: