predict.smooth.spline(stats)
predict.smooth.spline()所属R语言包:stats
Predict from Smoothing Spline Fit
从平滑样条拟合预测
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Predict a smoothing spline fit at new points, return the derivative if desired. The predicted fit is linear beyond the original data.
预测平滑样条拟合一个新的点,如果需要的话,返回的衍生。预测的拟合线性超越了原来的数据。
用法----------Usage----------
## S3 method for class 'smooth.spline'
predict(object, x, deriv = 0, ...)
参数----------Arguments----------
参数:object
a fit from smooth.spline.
从smooth.spline适合。
参数:x
the new values of x.
x的新值。
参数:deriv
integer; the order of the derivative required.
整数;所需的衍生工具的顺序。
参数:...
further arguments passed to or from other methods.
通过进一步的论据或其他方法。
值----------Value----------
A list with components
与组件列表
参数:x
The input x.
输入x。
参数:y
The fitted values or derivatives at x.
拟合值或衍生工具在x。
参见----------See Also----------
smooth.spline
smooth.spline
举例----------Examples----------
require(graphics)
attach(cars)
cars.spl <- smooth.spline(speed, dist, df=6.4)
## "Proof" that the derivatives are okay, by comparing with approximation[#“证明”,衍生工具都还好,用近似比较]
diff.quot <- function(x,y) {
## Difference quotient (central differences where available)[#差商(中央分歧的地方可用)]
n <- length(x); i1 <- 1:2; i2 <- (n-1):n
c(diff(y[i1]) / diff(x[i1]), (y[-i1] - y[-i2]) / (x[-i1] - x[-i2]),
diff(y[i2]) / diff(x[i2]))
}
xx <- unique(sort(c(seq(0,30, by = .2), kn <- unique(speed))))
i.kn <- match(kn, xx)# indices of knots within xx[指数在XX节]
op <- par(mfrow = c(2,2))
plot(speed, dist, xlim = range(xx), main = "Smooth.spline & derivatives")
lines(pp <- predict(cars.spl, xx), col = "red")
points(kn, pp$y[i.kn], pch = 3, col="dark red")
mtext("s(x)", col = "red")
for(d in 1:3){
n <- length(pp$x)
plot(pp$x, diff.quot(pp$x,pp$y), type = 'l', xlab="x", ylab="",
col = "blue", col.main = "red",
main= paste("s",paste(rep("'",d), collapse=""),"(x)", sep=""))
mtext("Difference quotient approx.(last)", col = "blue")
lines(pp <- predict(cars.spl, xx, deriv = d), col = "red")
points(kn, pp$y[i.kn], pch = 3, col="dark red")
abline(h=0, lty = 3, col = "gray")
}
detach(); par(op)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|