normcheck {s20x} | R Documentation |
Testing for normality plot
Description
Plots two plots side by side. Firstly it draws a Normal QQ-plot of the
residuals, along with a line which has an intercept at the mean of the
residuals and a slope equal to the standard deviation of the residuals. If
shapiro.wilk = TRUE
then, in the top left hand corner of the Q-Q
plot, the P-value from the Shapiro-Wilk test for normality is given.
Secondly, it draws a histogram of the residuals. A normal distribution is
fitted and superimposed over the histogram. NOTE: if you want to leave the
x-axis blank in the histogram then, use xlab = c("Theoretical Quantiles", " ")
, i.e. leave a space between the quotes. If you don't leave a space, then information
will be extracted from x
.
Usage
normcheck(x, ...)
## Default S3 method:
normcheck(
x,
xlab = c("Theoretical Quantiles", ""),
ylab = c("Sample Quantiles", ""),
main = c("", ""),
col = "light blue",
bootstrap = FALSE,
B = 5,
bpch = 3,
bcol = "lightgrey",
shapiro.wilk = FALSE,
whichPlot = 1:2,
usePar = TRUE,
...
)
## S3 method for class 'lm'
normcheck(
x,
xlab = c("Theoretical Quantiles", ""),
ylab = c("Sample Quantiles", ""),
main = c("", ""),
col = "light blue",
bootstrap = FALSE,
B = 5,
bpch = 3,
bcol = "lightgrey",
shapiro.wilk = FALSE,
whichPlot = 1:2,
usePar = TRUE,
...
)
Arguments
x |
the residuals from fitting a linear model. Alternatively, a fitted |
... |
additional arguments which are passed to both |
xlab |
a title for the x-axis of both the Q-Q plot and the histogram: see |
ylab |
a title for the y-axis of both the Q-Q plot and the histogram: see |
main |
a title for both the Q-Q plot and the histogram: see |
col |
a color for the bars of the histogram. |
bootstrap |
if |
B |
the number of bootstrap samples to take. Five should be sufficient, but hey maybe you want more? |
bpch |
the plotting symbol used for the bootstrap samples. Legal values are the same as any legal
value for |
bcol |
the plotting colour used for the bootstrap samples. Legal values are the same as any legal
value for |
shapiro.wilk |
if |
whichPlot |
legal values are |
usePar |
if |
Methods (by class)
-
normcheck(default)
: Testing for normality plot -
normcheck(lm)
: Testing for normality plot
See Also
Examples
# An exponential growth curve
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)
normcheck(lm(BP ~ weight, data = peru.df))