runmean {WRS2} | R Documentation |
Running Interval Smoother
Description
The runmean
implements a running interval smoother on the trimmed mean, rungen
uses general M-estimators, runmbo
performs
interval smoothing on M-estimators with bagging.
Usage
runmean(x, y, fr = 1, tr = 0.2, ...)
rungen(x, y, fr = 1, est = "mom", ...)
runmbo(x, y, fr = 1, est = "mom", nboot = 40, ...)
Arguments
x |
a numeric vector of data values (predictor) |
y |
a numeric vector of data values (response) |
fr |
smoothing factor (see details) |
tr |
trim level for the mean |
est |
type of M-estimator ( |
nboot |
number of bootstrap samples |
... |
currently ignored. |
Details
The larger the smoothing factor, the stronger the smoothing. Often the choice fr = 1
gives good results; the general strategy is
to find the smallest constant so that the plot looks reasonably smooth.
Value
Returns the fitted values.
References
Wilcox, R. (2012). Introduction to Robust Estimation and Hypothesis Testing (3rd ed.). Elsevier.
See Also
Examples
## trimmed mean smoother
fitmean <- runmean(Pygmalion$Pretest, Pygmalion$Posttest)
## MOM smoother
fitmest <- rungen(Pygmalion$Pretest, Pygmalion$Posttest)
## median smoother
fitmed <- rungen(Pygmalion$Pretest, Pygmalion$Posttest, est = "median")
## bagged onestep smoother
fitbag <- runmbo(Pygmalion$Pretest, Pygmalion$Posttest, est = "onestep")
## plot smoothers
plot(Pygmalion$Pretest, Pygmalion$Posttest, col = "gray", xlab = "Pretest", ylab = "Posttest",
main = "Pygmalion Smoothing")
orderx <- order(Pygmalion$Pretest)
lines(Pygmalion$Pretest[orderx], fitmean[orderx], lwd = 2)
lines(Pygmalion$Pretest[orderx], fitmest[orderx], lwd = 2, col = 2)
lines(Pygmalion$Pretest[orderx], fitmed[orderx], lwd = 2, col = 3)
lines(Pygmalion$Pretest[orderx], fitbag[orderx], lwd = 2, col = 4)
legend("topleft", legend = c("Trimmed Mean", "MOM", "Median", "Bagged Onestep"), col = 1:4, lty = 1)
[Package WRS2 version 1.1-6 Index]