path_data <- "~/OneDrive - University of Saskatchewan/teaching/stat245_1909/rdemo/data"
addpath <- function (x) file.path(path_data,x)
survey <- read.csv (addpath("survey.csv"))
t.test (survey$Age, mu = 23, altern = "less")
##
## One Sample t-test
##
## data: survey$Age
## t = -6.2429, df = 236, p-value =
## 9.885e-10
## alternative hypothesis: true mean is less than 23
## 95 percent confidence interval:
## -Inf 21.06899
## sample estimates:
## mean of x
## 20.37451
scatterplot
Unpaired t-test
##
## Welch Two Sample t-test
##
## data: mental[sub, 1] and mental[sub, 2]
## t = 0.18497, df = 34.912, p-value =
## 0.4272
## alternative hypothesis: true difference in means is greater than 0
## 95 percent confidence interval:
## -6.850349 Inf
## sample estimates:
## mean of x mean of y
## 52.26316 51.42105
Paired t-test
##
## Paired t-test
##
## data: mental[sub, 1] and mental[sub, 2]
## t = 0.61153, df = 18, p-value = 0.2742
## alternative hypothesis: true mean difference is greater than 0
## 95 percent confidence interval:
## -1.545793 Inf
## sample estimates:
## mean difference
## 0.8421053
scatterplot
Unpaired t-test
##
## Welch Two Sample t-test
##
## data: mental[sub, 1] and mental[sub, 2]
## t = 2.0165, df = 33.357, p-value =
## 0.02593
## alternative hypothesis: true difference in means is greater than 0
## 95 percent confidence interval:
## 1.341712 Inf
## sample estimates:
## mean of x mean of y
## 46.61111 38.27778
Paired t-test
##
## Paired t-test
##
## data: mental[sub, 1] and mental[sub, 2]
## t = 5.233, df = 17, p-value = 3.375e-05
## alternative hypothesis: true mean difference is greater than 0
## 95 percent confidence interval:
## 5.563069 Inf
## sample estimates:
## mean difference
## 8.333333
scatterplot
Unpaired t-test
##
## Welch Two Sample t-test
##
## data: mental[sub, 1] and mental[sub, 2]
## t = 3.6578, df = 41.987, p-value =
## 0.0003517
## alternative hypothesis: true difference in means is greater than 0
## 95 percent confidence interval:
## 8.51998 Inf
## sample estimates:
## mean of x mean of y
## 51.36364 35.59091
Paired t-test
##
## Paired t-test
##
## data: mental[sub, 1] and mental[sub, 2]
## t = 15.844, df = 21, p-value = 1.864e-13
## alternative hypothesis: true mean difference is greater than 0
## 95 percent confidence interval:
## 14.0597 Inf
## sample estimates:
## mean difference
## 15.77273