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.950   5.52e- 18 Shapiro-Wilk normality test        Not normally … NA     
#> 2    0.500   1.23e-217 Asymptotic one-sample Kolmogorov-… Not normally … NA     
#> 3    0.0167 NA         Skewness                           0 in normal d… NA     
#> 4    1.75   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.997     0.110 Shapiro-Wilk normality test           Normally dist… (as is)
#> 2   0.0314    0.278 Asymptotic one-sample Kolmogorov-Smi… Normally dist… (as is)
#> 3  -0.00789  NA     Skewness                              0 in normal d… NA     
#> 4   3.03     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.835  6.68e- 31 Shapiro-Wilk normality test        Not normally … NA     
#> 2     0.500  1.23e-217 Asymptotic one-sample Kolmogorov-… Not normally … NA     
#> 3     1.74  NA         Skewness                           0 in normal d… NA     
#> 4     6.70  NA         Kurtosis                           3 in normal d… NA