0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Octave で独立性の検定

Posted at

Octave で独立性の検定

分割表(二重クロス集計表)を与えて,2 変数の独立性の検定を行う。元データからカイ二乗検定を行う場合には crosstab() を使うことができる。

usage:
[pval, chisq, df] = chisquare_test_independence (x)

x は分割表(二重クロス集計表)
戻り値を指定しない場合は p 値のみを表示する
戻り値を指定した場合は,後で変数を使用すること(表示するなど)ができる
pkg load statistics   % statistics が必要
format long           % 表示精度を高くする(任意)
x = [2 4 9
     8 1 1];

戻り値を変数に代入しない場合には $p$ 値のみが表示される。

chisquare_test_independence(x);
  pval: 0.00360656

戻り値を変数に代入すれば結果を自由に表示できる。

[pval, chisq, df] = chisquare_test_independence(x);
printf("chisq = %.5g,  df = %d,  p value = %.5g\n", chisq, df, pval)
chisq = 11.25,  df = 2,  p value = 0.0036066

$2 \times 2$ 分割表の場合には,連続性の補正(イェーツの補正)をしない結果が表示される(連続性の補正をするオプションはない)。

t = [1 2; 3 4];
[pval, chisq, df] = chisquare_test_independence(t);
printf("chisq = %.5g,  df = %d,  p value = %.5g\n", chisq, df, pval)
chisq = 0.079365,  df = 1,  p value = 0.77816
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?