R の t.test() 関数 - t 検定

R言語の例

R の t.test() 関数は t 検定を実行し、2つのデータ群の平均値に有意差があるかどうかを比較します。

t 検定は、統計分析で最もよく使われる仮説検定の方法の1つです。

t.test() 関数の構文は次のとおりです:

t.test(x, y = NULL, alternative = "two.sided", mu = 0, paired = FALSE, conf.level = 0.95)

パラメータの説明:

  • x最初のデータベクトル。

  • yオプション。2番目のデータベクトル(独立した2標本t検定に使用)。

  • alternative対立仮説の方向:"two.sided"(両側)、"less"、"greater"。

  • mu帰無仮説における平均値。デフォルトは 0。

  • paired対応のある t 検定を行うかどうか。

  • conf.level信頼水準。デフォルトは 0.95。

例

# 2標本独立t検定:2つの教授法の効果を比較
method_a <- c(78, 82, 85, 88, 90, 75, 80, 86, 92, 84)
method_b <- c(72, 75, 78, 76, 80, 70, 74, 77, 79, 73)

# t 検定を実行
result <- t.test(method_a, method_b)
print(result)

上記のコードを実行すると、次の結果が出力されます:

    Welch Two Sample t-test

data:  method_a and method_b
t = 4.4029, df = 17.764, p-value = 0.0003513
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
  4.640839 13.159161
sample estimates:
mean of x mean of y
     84.0      75.1

結果から、p 値が 0.05 よりはるかに小さいことがわかり、2つの教授法のグループ間で成績に有意差があることを示しています。

R言語の例

その他の拡張