Для визуализации мощности с различными значениями N, размерами эффектов и дисперсиями, я моделирую и отображаю данные ниже:
Библиотеки:
library(repr)
library(plotrix)
# N = sample size
N = 1000
# Sample 1
x_gi = rnorm(N, mean=38.3, sd=8)
# Plot
x_gi_hist=hist(x_gi ,
breaks=25,
main=expression(paste(italic(bar(x)[0]))),
xlab="taurine per unit of something",
col="firebrick")
# Sample 2
x_gf = rnorm(N, mean=20, sd=7)
# Plot
x_gf_hist=hist(x_gf ,
breaks=25,
main=expression(paste(italic(bar(x)[gf]))),
xlab="taurine per unit of something",
col="grey70")
# Both samples together
#####################
# H0: Grain-inclusive distribution
# Plot
plot(x_gi_hist,
col= c("firebrick",rgb(0.8,0,0,1/2))[cut(x_gi_hist$breaks, c(-Inf, max(sort(x_gi)[(1: (length(x_gi)*0.05))]),Inf))],
xlim=c(0,75), ylim=c(0,N/5),
main="", xlab="taurine per unit of something",
cex.lab=1.5,
border=c("firebrick",rgb(0.7,0,0,1/4)))
# H0 label
text(x=mean(x_gi), y=max(x_gi_hist$counts) + (N/15),
label = expression(paste(italic(H[0]))),
cex=2)
# Mean label
text(x=mean(x_gi), y=max(x_gi_hist$counts) + (N/30),
label = expression(paste(italic(bar(x)[0]))),
cex=2)
# Critical value
ablineclip(v=max(sort(x_gi)[(1: (length(x_gi)*0.05))]+0.8),
lwd=2, lty=2, col="red",
y1=0, y2=max(x_gf_hist$counts)-5)
# Critical value
text(x=max(sort(x_gi)[(1: (length(x_gi)*0.05))]+0.8), y=max(x_gf_hist$counts)-4,
label="critical value", adj=0,cex= 1.5)
# Effect size arrow
arrows(x0=mean(x_gf)+4, x1=mean(x_gi)-4,
y0=max(x_gi_hist$counts) + (N/30), y1=max(x_gi_hist$counts) + (N/30),
lty=1, code=3, lwd=3, col="black")
# Effect size label
text(x=mean(x_gf) + (1/4 * mean(x_gi)), y=max(x_gi_hist$counts) + (N/25),
label = expression(paste(italic(d))),
cex=2)
#####################
# HA: Grain-free distribution
# Plot GF
plot(x_gf_hist,
col= c(rgb(0,0,0,0.2), rgb(0,0,0,0.5))[cut(x_gf_hist$breaks, c(-Inf, max(sort(x_gi)[(1: (length(x_gi)*0.05))]),Inf))],
xlim=c(0,75),ylim=c(0,N/5),
add=T, border=rgb(0,0,0,0.2))
# HA label
text(x=mean(x_gf), y=max(x_gi_hist$counts) + (N/15),
label = expression(paste(italic(H[A]))),
cex=2)
# Mean label
text(x=mean(x_gf), y=max(x_gi_hist$counts) + (N/30),
label = expression(paste(italic(bar(x)[gf]))),
cex=2, font=2)
Это работает, когда N > 100, но ломается, когда N <10. </p>
Вопрос : есть ли способ генерировать разумные графики для более низких значений N, скажем, когда N = 10
Здесь Вот пример:
Спасибо за ваше время!