Performs normality tests and creates related plots (histogram,
density, Q-Q). This is primarily a subfunction of t_neat
and
anova_neat
, but here it is available separately for other
potential purposes.
norm_tests(
var1,
var2 = NULL,
pair = FALSE,
norm_tests = "all",
alpha = 0.05,
plots = FALSE,
aspect_ratio = 1,
hush = FALSE
)
Prints normality tests, and displays plots if so specified. Returns
TRUE
if any of the specified tests has p value below the specified
alpha
, otherwise returns FALSE
.
Numeric vector; numbers of any given variable.
Optional numeric vector (or NULL
); numbers of a second
variable.
Logical; only matters if var2
is not null. In that case, if
TRUE
each normality test is performed for the difference values
between the two variables in case of paired samples, or, if FALSE
,
separately for each of the two variables for unpaired samples.
Normality tests. Any or all of the following character input
is accepted (as a single string or a character vector; case-insensitive):
"W"
(Shapiro-Wilk), "K2"
(D'Agostino), "A2"
(Anderson-Darling), "JB"
(Jarque-Bera); see Notes. The option
"all"
(default value) selects all four previous tests at the same
time.
Numeric (.05
by default), alpha level: if any p value if
below this alpha level, the function returns TRUE
, otherwise
FALSE
.
Logical: if TRUE
adds histogram, density, and Q-Q plots.
(Note: in case of paired samples, Q-Q plots are plotted on a separate
figure. In RStudio, press on "Previous plot" under "Plots" to see these Q-Q
plots.)
Aspect ratio of the plots: 1
(1
/1
) by
default. (Set to NULL
for dynamic aspect ratio.)
Logical. If TRUE
, prevents printing any details to console.
Lakens, D. (2015). The perfect t-test (version 1.0.0). Retrieved from https://github.com/Lakens/perfect-t-test. tools:::Rd_expr_doi("https://doi.org/10.5281/zenodo.17603")
Yap, B. W., & Sim, C. H. (2011). Comparisons of various types of normality tests. Journal of Statistical Computation and Simulation, 81(12), 2141–2155. tools:::Rd_expr_doi("https://doi.org/10.1080/00949655.2010.520163")
t_neat
norm_tests(stats::rnorm(100))
# should be normal...
Run the code above in your browser using DataLab