hatMat(sfsmisc)
hatMat()所属R语言包:sfsmisc
Hat Matrix of a Smoother
帽子矩阵的一个更顺畅
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Compute the hat matrix or smoother matrix, of "any" (linear) smoother, smoothing splines, by default.
计算的帽子矩阵或平滑的矩阵,任何顺畅,平滑样条曲线(直线),默认情况下。
用法----------Usage----------
hatMat(x, trace= FALSE,
pred.sm = function(x, y, ...)
predict(smooth.spline(x, y, ...), x = x)$y,
...)
参数----------Arguments----------
参数:x
numeric vector or matrix.
数值向量或矩阵。
参数:trace
logical indicating if the whole hat matrix, or only its trace, i.e. the sum of the diagonal values should be computed.
应计算逻辑表示,如果整个帽矩阵,或只有它的跟踪,即对角值的总和。
参数:pred.sm
a function of at least two arguments (x,y) which returns fitted values, i.e. y.hat, of length compatible to x (and y).
至少需要两个参数的函数(x,y)返回的拟合值,即y.hat,长度兼容x(y)。
参数:...
optionally further arguments to the smoother function pred.sm.
任选进一步的论据的平滑功能pred.sm。
值----------Value----------
The hat matrix H (if trace = FALSE as per default) or a number, tr(H), the trace of H, i.e., sum(i) H[i,i].
帽子矩阵H(如果trace = FALSE为默认)或数字的,tr(H),H,即sum(i) H[i,i]的痕迹。
Note that dim(H) == c(n, n) where n <- length(x) also in the case where some x values are duplicated (aka ties).
请注意这dim(H) == c(n, n)其中n <- length(x)的情况下,一些x值是重复的(又名关系)。
(作者)----------Author(s)----------
Martin Maechler <a href="mailto:maechler@stat.math.ethz.ch">maechler@stat.math.ethz.ch</a>
参考文献----------References----------
Generalized Additive Models. Chapman \& Hall.
参见----------See Also----------
smooth.spline, etc. Note the demo, demo("hatmat-ex").
smooth.spline,等。注意演示,demo("hatmat-ex")的。
实例----------Examples----------
require(stats) # for smooth.spline() or loess()[为smooth.spline()或黄土()]
x1 <- c(1:4, 7:12)
H1 <- hatMat(x1, spar = 0.5) # default : smooth.spline()[默认:smooth.spline()]
matplot(x1, H1, type = "l", main = "columns of smoother hat matrix")
## Example `pred.sm' arguments for hatMat() :[#例如pred.sm的论点为hatMat():]
pspl <- function(x,y,...) predict(smooth.spline(x,y, ...), x = x)$y
pksm <- function(x,y,...) ksmooth(sort(x),y, "normal", x.points=x, ...)$y
## Rather than ksmooth():[#而不是ksmooth()的:]
if(require("lokern"))
pksm2 <- function(x,y,...) glkerns(x,y, x.out=x, ...)$est
## Explaining 'trace = TRUE'[#解释“跟踪= TRUE]
all.equal(sum(diag((hatMat(c(1:4, 7:12), df = 4)))),
hatMat(c(1:4, 7:12), df = 4, trace = TRUE), tol = 1e-12)
## ksmooth() :[:#ksmooth():]
Hk <- hatMat(x1, pr = pksm, bandwidth = 2)
cat(sprintf("df = %.2f\n", sum(diag(Hk))))
image(Hk)
Matrix::printSpMatrix(as(round(Hk, 2), "sparseMatrix"))
##---> see demo("hatmat-ex") for more (and larger) examples[#--->看到更多的演示(的“hatmat-EX”)(及以上)的例子]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|