#----------------------------------------------------------------------------
# One-Sample Design
# Example 1a: Two-sided one-sample z-test, population mean = 20, population SD = 6
test.z(mtcars$mpg, sigma = 6, mu = 20)
# Example 1b: One-sided one-sample z-test, population mean = 20, population SD = 6,
# print Cohen's d
test.z(mtcars$mpg, sigma = 6, mu = 20, alternative = "greater", effsize = TRUE)
# Example 1c: Two-sided one-sample z-test, population mean = 20, population SD = 6,
# plot results
test.z(mtcars$mpg, sigma = 6, mu = 20, plot = TRUE)
if (FALSE) {
# Example 1d: Two-sided one-sample z-test, save plot
test.z(mtcars$mpg, sigma = 6, mu = 20, plot = TRUE, filename = "One-sample_z-test.png",
width = 4, height = 5)}
#----------------------------------------------------------------------------
# Two-Sample Design
# Example 2a: Two-sided two-sample z-test, population SD = 6, equal SD assumption
test.z(mpg ~ vs, data = mtcars, sigma = 6)
# Example 2b: Two-sided two-sample z-test, alternative specification
test.z(c(3, 1, 4, 2, 5, 3, 6, 7), c(5, 2, 4, 3, 1), sigma = 1.2)
# Example 2c: Two-sided two-sample z-test, population SD = 4 and 6, unequal SD assumption
test.z(mpg ~ vs, data = mtcars, sigma = c(4, 6))
# Example 2d: One-sided two-sample z-test, population SD = 4 and 6, unequal SD assumption
# print Cohen's d
test.z(mpg ~ vs, data = mtcars, sigma = c(4, 6), alternative = "greater",
effsize = TRUE)
# Example 2e: Two-sided two-sample z-test, population SD = 6, equal SD assumption
# plot results
test.z(mpg ~ vs, data = mtcars, sigma = 6, plot = TRUE)
if (FALSE) {
# Example 2f: Two-sided two-sample z-test, save plot
test.z(mpg ~ vs, data = mtcars, sigma = 6, plot = TRUE, filename = "Two-sample_z-test.png",
width = 5, height = 6)}
#----------------------------------------------------------------------------
# Paired-Sample Design
# Example 3a: Two-sided paired-sample z-test, population SD of difference score = 1.2
test.z(mtcars$drat, mtcars$wt, sigma = 1.2, paired = TRUE)
# Example 3b: One-sided paired-sample z-test, population SD of difference score = 1.2,
# print Cohen's d
test.z(mtcars$drat, mtcars$wt, sigma = 1.2, paired = TRUE,
alternative = "greater", effsize = TRUE)
# Example 3c: Two-sided paired-sample z-test, population SD of difference score = 1.2,
# plot results
test.z(mtcars$drat, mtcars$wt, sigma = 1.2, paired = TRUE, plot = TRUE)
if (FALSE) {
# Example 3d: Two-sided paired-sample z-test, save plot
test.z(mtcars$drat, mtcars$wt, sigma = 1.2, paired = TRUE, plot = TRUE,
filename = "Paired-sample_z-test.png", width = 4, height = 5)}
Run the code above in your browser using DataLab