The main components of the R code used in this chapter follow with the
components to modify in lighter and/or ALL CAPS text where y
is a response variable,
x
is an explanatory variable, and the data are in DATASETNAME
.
pairs.panels(DATASETNAME, ellipses=F, scale=T, smooth=F, col=0)
Requires the psych
package.
Makes a scatterplot matrix that also displays the correlation coefficient.
cor(y~x, data=DATASETNAME)
plot(y~x, data=DATASETNAME)
scatterplot(y~x, data=DATASETNAME, smooth=F)
Requires the car
package.
Provides a scatter plot with a regression line.
MODELNAME <-
lm(y~x,
data=DATASETNAME)
summary(MODELNAME)
par(mfrow=c(2, 2)); plot(MODELNAME)