※本ページの内容はテキストの第7章に相当します
本章では1標本と2標本の場合における平均値の推定方法について学びます。本章ではRcmdrで実行した場合のコードと出力結果のみを記載し、手順の記載は省略しますので詳細はテキストを参照してください。
データの読み込み
- Rcmdrのメニューから[データ]-[データセットのロード…]を実行する
- ファイルダイアログで「
外来患者ストレス.RData
」ファイルを選択する - アクティブデータセットが
PatientStress
になっていることを確認する
7.1 1標本における母平均に関する推測(P140)
7.1.1 母平均に関するt検定(P141)
t検定は「母平均はある特定の値に等しい(または、大きい・小さい)」という帰無仮説\(H_0\)(null hypothesis)をテスト(両側検定または片側検定)する手法です。テストが成功(p値が事前に設定した有意水準より小さい)すれば帰無仮説\(H_0\)は棄却され対立仮説\(H_1\)(alternative hypothesis)が採用されます。逆にテストが失敗(p値が有意水準より大きい)すれば帰無仮説\(H_0\)は棄却されません。
母平均\(\mu \ne \mu_0\)の両側検定。
統計量 - 平均 - 1標本t検定
One Sample t-test
data: 健康統制感
t = -11.468, df = 336, p-value < 2.2e-16
alternative hypothesis: true mean is not equal to 100
95 percent confidence interval:
89.99854 92.92728
sample estimates:
mean of x
91.46291
テキストにはありません。
統計量 - 平均 - 1標本t検定
One Sample t-test
data: 健康統制感
t = -11.468, df = 336, p-value < 2.2e-16
alternative hypothesis: true mean is less than 100
95 percent confidence interval:
-Inf 92.6908
sample estimates:
mean of x
91.46291
テキストにはありません。
統計量 - 平均 - 1標本t検定
One Sample t-test
data: 健康統制感
t = -11.468, df = 336, p-value = 1
alternative hypothesis: true mean is greater than 100
95 percent confidence interval:
90.23501 Inf
sample estimates:
mean of x
91.46291
7.1.2 1標本ウィルコクソン検定(P143)
ウィルコクソン検定は変数が正規分布に従わない場合に用いる検定です。
統計量 - ノンパラメトリック検定 - 1標本Wilcoxon検定
[1] 25
[1] 34.89911
Wilcoxon signed rank test with continuity correction
data: ストレス反応得点
V = 28410, p-value = 0.8792
alternative hypothesis: true location is not equal to 30
テキストにはありません。
統計量 - ノンパラメトリック検定 - 1標本Wilcoxon検定
[1] 25
[1] 34.89911
Wilcoxon signed rank test with continuity correction
data: ストレス反応得点
V = 28410, p-value = 0.5606
alternative hypothesis: true location is less than 30
テキストにはありません。
統計量 - ノンパラメトリック検定 - 1標本Wilcoxon検定
[1] 25
[1] 34.89911
Wilcoxon signed rank test with continuity correction
data: ストレス反応得点
V = 28410, p-value = 0.4396
alternative hypothesis: true location is greater than 30
7.2 独立な2標本における母平均に関する推定(P146)
7.2.1 母平均の差に関するt検定と区間推定(P147)
平均の差\(\mu_a - \mu_b \ne 0\)の両側検定。
統計量 - 平均 - 独立サンプルt検定
t.test(健康統制感 ~ 性別, alternative = "two.sided", var.equal = TRUE,
data = PatientStress)
Two Sample t-test
data: 健康統制感 by 性別
t = 0.049249, df = 335, p-value = 0.9608
alternative hypothesis: true difference in means between group 男 and group 女 is not equal to 0
95 percent confidence interval:
-2.991696 3.145347
sample estimates:
mean in group 男 mean in group 女
91.51261 91.43578
テキストにはありません。
統計量 - 平均 - 独立サンプルt検定
t.test(健康統制感 ~ 性別, alternative = "less", var.equal = TRUE,
data = PatientStress)
Two Sample t-test
data: 健康統制感 by 性別
t = 0.049249, df = 335, p-value = 0.5196
alternative hypothesis: true difference in means between group 男 and group 女 is less than 0
95 percent confidence interval:
-Inf 2.649821
sample estimates:
mean in group 男 mean in group 女
91.51261 91.43578
テキストにはありません。
統計量 - 平均 - 独立サンプルt検定
t.test(健康統制感 ~ 性別, alternative = "greater", var.equal = TRUE,
data = PatientStress)
Two Sample t-test
data: 健康統制感 by 性別
t = 0.049249, df = 335, p-value = 0.4804
alternative hypothesis: true difference in means between group 男 and group 女 is greater than 0
95 percent confidence interval:
-2.496171 Inf
sample estimates:
mean in group 男 mean in group 女
91.51261 91.43578
7.2.2 2標本ウィルコクソン検定(P149)
ウィルコクソン検定は変数が正規分布に従わない場合に用いる検定です。
統計量 - ノンパラメトリック検定 - 2標本ウィルコクソン検定
car::Tapply(ストレス反応得点 ~ 性別, median, na.action=na.omit,
data=PatientStress) # medians by group
wilcox.test(ストレス反応得点 ~ 性別, alternative="two.sided",
data=PatientStress)
男 女
19 31
Wilcoxon rank sum test with continuity correction
data: ストレス反応得点 by 性別
W = 9830, p-value = 0.000238
alternative hypothesis: true location shift is not equal to 0
テキストにはありません。
統計量 - ノンパラメトリック検定 - 2標本ウィルコクソン検定
car::Tapply(ストレス反応得点 ~ 性別, median, na.action=na.omit,
data=PatientStress) # medians by group
wilcox.test(ストレス反応得点 ~ 性別, alternative="less",
data=PatientStress)
男 女
19 31
Wilcoxon rank sum test with continuity correction
data: ストレス反応得点 by 性別
W = 9830, p-value = 0.000119
alternative hypothesis: true location shift is less than 0
テキストにはありません。
統計量 - ノンパラメトリック検定 - 2標本ウィルコクソン検定
car::Tapply(ストレス反応得点 ~ 性別, median, na.action=na.omit,
data=PatientStress) # medians by group
wilcox.test(ストレス反応得点 ~ 性別, alternative="greater",
data=PatientStress)
男 女
19 31
Wilcoxon rank sum test with continuity correction
data: ストレス反応得点 by 性別
W = 9830, p-value = 0.9999
alternative hypothesis: true location shift is greater than 0
7.3 対応のある標本における平均の差に関する推測(P152)
データの読み込み
- Rcmdrのメニューから[データ]-[データセットのロード…]を実行する
- ファイルダイアログで「
バイタルサイン.RData
」ファイルを選択する - アクティブデータセットが
VitalSign
になっていることを確認する
7.3.1 対応のある標本のt検定と区間推定(P153)
平均の差\(\mu_1 - \mu_2 \ne 0\)の両側検定。
統計量 - 平均 - 対応のあるt検定
Paired t-test
data: 運動後収縮期血圧 and 安静時収縮期血圧
t = 10.588, df = 56, p-value = 5.535e-15
alternative hypothesis: true mean difference is not equal to 0
95 percent confidence interval:
12.48919 18.31783
sample estimates:
mean difference
15.40351
テキストにはありません。
統計量 - 平均 - 対応のあるt検定
Paired t-test
data: 運動後収縮期血圧 and 安静時収縮期血圧
t = 10.588, df = 56, p-value = 1
alternative hypothesis: true mean difference is less than 0
95 percent confidence interval:
-Inf 17.8367
sample estimates:
mean difference
15.40351
テキストにはありません。
統計量 - 平均 - 対応のあるt検定
Paired t-test
data: 運動後収縮期血圧 and 安静時収縮期血圧
t = 10.588, df = 56, p-value = 2.768e-15
alternative hypothesis: true mean difference is greater than 0
95 percent confidence interval:
12.97032 Inf
sample estimates:
mean difference
15.40351
7.3.2 ウィルコクソンの符号付き順位検定(P155)
平均の差\(\mu_1 - \mu_2 \ne 0\)の両側検定。
統計量 - ノンパラメトリック検定 - 対応のあるウィルコクソン検定
with(VitalSign, wilcox.test(運動後呼吸数, 安静時呼吸数,
alternative='two.sided', paired=TRUE))
Wilcoxon signed rank test with continuity correction
data: 運動後呼吸数 and 安静時呼吸数
V = 1427.5, p-value = 2.931e-10
alternative hypothesis: true location shift is not equal to 0
テキストにはありません。
統計量 - ノンパラメトリック検定 - 対応のあるウィルコクソン検定
with(VitalSign, wilcox.test(運動後呼吸数, 安静時呼吸数,
alternative='less', paired=TRUE))
Wilcoxon signed rank test with continuity correction
data: 運動後呼吸数 and 安静時呼吸数
V = 1427.5, p-value = 1
alternative hypothesis: true location shift is less than 0
テキストにはありません。
統計量 - ノンパラメトリック検定 - 対応のあるウィルコクソン検定
with(VitalSign, wilcox.test(運動後呼吸数, 安静時呼吸数,
alternative='greater', paired=TRUE))
Wilcoxon signed rank test with continuity correction
data: 運動後呼吸数 and 安静時呼吸数
V = 1427.5, p-value = 1.465e-10
alternative hypothesis: true location shift is greater than 0
テキストにはありません。
グラフ - ヒストグラム
テキストにはありません。
統計量 - 要約 - 数値による要約
RcmdrMisc::numSummary(VitalSign[,"運動後呼吸数", drop=FALSE],
statistics=c("quantiles"), quantiles=c(.5))
RcmdrMisc::numSummary(VitalSign[,"安静時呼吸数", drop=FALSE],
statistics=c("quantiles"), quantiles=c(.5))
50%
25
50%
16
数値による要約の制約事項