# Synthetic teaching example: an exponential growth curve
set.seed(123)
e = rnorm(100, 0, 0.1)
x = rnorm(100)
y = exp(5 + 3 * x + e)
fit = lm(y ~ x)
normcheck(fit)
# An exponential growth curve with the correct transformation
fit = lm(log(y) ~ x)
normcheck(fit)
# Same example as above except we use normcheck.default
normcheck(residuals(fit))
# Peruvian Indians data
data(peru.df)
peruFit = lm(BP ~ weight, data = peru.df)
normcheck(peruFit)
# Optional ggplot2 engine for reusable plot objects
if (requireNamespace("ggplot2", quietly = TRUE)) {
normPlots = normcheck(peruFit, engine = "ggplot2")
names(normPlots)
normcheck(peruFit, engine = "ggplot2", whichPlot = 1)
normcheck(peruFit, engine = "ggplot2", whichPlot = 2)
}
Run the code above in your browser using DataLab