###Independent samples t-test
### Read the data
# Read a csv file, named "ass06_spider.csv"
# Data set has the grouping variable as both numeric (group) and text (groupcat)
spider <- read.csv("ass06_spider.csv")
head(spider)
##   ï..subject group groupcat anxiety
## 1 1 0 toupee 30
## 2 2 0 toupee 35
## 3 3 0 toupee 45
## 4 4 0 toupee 40
## 5 5 0 toupee 50
## 6 6 0 toupee 35
# This turns the categorical version of group into a factor (non quantitative).
spider$groupcat<-factor(spider$groupcat)
View(spider)

#Two-sided (non-directional) independent samples t-test
jmv::ttestIS(
formula = anxiety ~ groupcat,
data = spider,
vars = anxiety,
eqv = TRUE,
meanDiff = TRUE,
ci = TRUE,
effectSize = TRUE,
ciES = TRUE,
desc = TRUE)
## 
## INDEPENDENT SAMPLES T-TEST
##
## Independent Samples T-Test
## --------------------------------------------------------------------------------------------------------------------------------------------------------------------
## Statistic df p Mean difference SE difference Lower Upper Cohen's d Lower Upper
## --------------------------------------------------------------------------------------------------------------------------------------------------------------------
## anxiety Student's t 1.681346 22.00000 0.1068392 7.000000 4.163332 -1.634222 15.63422 0.6864065 -0.1761329 1.521592
## --------------------------------------------------------------------------------------------------------------------------------------------------------------------
##
##
## ASSUMPTIONS
##
## Homogeneity of Variances Test (Levene's)
## --------------------------------------------------
## F df df2 p
## --------------------------------------------------
## anxiety 0.7815619 1 22 0.3862236
## --------------------------------------------------
## Note. A low p-value suggests a violation of
## the assumption of equal variances
##
##
## Group Descriptives
## ---------------------------------------------------------------------------
## Group N Mean Median SD SE
## ---------------------------------------------------------------------------
## anxiety spider 12 47.00000 50.00000 11.02889 3.183766
## toupee 12 40.00000 40.00000 9.293204 2.682717
## ---------------------------------------------------------------------------
#One-sided (directional) independent samples t-test

jmv::ttestIS(
formula = anxiety ~ groupcat,
data = spider,
vars = anxiety,
hypothesis = "oneGreater",
eqv = TRUE,
meanDiff = TRUE,
ci = TRUE,
effectSize = TRUE,
ciES = TRUE,
desc = TRUE)
## 
## INDEPENDENT SAMPLES T-TEST
##
## Independent Samples T-Test
## ------------------------------------------------------------------------------------------------------------------------------------------------------------------
## Statistic df p Mean difference SE difference Lower Upper Cohen's d Lower Upper
## ------------------------------------------------------------------------------------------------------------------------------------------------------------------
## anxiety Student's t 1.681346 22.00000 0.0534196 7.000000 4.163332 -0.1490421 Inf 0.6864065 -0.1761329 1.521592
## ------------------------------------------------------------------------------------------------------------------------------------------------------------------
## Note. H<U+2090> spider > toupee
##
##
## ASSUMPTIONS
##
## Homogeneity of Variances Test (Levene's)
## --------------------------------------------------
## F df df2 p
## --------------------------------------------------
## anxiety 0.7815619 1 22 0.3862236
## --------------------------------------------------
## Note. A low p-value suggests a violation of
## the assumption of equal variances
##
##
## Group Descriptives
## ---------------------------------------------------------------------------
## Group N Mean Median SD SE
## ---------------------------------------------------------------------------
## anxiety spider 12 47.00000 50.00000 11.02889 3.183766
## toupee 12 40.00000 40.00000 9.293204 2.682717
## ---------------------------------------------------------------------------