Generates univariate distributional data and returns a p-value to assess the null
that the population follows a Gaussian distribution shape. Uses
shapiro.test.
Author
Phil Chalmers rphilip.chalmers@gmail.com
Examples
# 50 observations drawn from normal distribution (null is true)
p_shapiro.test(rnorm(50))
#> [1] 0.8359497
# return analysis object
p_shapiro.test(rnorm(50), TRUE)
#>
#> Shapiro-Wilk normality test
#>
#> data: dist
#> W = 0.98676, p-value = 0.8438
#>
# 50 observations from slightly skewed chi-squared distribution (power)
p_shapiro.test(rchisq(50, df=100))
#> [1] 0.9303694
# \donttest{
# empirical Type I error rate estimate
p_shapiro.test(rnorm(50)) |> Spower()
#> Warning: number of items to replace is not a multiple of replacement length
#>
#> ── Spower Results ──────────────────────────────────────────────────────────────
#>
#> Design conditions:
#>
#> # A tibble: 1 × 3
#> dist sig.level power
#> <dbl> <dbl> <lgl>
#> 1 -1.3847 0.05 NA
#>
#> Estimate of power: 0.047
#> 95% Confidence Interval: [0.043, 0.051]
#> Execution time (H:M:S): 00:00:02
# power
p_shapiro.test(rchisq(50, df=100)) |> Spower()
#> Warning: number of items to replace is not a multiple of replacement length
#>
#> ── Spower Results ──────────────────────────────────────────────────────────────
#>
#> Design conditions:
#>
#> # A tibble: 1 × 3
#> dist sig.level power
#> <dbl> <dbl> <lgl>
#> 1 84.276 0.05 NA
#>
#> Estimate of power: 0.103
#> 95% Confidence Interval: [0.097, 0.109]
#> Execution time (H:M:S): 00:00:02
# }