为什么ns(0.8)
或ns(c(0.8))
返回NA/NaN/Inf in foreign function call (arg 1)
?为什么ns(0.8)或ns(c(0.8))`在外部函数调用(arg 1)`中返回NA/NaN/Inf?
ns(c(0.8, 1.0))
工作正常,但我想知道为什么只给1个值ns
导致NA/NaN/Inf in foreign function call (arg 1)
。
例子:
> library(splines)
> ns(0.8)
Error in qr.default(t(const)) :
NA/NaN/Inf in foreign function call (arg 1)
> ns(c(0.8, 1.0))
1
[1,] 0.0000000
[2,] 0.8017837
attr(,"degree")
[1] 3
attr(,"knots")
numeric(0)
attr(,"Boundary.knots")
[1] 0.8 1.0
attr(,"intercept")
[1] FALSE
attr(,"class")
[1] "ns" "basis" "matrix"
你能解释一下你认为如何将样条曲线拟合成一个点_应该工作吗? ns()'依赖于第一个参数,因为它可以用来确定结的位置(包括边界结)。只有一个数据点,没有足够的信息来进行明智的选择,并且该方法失败是有意义的。 – stephematician
@stephematician听起来像是一个更好的错误消息 –