當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。