![見出し画像](https://assets.st-note.com/production/uploads/images/97966880/rectangle_large_type_2_86ced34035a8048d026934f49f3004f4.png?width=800)
カイ2乗検定(chi-square test)
グラフのコードの出所:
グラフのスクリプト
imanishi$Digit <- factor(imanishi$Digit)
graph <- ggplot(imanishi, aes(x=Digit, y=Frequency)) +
geom_bar(stat='identity') +
theme_bw()
graph
カイ2乗検定の結果:
X-squared = 174.37, df = 9, p-value < 2.2e-16
library(ggplot2)
x <- seq(0, +180, 0.1)
dens <- data.frame(x=x, y=dchisq(x, 9))
ggplot(dens,aes(x,y)) +
geom_line()+
geom_vline(xintercept = 16.92, linetype="dashed")+
geom_vline(xintercept = 21.67, linetype="dashed")+
geom_vline(xintercept = 174.37, linetype="dashed",col="red")
pchisq(q=16.92,df=9)
pchisq(q=21.67,df=9)
pchisq(q=174.37,df=9)
![](https://assets.st-note.com/img/1676340704315-eSRICrr2QP.png?width=800)
![](https://assets.st-note.com/img/1676341576545-uDRgZP0Kso.png?width=800)
chisq.test(imanishi$Frequency,simulate.p.value=T)
![](https://assets.st-note.com/img/1676343837133-BaMM6uA49E.png?width=800)
この記事が気に入ったらサポートをしてみませんか?