# R script for InfluenceSimulation Example xorig = rnorm(50) yorig = rnorm(50) pdf("inf-sim.pdf") # Model 1 x = c(xorig, 20) y = c(yorig, 20) modelorig = lm(yorig ~ xorig) model1 = lm(y ~ x) cat("Influence points for Model 1:\n") print(influence.measures(model1)) plot(x, y, main="InfluenceSimulation Example -- Model 1") abline(modelorig, lty="dotted", col="blue") abline(model1, lty="dashed", col="red") subset = c(17, 51) points(x[subset], y[subset], col="red", pch="*", cex=2) # Model 2 x = c(xorig, 0) y = c(yorig, 20) model2 = lm(y ~ x) cat("Influence points for Model 2:\n") print(influence.measures(model2)) plot(x, y, main="InfluenceSimulation Example -- Model 2") abline(modelorig, lty="dotted", col="blue") abline(model2, lty="dashed", col="red") subset = c(10, 17, 27, 28, 47, 51) points(x[subset], y[subset], col="red", pch="*", cex=2) dev.off( )