Files
Shiny--Code/sample_size_site_full/anova_oneway_guide.html
admin 33e9543b15 Upload to Server
Uploading to server
2025-08-02 05:15:23 +07:00

712 lines
21 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="vi">
<head>
<meta charset="UTF-8" />
<title>Hướng dẫn One Way ANOVA</title>
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<style>
body { font-family: Arial, sans-serif; padding: 20px; max-width: 800px; margin: auto; }
h1 { color: #0074D9; }
hr { margin: 20px 0; }
</style>
</head>
<body>
<h3><strong>Hướng dẫn tính toán cỡ mẫu cho kiểm định ANOVA (Phân tích phương
sai)</strong></h3>
<hr>
<h3><strong>1. Kiểm định ANOVA là gì?</strong></h3>
<p>Kiểm định ANOVA (Analysis of Variance) là một phương pháp thống kê dùng để
kiểm tra xem có sự khác biệt có ý nghĩa thống kê giữa trung bình của nhiều
nhóm độc lập hay không.</p>
<hr>
<h4><strong>Phạm vi ứng dụng:</strong></h4>
<p>Kiểm định ANOVA được sử dụng rộng rãi trong các nghiên cứu y tế, khoa học xã
hội và giáo dục, đặc biệt khi cần so sánh trung bình của hơn 2 nhóm độc
lập.<br>Ví dụ:</p>
<ul>
<li>So sánh trung bình cân nặng giữa 3 nhóm trẻ em được bổ sung dinh dưỡng ở
các mức độ khác nhau.</li>
<li>So sánh điểm trung bình của sinh viên giữa 4 phương pháp giảng dạy.</li>
<li>So sánh thời gian sống sót trung bình giữa 3 loại thuốc.</li>
</ul>
<hr>
<h3><strong>2. Công thức tính cỡ mẫu cho kiểm định ANOVA</strong></h3>
<p>Công thức tổng quát để tính cỡ mẫu cho kiểm định ANOVA dựa trên kích thước
hiệu ứng chuẩn hóa (</p>
<math style="display: block">
<semantics>
<mrow>
<mi>f</mi>
</mrow>
<annotation encoding="application/x-tex">f</annotation>
</semantics>
</math>
<p><span aria-hidden="true">f</span>), mức ý nghĩa (</p>
<math style="display: block">
<semantics>
<mrow>
<mi>α</mi>
</mrow>
<annotation encoding="application/x-tex">\alpha</annotation>
</semantics>
</math>
<p><span aria-hidden="true">α</span>), và độ mạnh kiểm định (</p>
<math style="display: block">
<semantics>
<mrow>
<mn>1</mn>
<mo></mo>
<mi>β</mi>
</mrow>
<annotation encoding="application/x-tex">1-\beta</annotation>
</semantics>
</math>
<p><span aria-hidden="true">1β</span>):</p>
<math style="display: block">
<semantics>
<mrow>
<mi>n</mi>
<mo>=</mo>
<mfrac>
<mrow>
<mo stretchy="false">(</mo>
<mi>η</mi>
<mo>+</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
<mo stretchy="false">(</mo>
<msub>
<mi>Z</mi>
<mrow>
<mn>1</mn>
<mo></mo>
<mi>α</mi>
</mrow>
</msub>
<mo>+</mo>
<msub>
<mi>Z</mi>
<mrow>
<mn>1</mn>
<mo></mo>
<mi>β</mi>
</mrow>
</msub>
<msup>
<mo stretchy="false">)</mo>
<mn>2</mn>
</msup>
</mrow>
<msup>
<mi>f</mi>
<mn>2</mn>
</msup>
</mfrac>
</mrow>
<annotation encoding="application/x-tex">n =
\frac{{(\eta + 1)(Z_{1-\alpha} + Z_{1-\beta})^2}}{{f^2}}</annotation>
</semantics>
</math>
<p><span aria-hidden="true">n=f2(η+1)(Z1α+Z1β)2</span></p>
<p><strong>Trong đó:</strong></p>
<ul>
<li><math style="display: block">
<semantics>
<mrow>
<mi>n</mi>
</mrow>
<annotation encoding="application/x-tex">n</annotation>
</semantics>
</math><span aria-hidden="true">n</span>: Số mẫu cần thiết cho mỗi nhóm.
</li>
<li><math style="display: block">
<semantics>
<mrow>
<mi>η</mi>
</mrow>
<annotation encoding="application/x-tex">\eta</annotation>
</semantics>
</math><span aria-hidden="true">η</span>: Bậc tự do giữa các nhóm (<math
style="display: block">
<semantics>
<mrow>
<mi>η</mi>
<mo>=</mo>
<mi>k</mi>
<mo></mo>
<mn>1</mn>
</mrow>
<annotation encoding="application/x-tex">\eta = k - 1</annotation>
</semantics>
</math><span aria-hidden="true">η=k1</span>, với<math
style="display: block">
<semantics>
<mrow>
<mi>k</mi>
</mrow>
<annotation encoding="application/x-tex">k</annotation>
</semantics>
</math><span aria-hidden="true">k</span> là số nhóm).</li>
<li><math style="display: block">
<semantics>
<mrow>
<mi>f</mi>
</mrow>
<annotation encoding="application/x-tex">f</annotation>
</semantics>
</math><span aria-hidden="true">f</span>: Kích thước hiệu ứng chuẩn hóa:
<ul>
<li><math style="display: block">
<semantics>
<mrow>
<mi>f</mi>
<mo>=</mo>
<mn>0.1</mn>
</mrow>
<annotation encoding="application/x-tex">f = 0.1</annotation>
</semantics>
</math><span aria-hidden="true">f=0.1</span>: Hiệu ứng nhỏ.</li>
<li><math style="display: block">
<semantics>
<mrow>
<mi>f</mi>
<mo>=</mo>
<mn>0.25</mn>
</mrow>
<annotation encoding="application/x-tex">f = 0.25</annotation>
</semantics>
</math><span aria-hidden="true">f=0.25</span>: Hiệu ứng trung bình.</li>
<li><math style="display: block">
<semantics>
<mrow>
<mi>f</mi>
<mo>=</mo>
<mn>0.4</mn>
</mrow>
<annotation encoding="application/x-tex">f = 0.4</annotation>
</semantics>
</math><span aria-hidden="true">f=0.4</span>: Hiệu ứng lớn.</li>
</ul>
</li>
<li><math style="display: block">
<semantics>
<mrow>
<msub>
<mi>Z</mi>
<mrow>
<mn>1</mn>
<mo></mo>
<mi>α</mi>
</mrow>
</msub>
</mrow>
<annotation encoding="application/x-tex">Z_{1-\alpha}</annotation>
</semantics>
</math><span aria-hidden="true">Z1α</span>: Điểm tới hạn từ phân phối
chuẩn theo mức ý nghĩa<math style="display: block">
<semantics>
<mrow>
<mi>α</mi>
</mrow>
<annotation encoding="application/x-tex">\alpha</annotation>
</semantics>
</math><span aria-hidden="true">α</span>.</li>
<li><math style="display: block">
<semantics>
<mrow>
<msub>
<mi>Z</mi>
<mrow>
<mn>1</mn>
<mo></mo>
<mi>β</mi>
</mrow>
</msub>
</mrow>
<annotation encoding="application/x-tex">Z_{1-\beta}</annotation>
</semantics>
</math><span aria-hidden="true">Z1β</span>: Điểm tới hạn từ phân phối
chuẩn tương ứng với độ mạnh kiểm định.</li>
</ul>
<hr>
<h3><strong>3. Đặc biệt khi chỉ có 2 nhóm</strong></h3>
<p>Khi số nhóm</p>
<math style="display: block">
<semantics>
<mrow>
<mi>k</mi>
<mo>=</mo>
<mn>2</mn>
</mrow>
<annotation encoding="application/x-tex">k = 2</annotation>
</semantics>
</math>
<p><span aria-hidden="true">k=2</span>, kiểm định ANOVA trở thành <strong>kiểm
định t-test hai mẫu độc lập</strong>.<br>Trong trường hợp này, công thức
trên được đơn giản hóa thành:</p>
<math style="display: block">
<semantics>
<mrow>
<mi>n</mi>
<mo>=</mo>
<mfrac>
<mrow>
<mn>2</mn>
<mo stretchy="false">(</mo>
<msub>
<mi>Z</mi>
<mrow>
<mn>1</mn>
<mo></mo>
<mi>α</mi>
</mrow>
</msub>
<mo>+</mo>
<msub>
<mi>Z</mi>
<mrow>
<mn>1</mn>
<mo></mo>
<mi>β</mi>
</mrow>
</msub>
<msup>
<mo stretchy="false">)</mo>
<mn>2</mn>
</msup>
</mrow>
<msup>
<mi>f</mi>
<mn>2</mn>
</msup>
</mfrac>
</mrow>
<annotation encoding="application/x-tex">n =
\frac{{2(Z_{1-\alpha} + Z_{1-\beta})^2}}{{f^2}}</annotation>
</semantics>
</math>
<p><span aria-hidden="true">n=f22(Z1α+Z1β)2</span></p>
<p><strong>Nhận xét:</strong></p>
<ul>
<li>Nếu nghiên cứu của bạn luôn chỉ so sánh 2 nhóm, bạn nên sử dụng
<strong>kiểm định t-test hai mẫu độc lập</strong> để đơn giản hóa.</li>
<li>Tuy nhiên, nếu có khả năng mở rộng số lượng nhóm (nhiều hơn 2), kiểm định
ANOVA sẽ là phương pháp tổng quát hơn.</li>
</ul>
<hr>
<h3><strong>4. Hướng dẫn tính toán</strong></h3>
<h4><strong>Cách tính cỡ mẫu</strong></h4>
<p>Để tính cỡ mẫu cho kiểm định ANOVA, bạn cần cung cấp:</p>
<ol>
<li><strong>Kích thước hiệu ứng (</strong><math style="display: block">
<semantics>
<mrow>
<mi>f</mi>
</mrow>
<annotation encoding="application/x-tex">f</annotation>
</semantics>
</math><strong><span aria-hidden="true">f</span>)</strong>:
<ul>
<li><math style="display: block">
<semantics>
<mrow>
<mi>f</mi>
<mo>=</mo>
<mn>0.1</mn>
</mrow>
<annotation encoding="application/x-tex">f = 0.1</annotation>
</semantics>
</math><span aria-hidden="true">f=0.1</span>: Hiệu ứng nhỏ.</li>
<li><math style="display: block">
<semantics>
<mrow>
<mi>f</mi>
<mo>=</mo>
<mn>0.25</mn>
</mrow>
<annotation encoding="application/x-tex">f = 0.25</annotation>
</semantics>
</math><span aria-hidden="true">f=0.25</span>: Hiệu ứng trung bình.</li>
<li><math style="display: block">
<semantics>
<mrow>
<mi>f</mi>
<mo>=</mo>
<mn>0.4</mn>
</mrow>
<annotation encoding="application/x-tex">f = 0.4</annotation>
</semantics>
</math><span aria-hidden="true">f=0.4</span>: Hiệu ứng lớn.</li>
</ul>
</li>
<li><strong>Mức ý nghĩa (</strong><math style="display: block">
<semantics>
<mrow>
<mi>α</mi>
</mrow>
<annotation encoding="application/x-tex">\alpha</annotation>
</semantics>
</math><strong><span aria-hidden="true">α</span>)</strong>: Thường là 0.05.
</li>
<li><strong>Độ mạnh kiểm định (</strong><math style="display: block">
<semantics>
<mrow>
<mn>1</mn>
<mo></mo>
<mi>β</mi>
</mrow>
<annotation encoding="application/x-tex">1-\beta</annotation>
</semantics>
</math><strong><span aria-hidden="true">1β</span>)</strong>: Thường là 0.8
hoặc 0.9.</li>
<li><strong>Số nhóm (</strong><math style="display: block">
<semantics>
<mrow>
<mi>k</mi>
</mrow>
<annotation encoding="application/x-tex">k</annotation>
</semantics>
</math><strong><span aria-hidden="true">k</span>)</strong>: Nhập số nhóm cần
so sánh.</li>
</ol>
<h4><strong>Tổng cỡ mẫu</strong></h4>
<p>Tổng cỡ mẫu cho toàn bộ nghiên cứu được tính bằng:</p>
<math style="display: block">
<semantics>
<mrow>
<msub>
<mi>n</mi>
<mrow>
<mi>t</mi>
<mi>o</mi>
<mi>t</mi>
<mi>a</mi>
<mi>l</mi>
</mrow>
</msub>
<mo>=</mo>
<mi>n</mi>
<mo>×</mo>
<mi>k</mi>
</mrow>
<annotation encoding="application/x-tex">n_{total} = n \times k</annotation>
</semantics>
</math>
<p><span aria-hidden="true">ntotal=n×k</span></p>
<p>Với</p>
<math style="display: block">
<semantics>
<mrow>
<mi>n</mi>
</mrow>
<annotation encoding="application/x-tex">n</annotation>
</semantics>
</math>
<p><span aria-hidden="true">n</span> là số mẫu cần thiết cho mỗi nhóm, và</p>
<math style="display: block">
<semantics>
<mrow>
<mi>k</mi>
</mrow>
<annotation encoding="application/x-tex">k</annotation>
</semantics>
</math>
<p><span aria-hidden="true">k</span> là số nhóm.</p>
<hr>
<h3><strong>5. Ví dụ minh họa</strong></h3>
<h4><strong>Bài toán:</strong></h4>
<p>Bạn muốn kiểm tra sự khác biệt trung bình cân nặng giữa 3 nhóm trẻ em được bổ
sung dinh dưỡng ở mức độ khác nhau với:</p>
<ul>
<li>Kích thước hiệu ứng (<math style="display: block">
<semantics>
<mrow>
<mi>f</mi>
</mrow>
<annotation encoding="application/x-tex">f</annotation>
</semantics>
</math><span aria-hidden="true">f</span>) = 0.25 (hiệu ứng trung bình).</li>
<li>Mức ý nghĩa (<math style="display: block">
<semantics>
<mrow>
<mi>α</mi>
</mrow>
<annotation encoding="application/x-tex">\alpha</annotation>
</semantics>
</math><span aria-hidden="true">α</span>) = 0.05.</li>
<li>Độ mạnh kiểm định (<math style="display: block">
<semantics>
<mrow>
<mn>1</mn>
<mo></mo>
<mi>β</mi>
</mrow>
<annotation encoding="application/x-tex">1-\beta</annotation>
</semantics>
</math><span aria-hidden="true">1β</span>) = 0.8.</li>
<li>Số nhóm (<math style="display: block">
<semantics>
<mrow>
<mi>k</mi>
<mo>=</mo>
<mn>3</mn>
</mrow>
<annotation encoding="application/x-tex">k = 3</annotation>
</semantics>
</math><span aria-hidden="true">k=3</span>).</li>
</ul>
<h4><strong>Áp dụng công thức:</strong></h4>
<ol>
<li>
<p>Bậc tự do giữa các nhóm:</p>
<math style="display: block">
<semantics>
<mrow>
<mi>η</mi>
<mo>=</mo>
<mi>k</mi>
<mo></mo>
<mn>1</mn>
<mo>=</mo>
<mn>3</mn>
<mo></mo>
<mn>1</mn>
<mo>=</mo>
<mn>2</mn>
</mrow>
<annotation encoding="application/x-tex">\eta = k - 1 = 3 - 1 = 2
</annotation>
</semantics>
</math><span aria-hidden="true">η=k1=31=2</span>
</li>
<li>
<p>Tra bảng phân phối chuẩn:</p>
<ul>
<li><math style="display: block">
<semantics>
<mrow>
<msub>
<mi>Z</mi>
<mrow>
<mn>1</mn>
<mo></mo>
<mi>α</mi>
</mrow>
</msub>
<mo>=</mo>
<msub>
<mi>Z</mi>
<mn>0.95</mn>
</msub>
<mo>=</mo>
<mn>1.96</mn>
</mrow>
<annotation encoding="application/x-tex">Z_{1-\alpha} = Z_{0.95} =
1.96</annotation>
</semantics>
</math><span aria-hidden="true">Z1α=Z0.95=1.96</span>.</li>
<li><math style="display: block">
<semantics>
<mrow>
<msub>
<mi>Z</mi>
<mrow>
<mn>1</mn>
<mo></mo>
<mi>β</mi>
</mrow>
</msub>
<mo>=</mo>
<msub>
<mi>Z</mi>
<mn>0.8</mn>
</msub>
<mo>=</mo>
<mn>0.84</mn>
</mrow>
<annotation encoding="application/x-tex">Z_{1-\beta} = Z_{0.8} =
0.84</annotation>
</semantics>
</math><span aria-hidden="true">Z1β=Z0.8=0.84</span>.</li>
</ul>
</li>
<li>
<p>Tính cỡ mẫu cho mỗi nhóm:</p>
<math style="display: block">
<semantics>
<mrow>
<mi>n</mi>
<mo>=</mo>
<mfrac>
<mrow>
<mo stretchy="false">(</mo>
<mi>η</mi>
<mo>+</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
<mo stretchy="false">(</mo>
<msub>
<mi>Z</mi>
<mrow>
<mn>1</mn>
<mo></mo>
<mi>α</mi>
</mrow>
</msub>
<mo>+</mo>
<msub>
<mi>Z</mi>
<mrow>
<mn>1</mn>
<mo></mo>
<mi>β</mi>
</mrow>
</msub>
<msup>
<mo stretchy="false">)</mo>
<mn>2</mn>
</msup>
</mrow>
<msup>
<mi>f</mi>
<mn>2</mn>
</msup>
</mfrac>
</mrow>
<annotation encoding="application/x-tex">n =
\frac{{(\eta + 1)(Z_{1-\alpha} + Z_{1-\beta})^2}}{{f^2}}</annotation>
</semantics>
</math><span aria-hidden="true">n=f2(η+1)(Z1α+Z1β)2</span><math
style="display: block">
<semantics>
<mrow>
<mi>n</mi>
<mo>=</mo>
<mfrac>
<mrow>
<mo stretchy="false">(</mo>
<mn>2</mn>
<mo>+</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
<mo stretchy="false">(</mo>
<mn>1.96</mn>
<mo>+</mo>
<mn>0.84</mn>
<msup>
<mo stretchy="false">)</mo>
<mn>2</mn>
</msup>
</mrow>
<mrow>
<mn>0.2</mn>
<msup>
<mn>5</mn>
<mn>2</mn>
</msup>
</mrow>
</mfrac>
<mo>=</mo>
<mfrac>
<mrow>
<mn>3</mn>
<mo>×</mo>
<mn>7.84</mn>
</mrow>
<mn>0.0625</mn>
</mfrac>
<mo>=</mo>
<mfrac>
<mn>23.52</mn>
<mn>0.0625</mn>
</mfrac>
<mo>=</mo>
<mn>376.32</mn>
</mrow>
<annotation encoding="application/x-tex">n =
\frac{{(2 + 1)(1.96 + 0.84)^2}}{{0.25^2}} =
\frac{{3 \times 7.84}}{{0.0625}} = \frac{{23.52}}{{0.0625}} = 376.32
</annotation>
</semantics>
</math><span
aria-hidden="true">n=0.252(2+1)(1.96+0.84)2=0.06253×7.84=0.062523.52=376.32</span>
</li>
<li>
<p>Tổng cỡ mẫu:</p>
<math style="display: block">
<semantics>
<mrow>
<msub>
<mi>n</mi>
<mrow>
<mi>t</mi>
<mi>o</mi>
<mi>t</mi>
<mi>a</mi>
<mi>l</mi>
</mrow>
</msub>
<mo>=</mo>
<mi>n</mi>
<mo>×</mo>
<mi>k</mi>
<mo>=</mo>
<mn>376.32</mn>
<mo>×</mo>
<mn>3</mn>
<mo>=</mo>
<mn>1129</mn>
</mrow>
<annotation encoding="application/x-tex">n_{total} = n \times k = 376.32
\times 3 = 1129</annotation>
</semantics>
</math><span aria-hidden="true">ntotal=n×k=376.32×3=1129</span>
</li>
</ol>
<h4><strong>Kết luận:</strong></h4>
<p>Cần ít nhất <strong>376 mẫu cho mỗi nhóm</strong> và tổng cộng <strong>1129
mẫu</strong> cho cả nghiên cứu.</p>
<hr>
<h3><strong>6. Công cụ tính toán bằng R</strong></h3>
<p>Bạn có thể tính cỡ mẫu cho kiểm định ANOVA bằng hàm
<code>pwr.anova.test</code> trong R:</p>
<div>
<div>R</div>
<div>
<div>
<div><svg>
<path fill-rule="evenodd" clip-rule="evenodd"
d="M7 5C7 3.34315 8.34315 2 10 2H19C20.6569 2 22 3.34315 22 5V14C22 15.6569 20.6569 17 19 17H17V19C17 20.6569 15.6569 22 14 22H5C3.34315 22 2 20.6569 2 19V10C2 8.34315 3.34315 7 5 7H7V5ZM9 7H14C15.6569 7 17 8.34315 17 10V15H19C19.5523 15 20 14.5523 20 14V5C20 4.44772 19.5523 4 19 4H10C9.44772 4 9 4.44772 9 5V7ZM5 9C4.44772 9 4 9.44772 4 10V19C4 19.5523 4.44772 20 5 20H14C14.5523 20 15 19.5523 15 19V10C15 9.44772 14.5523 9 14 9H5Z"
fill="currentColor"></path>
</svg><span data-state="closed"><button>Sao chép mã</button></span>
</div>
</div>
</div>
<div dir="ltr"><code>library(pwr)
pwr.anova.test(k = 3, f = 0.25, sig.level = 0.05, power = 0.8)
</code></div>
</div>
<p>Kết quả trả về:</p>
<ul>
<li>Số mẫu cần thiết cho mỗi nhóm (<math style="display: block">
<semantics>
<mrow>
<mi>n</mi>
</mrow>
<annotation encoding="application/x-tex">n</annotation>
</semantics>
</math><span aria-hidden="true">n</span>).</li>
<li>Tổng số mẫu nếu bạn nhân với số nhóm (<math style="display: block">
<semantics>
<mrow>
<mi>k</mi>
</mrow>
<annotation encoding="application/x-tex">k</annotation>
</semantics>
</math><span aria-hidden="true">k</span>).</li>
</ul>
<p dir="ltr" style="text-align: left;"></p>
</body>
</html>