groupmeans
説明
例
1 因子 ANOVA のグループ平均の検査
標本データを読み込みます。
load carbig.mat
加速度と馬力のカテゴリの変数を含む table を作成します。変数 Horsepower
を 3 つの馬力範囲に並べ替えて馬力カテゴリを取得します。
tbl = table(Acceleration); tbl.HorsepowerCats = discretize(Horsepower,[0 100 200 300])
tbl=406×2 table
Acceleration HorsepowerCats
____________ ______________
12 2
11.5 2
11 2
12 2
10.5 2
10 2
9 3
8.5 3
10 3
8.5 2
17.5 2
11.5 2
11 2
10.5 2
11 2
10 2
⋮
1 因子 ANOVA を実行して、3 つの馬力範囲のいずれでも平均加速時間が同じであるという帰無仮説を検定します。
aov = anova(tbl,"Acceleration")
aov = 1-way anova, constrained (Type III) sums of squares. Acceleration ~ 1 + HorsepowerCats SumOfSquares DF MeanSquares F pValue ____________ ___ ___________ ______ __________ HorsepowerCats 975.93 2 487.96 89.571 7.8471e-33 Error 2162.8 397 5.4478 Total 3138.7 399 Properties, Methods
"p" 値が小さいことから、少なくとも 1 つの馬力カテゴリで平均加速時間が異なることがわかります。馬力カテゴリの平均を検査して、どの馬力範囲の平均加速時間が異なるかを調べます。
means = groupmeans(aov)
means=3×5 table
HorsepowerCats Mean SE MeanLower MeanUpper
______________ ______ _______ _________ _________
1 16.804 0.15526 16.498 17.11
2 13.969 0.18282 13.608 14.33
3 11.136 0.70374 9.5683 12.704
table means
から、各カテゴリの平均が他のカテゴリの平均推定値の 95% 信頼区間外にあることがわかります。したがって、3 つのすべての馬力カテゴリで平均加速時間が有意に異なります。
2 因子 ANOVA のグループ平均の検査
自動車の燃費の標本データを読み込みます。
load mileage.mat
6 行 3 列の行列 mileage
の列に、3 つの自動車モデルについての燃費データが格納されています。最初の 3 行に 1 つの工場で製造された自動車のデータが格納され、最後の 3 行に別の工場で製造された自動車のデータが格納されています。
mileage
をベクトルに変換します。
mileage = mileage(:);
関数repmat
を使用して、工場と自動車モデルの因子の値の string 配列を作成します。
factory = repmat(["factory1";"factory1";"factory1";... "factory2";"factory2";"factory2"], [3, 1]); model = [repmat("model1",6,1);... repmat("model2",6,1);repmat("model3",6,1)]; factors = {factory,model};
2 因子 ANOVA を実行して、工場や自動車モデルの因子は自動車の燃費に影響しないという帰無仮説を検定します。
aov = anova(factors,mileage,FactorNames=["Factory","Model"])
aov = 2-way anova, constrained (Type III) sums of squares. Y ~ 1 + Factory + Model SumOfSquares DF MeanSquares F pValue ____________ __ ___________ ______ __________ Factory 1.445 1 1.445 14.382 0.0019807 Model 53.351 2 26.676 265.49 7.3827e-12 Error 1.4067 14 0.10048 Total 56.203 17 Properties, Methods
"p" 値が小さいことから、自動車が製造された工場よりも、自動車のモデルの方が自動車の燃費に有意な影響を与えることがわかります。
どの自動車モデルの燃費が 99% の信頼水準で異なるかを調べるために、グループ平均を検査します。
means = groupmeans(aov,"Model",Alpha=0.01)
means=3×5 table
Model Mean SE MeanLower MeanUpper
________ ______ _______ _________ _________
"model1" 32.95 0.12941 32.428 33.472
"model2" 34.017 0.12941 33.495 34.538
"model3" 37.017 0.12941 36.495 37.538
table から、いずれの自動車モデルの 99% 信頼区間もオーバーラップしていないことがわかります。したがって、自動車の燃費の平均について、3 つのすべてのモデルに 99% の信頼水準の統計的な有意差があります。
入力引数
aov
— ANOVA の結果
anova
オブジェクト
ANOVA の結果。anova
オブジェクトとして指定します。aov
のプロパティに、平均応答の計算に groupmeans
で使用される因子と応答データが格納されます。
factors
— 応答データのグループ化に使用する因子
string ベクトル | 文字ベクトルの cell 配列
応答データのグループ化に使用する因子。string ベクトルまたは文字ベクトルの cell 配列として指定します。関数 groupmeans
は、factors
の因子の値の組み合わせで応答データをグループ化します。引数 factors
は、aov.FactorNames
に含まれる 1 つ以上の名前でなければなりません。
例: ["g1","g2"]
データ型: string
| cell
alpha
— 有意水準
0.05
(既定値) | (0,1) の範囲のスカラー値
推定値の有意水準。範囲 (0,1) のスカラー値として指定します。信頼区間の信頼水準は です。alpha
の既定値は 0.05
で、推定値の 95% 信頼区間を返します。
例: Alpha=0.01
データ型: single
| double
出力引数
means
— 平均応答推定、標準誤差、信頼区間
テーブル
平均応答推定、標準誤差、信頼区間。table として返されます。table means
には、因子の値の一意の組み合わせごとに 1 つの行が含まれます。aov
が 1 因子 anova
オブジェクトの場合、means
には単一の因子に対応する列が含まれます。aov
が 2 因子または多因子 anova
オブジェクトの場合、means
には factors
で指定された各因子に対する列が含まれます。means
には、因子の列に加えて以下が含まれます。
Mean
— 因子の値の平均応答の推定値SE
— 平均推定値の標準誤差MeanLower
— 平均推定値の 95% 信頼限界の下限MeanUpper
— 平均推定値の 95% 信頼限界の上限
バージョン履歴
R2022b で導入
参考
multcompare
| plotComparisons
| anova
| 1 因子 ANOVA | 2 因子 ANOVA | 多因子 ANOVA
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)