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