A notebook made by Paul Amat, amat-design.com
Does the population mean or median differ from a predefined value?
H0:
H1:
library(readr)
data <- read_csv("data.csv", show_col_types = FALSE)
mu0 <- 34
print("Score")
[1] "Score"
summary(data$score)
Min. 1st Qu. Median Mean 3rd Qu. Max.
6.36 18.75 30.25 30.31 41.45 54.78
mean(data$score)-mu0 # ok jamovi
[1] -3.69145
The independence of observations is guaranteed by the recruitment process.
par(mfrow=c(1,2))
hist(data$score, freq=FALSE)
curve(dnorm(x, mean=mean(data$score), sd=sd(data$score)), add=TRUE, col="red")
qqnorm(data$score)
qqline(data$score, col="red")
ks.test(data$score, "pnorm", mean(data$score), sd(data$score)) # ok in jamovi
Warning in ks.test(data$score, "pnorm", mean(data$score), sd(data$score)) :
ties should not be present for the Kolmogorov-Smirnov test
One-sample Kolmogorov-Smirnov test
data: data$score
D = 0.083478, p-value = 0.1231
alternative hypothesis: two-sided
shapiro.test(data$score) # ok in jamovi
Shapiro-Wilk normality test
data: data$score
W = 0.95916, p-value = 1.607e-05
outliers <- function(x) {
qinf <- quantile(x, 0.25) - (IQR(x)*1.5)
qsup <- quantile(x, 0.75) + (IQR(x)*1.5)
x[x < qinf | x > qsup]
}
outliers(data$score)
numeric(0)
t.test(data$score, mu = mu0) # ok in jamovi
One Sample t-test
data: data$score
t = -4.0113, df = 199, p-value = 8.542e-05
alternative hypothesis: true mean is not equal to 34
95 percent confidence interval:
28.49383 32.12327
sample estimates:
mean of x
30.30855
if(!require(effsize)) install.packages("effsize")
Le chargement a nécessité le package : effsize
library(effsize)
(cohentest <- cohen.d(data$score, NA, mu = mu0)) #ok jamovi
Cohen's d (single sample)
d estimate: -0.2836416 (small)
Reference mu: 34
95 percent confidence interval:
lower upper
-0.563917120 -0.003366054
if(!require(pwr)) install.packages("pwr")
Le chargement a nécessité le package : pwr
library(pwr)
pwr.t.test(d = cohentest$estimate, n = length(data$score), sig.level = 0.05, type = "one.sample", alternative = "two.sided")
One-sample t test power calculation
n = 200
d = 0.2836416
sig.level = 0.05
power = 0.9789182
alternative = two.sided
pwr.t.test(d = cohentest$estimate, power = 0.8, sig.level = 0.05, type = "one.sample", alternative = "two.sided")
One-sample t test power calculation
n = 99.4967
d = 0.2836416
sig.level = 0.05
power = 0.8
alternative = two.sided
The independence of observations is guaranteed by the recruitment process.
length(data$score) > 30
[1] TRUE
wilcox.test(data$score, mu = mu0) # ok jamovi
Wilcoxon signed rank test with continuity correction
data: data$score
V = 6951, p-value = 0.0001564
alternative hypothesis: true location is not equal to 34
if(!require(effectsize)) install.packages("effectsize")
Le chargement a nécessité le package : effectsize
Registered S3 method overwritten by 'parameters':
method from
format.parameters_distribution datawizard
library(effectsize)
rank_biserial(data$score, mu = mu0)
r (rank biserial) | 95% CI
----------------------------------
-0.31 | [-0.45, -0.16]
- Deviation from a difference of 34.