symviews <-
function(x, Y)
{
# Makes trimmed views for 90, 80, ..., 0
# percent trimming and sometimes works even if m
# is symmetric about E(x^t beta) where
# y = m(x^T beta ) + e.
# For work stations, activate a graphics
# device with command "X11()" or "motif()."
# For R, use "library(lqs)."
# Use the rightmost mouse button to advance
# the view. In R, highlight ``stop."
x <- as.matrix(x)
tem <- seq(0.1, 1, 0.1)
bols <- lsfit(x, Y)$coef
fit <- x %*% bols[-1]
temx <- x[fit > median(fit), ]
temy <- Y[fit > median(fit)]
out <- cov.mcd(temx) # or use out <- cov.mve(temx)
center <- out$center
cov <- out$cov
rd2 <- mahalanobis(temx, center, cov)
for(i in 1:10) {
val <- quantile(rd2, tem[i])
bhat <- lsfit(temx[rd2 <= val, ], temy[rd2 <= val])$coef
ESP <- x %*% bhat[-1]
plot(ESP, Y)
identify(ESP, Y)
print(bhat)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.