dat <- data.frame(x1 = c(3, 2, 4, 9, 5, 3, 6, 4, 5, 6, 3, 5),
x2 = c(1, 4, 3, 1, 2, 4, 3, 5, 1, 7, 8, 7),
x3 = c(0, NA, 1, 0, 1, 1, NA, 1, 0, 0, 1, 1),
y = c(2, 7, 4, 4, 7, 8, 4, 2, 5, 1, 3, 8))
# Regression model and measures for leverage, distance, and influence
mod.lm <- lm(y ~ x1 + x2, data = dat)
check.outlier(mod.lm)
# Merge result table with the data
dat1 <- cbind(dat, check.outlier(mod.lm))
Run the code above in your browser using DataLab