# NOT RUN {
# example from 'anscombe'
# trim = 0
lm.1 <- lmWinsor(y1~x1, data=anscombe)
newD <- data.frame(x1=seq(1, 22, .1))
predW <- predict(lm.1, newdata=newD)
plot(y1~x1, anscombe, xlim=c(1, 22),
main="Anscombe, example 1")
lines(newD[["x1"]], predW, col='blue')
abline(h=lm.1[['lower']]['y1'], col='red', lty='dashed')
abline(h=lm.1[['upper']]['y1'], col='red', lty='dashed')
abline(v=lm.1[['lower']]['x1'], col='green', lty='dashed')
abline(v=lm.1[['upper']]['x1'], col='green', lty='dashed')
# clipped at range(anscombe[, 'x1']) = c(4, 14)
# }
# NOT RUN {
# trim = 0.25
lm.1.25 <- lmWinsor(y1~x1, data=anscombe, trim=0.25)
newD <- data.frame(x1=seq(1, 22, .1))
predW.25 <- predict(lm.1.25, newdata=newD)
plot(y1~x1, anscombe, xlim=c(1, 22))
lines(newD[["x1"]], predW.25, col='blue', lwd=2)
abline(h=lm.1.25[['lower']]['y1'], col='red', lty='dotted')
abline(h=lm.1.25[['upper']]['y1'], col='red', lty='dotted')
abline(v=lm.1.25[['lower']]['x1'], col='green', lty='dotted')
abline(v=lm.1.25[['upper']]['x1'], col='green', lty='dotted')
# clipped at range(anscombe[, 'y1']) = c(4.26 10.84)
# }
# NOT RUN {
# list example
lm.1. <- lmWinsor(y1~x1, data=anscombe, trim=c(0, 0.25, .4, .5))
pred.1. <- predict(lm.1.)
# }
Run the code above in your browser using DataCamp Workspace