趣味の統計

心理統計のはなし(偏差への偏愛ともいう)。Web上に散らばっている「アンケート」へのつっこみ。その他。

3色のミニトマト

「クレア」という品種?の、3色のミニトマトを買ってきました。

どう見ても、オレンジ色だけが大きいように見えます。重さを測ってみましょう。

tomato_red    <- c(5,6,7,6,7,6,5,5,6,5,6,5,6,6,5)
tomato_yellow <- c(7,6,7,6,6,6,7,5,5)
tomato_orange <- c(10,9,11,8,9,9,10,11)

データフレームにまとめて、箱ひげ図を描きましょう。

tomato <- data.frame(
  weight = c(tomato_red, tomato_yellow, tomato_orange),
  color  = c(rep("R", length(tomato_red)), rep("Y", length(tomato_yellow)), rep("O", length(tomato_orange)))
)
tomato$color <- as.factor(tomato$color)
boxplot(tomato$weight ~ tomato$color)

おお、どう見ても「O」(オレンジ色)だけ重そうです。重さの平均値を調べると、オレンジは 9.625、レッドは 5.733、イエローは 6.111でした。

私が買ってきたパックを、出荷されているすべての同じ3色のトマトからの無作為標本だと仮定すると、母集団においても重さに違いがあるのかを予測できます。

result <- aov(weight ~ color, data=tomato)
summary(result)
TukeyHSD(result)

結果はこうなりました。

> summary(result)
            Df Sum Sq Mean Sq F value   Pr(>F)    
color        2  85.18   42.59    62.7 2.95e-11 ***
Residuals   29  19.70    0.68                     
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> TukeyHSD(result)
  Tukey multiple comparisons of means
    95% family-wise confidence level

Fit: aov(formula = weight ~ color, data = tomato)

$color
          diff        lwr       upr     p adj
R-O -3.8916667 -4.7827365 -3.000597 0.0000000
Y-O -3.5138889 -4.5028897 -2.524888 0.0000000
Y-R  0.3777778 -0.4803999  1.235955 0.5294898

0.1%水準で有意差ありという結果で、多重比較(Tukey)でも、オレンジだけ有意に重いという結果でした。