resid.squares | R Documentation |
plot squared residuals in inches to match the y-dimension
resid.squares(x, y, y.hat, resid.plot = "square", ...)
x |
x values |
y |
observed y values |
y.hat |
predicted y values |
resid.plot |
If |
... |
Other graphics arguments. |
The goal is to get real squares on the screen or paper. The trick is to play games with the aspect ratio. We find the number of inches that each vertical residual occupies. We then find the number of x-units that corresponds to, and plot a rectangle with height=height in the y-data units and with width=the number of x-units that we just calculated.
Richard M. Heiberger <rmh@temple.edu>
Heiberger, Richard M. and Holland, Burt (2015). Statistical Analysis and Data Display: An Intermediate Course with Examples in R. Second Edition. Springer-Verlag, New York. https://link.springer.com/book/10.1007/978-1-4939-2122-5
regr1.plot
data(hardness)
hardness.lin.lm <- lm(hardness ~ density, data=hardness)
plot(hardness ~ density, data=hardness, xlim=c(22,73), ylim=c(0,3400))
abline(hardness.lin.lm)
resid.squares(hardness$density, hardness$hardness,
predict(hardness.lin.lm))
plot(hardness ~ density, data=hardness, xlim=c(22,73), ylim=c(0,3400))
abline(hardness.lin.lm)
resid.squares(hardness$density, hardness$hardness,
predict(hardness.lin.lm), resid.plot = "line")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.