F検定について

9 views (last 30 days)
Hiraku Tokuma
Hiraku Tokuma on 29 Sep 2021
Commented: Hiraku Tokuma on 2 Oct 2021
forループでF検定のp値を出力させる方法を教えてください。
for a= 1:n;
x= 行列名1 (a,:);
y = 行列名2(a,:);
f(a,:) = vartest2(x,y);
end
とすると、
行列名1と2のa列目同士をF検定してその判定を返してはくれるのですが、同時にp値の行列も作成したいです。
ご知恵を拝借願えませんでしょうか。

Accepted Answer

Atsushi Ueno
Atsushi Ueno on 29 Sep 2021
上記の最初に書いてある「等分散に関する検定」と同じ内容です。データの内容はさておき、[h,p] = vartest2(x,y)と書かないとp値を出力してくれないので、一旦スカラ変数に格納してから行列にコピーすればやりたい事が出来ます。
load examgrades;
for a= 1:size(grades,2)-1;
x = grades(:,a);
y = grades(:,a+1);
[h,p] = vartest2(x,y) % 検定結果とp値を両方出力する
f(a,:) = [h,p]; % 検定結果とp値を行列に格納する
end
h = 1
p = 0.0019
h = 0
p = 0.1661
h = 0
p = 0.1120
h = 1
p = 1.4921e-07
f
f = 4×2
1.0000 0.0019 0 0.1661 0 0.1120 1.0000 0.0000
  1 Comment
Hiraku Tokuma
Hiraku Tokuma on 2 Oct 2021
解決しました
ありがとうございます

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!