找回密码
 注册
查看: 2060|回复: 0

R语言:runmed()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-16 20:23:58 | 显示全部楼层 |阅读模式
runmed(stats)
runmed()所属R语言包:stats

                                        Running Medians – Robust Scatter Plot Smoothing
                                         运行中位数 - 鲁棒散点图平滑

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Compute running medians of odd span.  This is the "most robust" scatter plot smoothing possible.  For efficiency (and historical reason), you can use one of two different algorithms giving identical results.
计算运行奇数跨度的中位数。这是“最强大的”散点图平滑可能。为了提高效率(历史原因),您可以使用两种不同的算法,给予相同的结果之一。


用法----------Usage----------


runmed(x, k, endrule = c("median", "keep", "constant"),
       algorithm = NULL, print.level = 0)



参数----------Arguments----------

参数:x
numeric vector, the "dependent" variable to be smoothed.
数字向量,依赖变量进行平滑。


参数:k
integer width of median window; must be odd.  Turlach had a default of k <- 1 + 2 * min((n-1)%/% 2, ceiling(0.1*n)). Use k = 3 for "minimal" robust smoothing eliminating isolated outliers.
整数位数窗口宽度;必须是奇数。 turlach了k <- 1 + 2 * min((n-1)%/% 2, ceiling(0.1*n))的默认。使用k = 3最小稳健消除隔离离群的平滑。


参数:endrule
character string indicating how the values at the beginning and the end (of the data) should be treated.     
说明如何在开头和结尾(数据)的值应被视为字符串。

"keep"keeps the first and last k2 values at both ends, where k2 is the half-bandwidth k2 = k %/% 2, i.e., y[j] = x[j] for j = 1, &hellip;, k2 and (n-k2+1), &hellip;, n;  
"keep"保持第一个和最后一个k2两端值,其中k2是半带宽k2 = k %/% 2,即y[j] = x[j]j = 1, &hellip;, k2 and (n-k2+1), &hellip;, n ;

"constant"copies median(y[1:k2]) to the first values and analogously for the last ones making the smoothed ends constant;  
"constant"复制median(y[1:k2])第一值和类似于去年的平滑结束恒定;

"median"the default, smooths the ends by using symmetrical medians of subsequently smaller bandwidth, but for the very first and last value where Tukey's robust end-point rule is applied, see smoothEnds.     
"median"默认情况下,平滑随后较小的带宽使用对称中线的两端,但Tukey的强劲终点的规则是第一个和最后的价值,看到smoothEnds。


参数:algorithm
character string (partially matching "Turlach" or "Stuetzle") or the default NULL, specifying which algorithm should be applied.  The default choice depends on n = length(x) and k where "Turlach" will be used for larger problems.
字符串(部分匹配"Turlach"或"Stuetzle")或默认的NULL,指定应适用的算法。默认的选择取决于n = length(x)和k"Turlach"将使用更大的问题。


参数:print.level
integer, indicating verboseness of algorithm; should rarely be changed by average users.
整数,表示冗长的算法;应该很少改变普通用户。


Details

详情----------Details----------

Apart from the end values, the result y = runmed(x, k) simply has y[j] = median(x[(j-k2)j+k2)]) (k = 2*k2+1), computed very efficiently.
除了结束值,结果y = runmed(x, k)根本y[j] = median(x[(j-k2)j+k2)])(k = 2*k2+1),计算非常有效。

The two algorithms are internally entirely different:
国内完全不同的两种算法:




"Turlach" is the H鋜dle&ndash;Steiger algorithm (see Ref.) as implemented by Berwin Turlach. A tree algorithm is used, ensuring performance O(n * log(k)) where n = length(x) which is
"Turlach"是H?的rdle斯泰格尔算法(见参考文献)Berwin Turlach实施。树算法,确保性能O(n * log(k))其中n = length(x)这是




"Stuetzle" is the (older) Stuetzle&ndash;Friedman implementation which makes use of median updating when one observation enters and one leaves the smoothing window.  While this performs as O(n * k) which is slower asymptotically, it is
"Stuetzle"(旧)的Stuetzle弗里德曼实施,这使得使用中位数,更新一个观测时进入和离开平滑窗口。而这个执行O(n * k)这是较慢的渐近,它是


值----------Value----------

vector of smoothed values of the same length as x with an attribute k containing (the "oddified") k.
向量的长度相同的平滑值x与attributek包含(“oddified)k的。


作者(S)----------Author(s)----------


Martin Maechler <a href="mailto:maechler@stat.math.ethz.ch">maechler@stat.math.ethz.ch</a>,
based on Fortran code from Werner Stuetzle and S-PLUS and C code from
Berwin Turlach.




参考文献----------References----------

[Algorithm AS 296] Optimal median smoothing, Applied Statistics 44, 258&ndash;264.
Smoothing of Scatterplots; Report, Dep. Statistics, Stanford U., Project Orion 003.
Fast Running Medians: Finite Sample and Asymptotic Optimality; working paper available from the author.

参见----------See Also----------

smoothEnds which implements Tukey's end point rule and is called by default from runmed(*, endrule = "median"). smooth uses running medians of 3 for its compound smoothers.
smoothEnds实现Tukey的终点规则,被称为默认情况下,从runmed(*, endrule = "median")。 smooth使用及其化合物的平滑运行中位数为3。


举例----------Examples----------


require(graphics)

utils::example(nhtemp)
myNHT <- as.vector(nhtemp)
myNHT[20] <- 2 * nhtemp[20]
plot(myNHT, type="b", ylim = c(48,60), main = "Running Medians Example")
lines(runmed(myNHT, 7), col = "red")

## special: multiple y values for one x[#特殊:一个X多个y值]
plot(cars, main = "'cars' data and runmed(dist, 3)")
lines(cars, col = "light gray", type = "c")
with(cars, lines(speed, runmed(dist, k = 3), col = 2))


## nice quadratic with a few outliers[#漂亮的二次几个离群]
y <- ys <- (-20:20)^2
y [c(1,10,21,41)] <- c(150, 30, 400, 450)
all(y == runmed(y, 1)) # 1-neighbourhood &lt;==&gt; interpolation[1个居委会<==>插值]
plot(y) ## lines(y, lwd=.1, col="light gray")[#线(Y,LWD = 0.1,彩色=“浅灰色”)]
lines(lowess(seq(y),y, f = .3), col = "brown")
lines(runmed(y, 7), lwd=2, col = "blue")
lines(runmed(y,11), lwd=2, col = "red")

## Lowess is not robust[#LOWESS是不健全]
y <- ys ; y[21] <- 6666 ; x <- seq(y)
col <- c("black", "brown","blue")
plot(y, col=col[1])
lines(lowess(x,y, f = .3), col = col[2])


lines(runmed(y, 7),      lwd=2, col = col[3])
legend(length(y),max(y), c("data", "lowess(y, f = 0.3)", "runmed(y, 7)"),
       xjust = 1, col = col, lty = c(0, 1,1), pch = c(1,NA,NA))

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-1-24 14:53 , Processed in 0.025173 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表