当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


R predict.bSpline 在 x 的新值处评估样条线


R语言 predict.bSpline 位于 splines 包(package)。

说明

从虚拟类 bSplinepolySpline 继承的类的 predict 方法用于评估样条线或其导数。样条线对象的 plot 方法首先在缺少 x 参数的情况下计算 predict ,然后用 type = "l" 绘制生成的 xyVector

用法

## S3 method for class 'bSpline'
predict(object, x, nseg = 50, deriv = 0, ...)
## S3 method for class 'nbSpline'
predict(object, x, nseg = 50, deriv = 0, ...)
## S3 method for class 'pbSpline'
predict(object, x, nseg = 50, deriv = 0, ...)
## S3 method for class 'npolySpline'
predict(object, x, nseg = 50, deriv = 0, ...)
## S3 method for class 'ppolySpline'
predict(object, x, nseg = 50, deriv = 0, ...)

参数

object

bSplinepolySpline 类继承的对象。

x

用于评估样条线的 x 值的数值向量。如果缺少此参数,则会生成一组合适的 x 值,作为跨越结范围的 nseq 段序列。

nseg

一个正整数,给出跨越 object 中的结范围的一组等距 x 值中的段数。仅当 x 缺失时才使用该值。

deriv

0 到 splineOrder(object) - 1 之间的整数,指定要计算的导数。

...

传入或传出其他方法的进一步参数。

带有组件的xyVector

x

提供或推断的 x 值的数值向量

y

x 向量处的样条线值(或其 deriv 阶导数)

例子

require(graphics); require(stats)
ispl <- interpSpline( weight ~ height,  women )
opar <- par(mfrow = c(2, 2), las = 1)
plot(predict(ispl, nseg = 201),     # plots over the range of the knots
     main = "Original data with interpolating spline", type = "l",
     xlab = "height", ylab = "weight")
points(women$height, women$weight, col = 4)
plot(predict(ispl, nseg = 201, deriv = 1),
     main = "First derivative of interpolating spline", type = "l",
     xlab = "height", ylab = "weight")
plot(predict(ispl, nseg = 201, deriv = 2),
     main = "Second derivative of interpolating spline", type = "l",
     xlab = "height", ylab = "weight")
plot(predict(ispl, nseg = 401, deriv = 3),
     main = "Third derivative of interpolating spline", type = "l",
     xlab = "height", ylab = "weight")
par(opar)

作者

Douglas Bates and Bill Venables

也可以看看

xyVector , interpSpline , periodicSpline

相关用法


注:本文由纯净天空筛选整理自R-devel大神的英文原创作品 Evaluate a Spline at New Values of x。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。