从ns对象中提取结
library(splines) x <- runif(100000)
spline <- ns(x, df=5)
如何判断这个脊柱对象中的结是哪里?从ns对象中提取结
> spline ['knots'] [1] NA
str
让我接近我需要什么,但我希望能够提取样条的矢量,格式化和Sweave文档中打印出来。
> str(sp) ns [1:117542, 1:5] 0.527 0.474 0.455 0.472 0.498 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:5] "1" "2" "3" "4" ...
- attr(*, "degree")= num 3
- attr(*, "knots")= Named num [1:4] 1.03 1.55 1.99 2.7
..- attr(*, "names")= chr [1:4] "20%" "40%" "60%" "80%"
- attr(*, "Boundary.knots")= num [1:2] 0.0214 4.9999
- attr(*, "intercept")= logi FALSE
- attr(*, "class")= chr [1:3] "ns" "basis" "matrix"
回答:
那么,这样的事情绝对可以提取的东西:
> attr(spline, "knots") 20% 40% 60% 80%
0.1966951 0.3973261 0.5982386 0.7993613
以上是 从ns对象中提取结 的全部内容, 来源链接: utcz.com/qa/266862.html