Check normality of a vector of values.

normality(
  x,
  na.rm = getOption("na.rm", FALSE),
  type = getOption("quantile.type", 7)
)

Arguments

x

vector of values

na.rm

Remove empty values

type

an integer between 1 and 9 selecting one of the nine quantile algorithms detailed below to be used.

Default values of na.rm

This 'certestats' package supports a global default setting for na.rm in many mathematical functions. This can be set with options(na.rm = TRUE) or options(na.rm = FALSE).

For normality(), quantile() and IQR(), this also applies to the type argument. The default, type = 7, is the default of base R. Use type = 6 to comply with SPSS.

Examples

x <- runif(1000)
normality(x)

#> # A tibble: 4 × 5
#>   statistic    p.value method                             interpretation suggest
#>       <dbl>      <dbl> <chr>                              <chr>          <chr>  
#> 1    0.957   1.78e- 16 Shapiro-Wilk normality test        Not normally … NA     
#> 2    0.500   5.93e-218 Asymptotic one-sample Kolmogorov-… Not normally … NA     
#> 3    0.0307 NA         Skewness                           0 in normal d… NA     
#> 4    1.83   NA         Kurtosis                           3 in normal d… NA     

x <- rnorm(1000)
normality(x)

#> # A tibble: 4 × 5
#>   statistic  p.value method                               interpretation suggest
#>       <dbl>    <dbl> <chr>                                <chr>          <chr>  
#> 1    0.995   0.00471 Shapiro-Wilk normality test          Not normally … x ^ (1…
#> 2    0.0190  0.863   Asymptotic one-sample Kolmogorov-Sm… Normally dist… (as is)
#> 3    0.232  NA       Skewness                             0 in normal d… NA     
#> 4    3.30   NA       Kurtosis                             3 in normal d… NA     

x <- rexp(1000, rate = 3)
normality(x)

#> # A tibble: 4 × 5
#>   statistic    p.value method                             interpretation suggest
#>       <dbl>      <dbl> <chr>                              <chr>          <chr>  
#> 1     0.833  4.86e- 31 Shapiro-Wilk normality test        Not normally … NA     
#> 2     0.500  9.38e-218 Asymptotic one-sample Kolmogorov-… Not normally … NA     
#> 3     1.76  NA         Skewness                           0 in normal d… NA     
#> 4     7.14  NA         Kurtosis                           3 in normal d… NA