# Sampling survey
小補充 :
$SRSWOR$ 是 隨機抽出不放回(Simple Random Sample Without Replacement)
$SRSWR$ 是 隨機抽出放回(Simple Random Sample With Replacement)
## Part 1. 基礎統計量計算
首先會先分成 SRSWOR 或是 SRSWR
因為計算時會有些許差異
### SRSWOR
求出母體均數( $\overline{Y}$ ),以及母體變異數 ($\sigma^2,\ S^2$)
$\begin{aligned}
\Rightarrow
& \overline{Y} = \cfrac{\Sigma^N \ y_i}{N} \\
& \sigma^2 = \cfrac{\Sigma^N \ (y_i - \overline{Y})^2}{N} \\
& S^2 = \cfrac{\Sigma^N \ (y_i - \overline{Y})^2}{N-1}
\end{aligned}$
分別列出樣本均數( $\overline{y}$ ),樣本變異數( $s^2$ )
$\begin{aligned}
\Rightarrow
& \overline{y} = \cfrac{\Sigma^n \ y_i}{n} \\
& s^2 = \cfrac{\Sigma^n \ (y_i - \overline{y})^2}{n-1}
\end{aligned}$
一些重要觀念 :
$E(\overline{y}) = \overline{Y}$
$E(s^2) = S^2$
$\begin{aligned}
V(\overline{y})
&= \cfrac{1-f}{n} \cdot S^2,\ f = \cfrac{n}{N} \\
&= E( \ \overline{y}^2 \ ) - \left[\ E(\overline{y}) \ \right]^2
\end{aligned}$
判斷是否是 unbiased(不偏) :
$\overline{Y} - E(\overline{y}) = 0 \Rightarrow unbiased$
---
下方是例題 :
:::spoiler
**題目給定 :**
$N = 3$,母體 : $\left\{ 5,\ 7,\ 9 \right\},\ n = 2,\ SRSWOR$
求出 :
(1) $\overline{y},\ unbias?$
(2) $s^2,\ \text{prove } E(s^2) = S^2?$
(3) $\text{prove } V(\overline{y}) = \cfrac{1-f}{n} \cdot S^2?$
**解法 :**
首先把已知的樣本估計做成表格 :
| $y_i$ | $(5, 7)$ | $(5, 9)$ | $(7, 9)$ |
| ----------------- |:------------------------------------ | ------------------------------------ |:------------------------------------ |
| $\overline{y_i}$ | $6$ | $7$ | $8$ |
| $P(\overline{y})$ | $\cfrac{1}{3}$ | $\cfrac{1}{3}$ | $\cfrac{1}{3}$ |
| $s^2$ | $\cfrac{(5-6)^2 + (7-6)^2}{2-1} = 2$ | $\cfrac{(5-7)^2 + (9-7)^2}{2-1} = 8$ | $\cfrac{(7-8)^2 + (9-8)^2}{2-1} = 2$ |
接著計算出一些基本會用到的值 :
$\overline{Y} = \cfrac{5+7+9}{3} = 7$
$S^2 = \cfrac{(5-7)^2 + (7-7)^2 + (9-7)^2}{3-1} = 4$
$\begin{aligned}
V(\overline{y}) &= E(\overline{y}^2) - (E(\overline{y}))^2 \\
&= \cfrac{1}{3} \times (6^2 + 7^2 + 8^2) - (\cfrac{1}{3}\times (6 + 7 + 8))^2 = \cfrac{2}{3}
\end{aligned}$
最後就可以開始解上述題目
(1)
$E(\overline{y}) = \cfrac{6+7+8}{3} = 7$
又 $\because \overline{Y} - E(\overline{y}) = 7-7 = 0$
$\therefore unbias$
(2)
$s^2$ 已經在表格中顯示
$E(s^2) = \cfrac{1}{3} \cdot 2 + \cfrac{1}{3} \cdot 8 + \cfrac{1}{3} \cdot 2 = 4$
$\therefore E(s^2) = 4 = S^2$ 得証
(3)
$\because \cfrac{1-f}{n} \cdot S^2 = \cfrac{1-\frac{2}{3}}{2} \cdot \cfrac{1}{4} = \cfrac{2}{3}$
$\therefore V(\overline{y}) = \cfrac{2}{3} = \cfrac{1-f}{n} \cdot S^2$ 得証
:::
### SRSWR
求出母體均數( $\overline{Y}$ ),以及母體變異數 ($\sigma^2,\ S^2$)
$\begin{aligned}
\Rightarrow
& \overline{Y} = \cfrac{\Sigma^N \ y_i}{N} \\
& \sigma^2 = \cfrac{\Sigma^N \ (y_i - \overline{Y})^2}{N} \\
& S^2 = \cfrac{\Sigma^N \ (y_i - \overline{Y})^2}{N-1}
\end{aligned}$
分別列出樣本均數( $\overline{y}$ ),樣本變異數( $s^2$ )
$\begin{aligned}
\Rightarrow
& \overline{y} = \cfrac{\Sigma^n \ y_i}{n} \\
& s^2 = \cfrac{\Sigma^n \ (y_i - \overline{y})^2}{n-1}
\end{aligned}$
一些重要觀念 :
$E(\overline{y}) = \overline{Y}$
$E(s^2) = \sigma^2$
$V(\overline{y}) = \cfrac{\sigma^2}{n}$
判斷是否是 unbiased(不偏) :
$\overline{Y} - E(\overline{y}) = 0 \Rightarrow unbiased$
---
下方是例題 :
:::spoiler
**題目給定 :**
$N = 3$,母體 : $\left\{ 5,\ 7,\ 9 \right\},\ n = 2,\ SRSWR$
求出 :
(1) $\overline{y},\ unbias?$
(2) $s^2,\ \text{prove } E(s^2) = \sigma^2?$
(3) $\text{prove } V(\overline{y}) = \cfrac{\sigma^2}{n}?$
**解法 :**
首先把已知的樣本估計做成表格 :
| $y_i$ | $(5, 5)$ | $(5, 7)$ | $(5, 9)$ | $(7, 7)$ | $(7, 9)$ | $(9, 9)$ |
| ----------------- |:------------------------------------ | -------------- |:-------------- | -------------- | -------------- | -------------- |
| $\overline{y_i}$ | $5$ | $6$ | $7$ | $7$ | $8$ | $9$ |
| $P(\overline{y})$ | $\cfrac{1}{9}$ | $\cfrac{2}{9}$ | $\cfrac{2}{9}$ | $\cfrac{1}{9}$ | $\cfrac{2}{9}$ | $\cfrac{1}{9}$ |
| $s^2$ | $\cfrac{(5-5)^2 + (5-5)^2}{2-1} = 0$ | $2$ | $8$ | $0$ | $2$ | $0$ |
接著計算出一些基本會用到的值 :
$\overline{Y} = \cfrac{5+7+9}{3} = 7$
$\sigma^2 = \cfrac{(5-7)^2 + (7-7)^2 + (9-7)^2}{3} = \cfrac{8}{3}$
$\begin{aligned}
V(\overline{y}) &= E(\overline{y}^2) - (E(\overline{y}))^2 \\
&= \left[\ \cfrac{1}{9} \times (5^2 + 7^2 + 9^2) + \cfrac{2}{9} \times (6^2 + 7^2 + 8^2) \ \right] - \left[\ 7 \ \right]^2 = \cfrac{4}{3}
\end{aligned}$
最後就可以開始解上述題目
(1)
$E(\overline{y}) = \cfrac{1}{9} \times (5 + 7 + 9) + \cfrac{2}{9} \times (6 + 7 + 8) = 7$
又 $\because \overline{Y} - E(\overline{y}) = 7-7 = 0$
$\therefore unbias$
(2)
$s^2$ 已經在表格中顯示
$E(s^2) = \cfrac{2}{9} \cdot 2 + \cfrac{2}{9} \cdot 8 + \cfrac{2}{9} \cdot 2 = \cfrac{8}{3}$
$\therefore E(s^2) = \cfrac{8}{3} = \sigma^2$ 得証
(3)
$\because \cfrac{\sigma^2}{n} = \cfrac{3/8}{2} = \cfrac{4}{3}$
$\therefore V(\overline{y}) = \cfrac{4}{3} = \cfrac{\sigma^2}{n}$ 得証
:::
## Part 2. 估計比例差&其信賴區間
估計比例差,並列出 95% 信賴區間(CI)
$P_1 - P_2 = \cfrac{x_1}{n_1} - \cfrac{x_2}{n_2}$
接著就可以求出信賴區間 :
$se(P_1 - P_2) = \sqrt{V(P_1 - P_2)}$
$95\% \ CI : (P_1 - P_2) \pm 2 \times se(P_1 - P_2)$
除此之外,當這個 CI 包含 $0$ 的話,就代表**沒有顯著差異**
但計算 $V(P_1 - P_2)$ 有 2 個不同算法,使用時機有差異
$\begin{cases}
i. 不同\color{red}{組別}之間的比較 : V(P_1 - P_2) = \cfrac{p_1 \cdot q_1}{n_1} + \cfrac{p_2 \cdot q_2}{n_2} \\
ii. 不同\color{red}{選項}之間的比較 : V(P_1 - P_2) = \cfrac{1}{n} \cdot (p_1 \cdot q_1 + p_2 \cdot q_2 + 2 \cdot p_1 \cdot p_2) \\
\end{cases}$
---
下方是例題 :
:::spoiler
**題目給定 :**
| 次數 | 男性(M) | 女性(F) | 合計 |
| --------- |:------- |:------- |:---- |
| 贊成(1) | 180 | 240 | 420 |
| 不贊成(2) | 160 | 300 | 460 |
| 沒意見(3) | 60 | 60 | 120 |
| 合計 | 400 | 600 | 1000 |
$n = 1000,\ n_M = 400,\ n_F =600$
(1) 估計男性與女性贊成的比例差($P_M - P_F$),列出 $95\% CI$,並說明有無顯著差異
(2) 估計女性中贊成與不贊成的比例差($P_1 - P_2$),列出 $95\% CI$,並說明有無顯著差異
**解法 :**
(1)
可以先看出重點是比較 *男性、女性* 的贊成數
因此使用第 1 個公式(**組別**)
$P_M - P_F = \cfrac{180}{400} - \cfrac{240}{600} = 0.05$
$V(P_M - P_F) = \cfrac{\frac{180}{400} \cdot \frac{220}{400}}{400} + \cfrac{\frac{240}{600} \cdot \frac{360}{600}}{600} = 0.0062 + 0.0004 = 0.0012$
$se(P_M - P_F) = \sqrt{V(P_M - P_F)} = \sqrt{0.0012} = 0.03464$
$\therefore 95\%CI : 0.05 \pm (2 \times 0.03464) = 0.05 \pm 0.06928$
又 $\because$ 區間包含 $0 \Rightarrow$ 無顯著差異
(2)
可以先看出重點是比較女性中的 *贊成、不贊成*
因此使用第 2 個公式(**選項**)
$P_1 - P_2 = \cfrac{240}{600} - \cfrac{300}{600} = -0.1$
$V(P_1 - P_2) = \cfrac{1}{600} \cdot (\cfrac{240}{600} \cdot \cfrac{360}{600} + \cfrac{300}{600} \cdot \cfrac{300}{600} + 2 \cdot \cfrac{240}{600} \cdot \cfrac{300}{600}) = 0.00148$
$se(P_1 - P_2) = \sqrt{V(P_M - P_F)} = \sqrt{0.00148} = 0.03847$
$\therefore 95\%CI : -0.1 \pm (2 \times 0.03847) = -0.1 \pm 0.07694$
又 $\because$ 區間不包含 $0 \Rightarrow$ 有顯著差異
:::
## Part 3. 計算估計量
總共有 3 種估計量
* 比率估計量(ratio estimator, $\overline{y}_R$)
估計平均($\overline{Y}$),標準誤($se(\overline{y}_R)$)
$\Rightarrow \hat{R} = \cfrac{\overline{y}}{\overline{x}},\ \overline{y}_R = \hat{R} \cdot \overline{X} = \overline{Y}$
$\Rightarrow se(\overline{y}_R) = \sqrt{V(\overline{y}_R)} = \sqrt{\cfrac{N-n}{N \cdot n} \cdot (s_y^2 + \hat{R}^2 \cdot s_x^2 - 2 \cdot \hat{R} \cdot s_{xy})}$
* 回歸估計量(regression estimator, $\overline{y}_{lr}$)
估計平均($\overline{Y}$),標準誤($se(\overline{y}_{lr})$)
$\Rightarrow \overline{y}_{lr} = \overline{y} + \cfrac{s_{xy}}{s_x^2} \cdot (\overline{X} - \overline{x})$
$\Rightarrow se(\overline{y}_{lr}) = \sqrt{V(\overline{y}_{lr})} = \sqrt{\cfrac{N-n}{N \cdot n} \cdot s_y^2 \cdot (1-(\cfrac{s_{xy}}{s_x \cdot s_y})^2) \cdot (\cfrac{n-1}{n-2})}$
* 單位估計量(mean per unit estimator, $\overline{y}$)
$\overline{y} = \cfrac{\Sigma\ y_i}{n}$
$V(\overline{y}) = \cfrac{N-n}{N \cdot n} \cdot s_y^2$
* 計算上述估計量的相對效率(relative efficiency)
$\hat{RE}(\cfrac{\overline{y}_R}{\overline{y}_{lr}}) = \cfrac{V(\overline{y}_{lr})}{V(\overline{y}_R)},\ if >1 \Rightarrow \overline{y}_R \text{ better}$
以此類推
(也可以看標準誤越小越好)
:::success
補充 :
* $s_{y}^2 = \cfrac{\Sigma\ y_i^2 - n \cdot (\frac{\Sigma\ y_i}{n})^2}{n-1}$
* $s_{x}^2 = \cfrac{\Sigma\ x_i^2 - n \cdot (\frac{\Sigma\ x_i}{n})^2}{n-1}$
* $s_{xy} = \cfrac{\Sigma\ xy - n \cdot (\frac{\Sigma\ x_i}{n})(\frac{\Sigma\ y_i}{n})}{n-1}$
:::
---
下方是例題 :
:::spoiler
**題目給定 :**
$N = 600,\ n = 60,\ \overline{X} = 20,\ \Sigma_1^{60} x = 900,\ \Sigma_1^{60} y = 1350,\ s_x^2 = 3600,\ s_y^2 = 6400,\ s_{xy} = 4320$
求出上述 $\overline{y}_{R},\ \overline{y}_{lr},\ V(\overline{y}),\ V(\overline{y}_{R}),\ V(\overline{y}_{lr})$
並且計算出相對效率以及比較分析其精確度
**解法 :**
首先可以先做出 $\overline{x},\ \overline{y},\ \hat{R}$
$\overline{x} = \cfrac{\Sigma_1^{60} x}{60} = \cfrac{900}{60} = 15$
$\overline{y} = \cfrac{\Sigma_1^{60} y}{60} = \cfrac{1350}{60} = 22.5$
$\hat{R} = \cfrac{\overline{y}}{\overline{x}} = \cfrac{22.5}{15} = 1.5$
接著就可以計算出
$\overline{y}_{R} = \hat{R} \cdot \overline{X} = 1.5 \cdot 20 = 30$
$\begin{aligned}
\overline{y}_{lr} &= \overline{y} + \cfrac{s_{xy}}{s_x^2} \cdot (\overline{X} - \overline{x}) \\
&=22.5 + \cfrac{4320}{3600} \cdot (20-15) = 28.5
\end{aligned}$
$V(\overline{y}) = \cfrac{600 - 60}{600 \cdot 60} \cdot s_y^2 = \cfrac{540}{36000} \cdot 6400 = 96$
$V(\overline{y}_{R}) = \cfrac{600 - 60}{600 \cdot 60} \cdot (s_y^2 + \hat{R}^2 \cdot s_x^2 - 2 \cdot \hat{R} \cdot s_{xy}) = 23.1$
$\begin{aligned}
V(\overline{y}_{lr}) &= \cfrac{600 - 60}{600 \cdot 60} \cdot s_y^2 \cdot (1-(\cfrac{s_{xy}}{s_x \cdot s_y})^2) \cdot (\cfrac{n-1}{n-2}) \\
&= \cfrac{540}{36000} \cdot 6400 \cdot (1-(\cfrac{4320}{60 \cdot 80})^2) \cdot (\cfrac{60-1}{60-2}) = 18.55
\end{aligned}$
最後就可以比較他們之間的相對效率&精確度
$\hat{RE}(\cfrac{\overline{y}_R}{\overline{y}}) = \cfrac{V(\overline{y})}{V(\overline{y}_R)} = \cfrac{96}{23.1},\ >1 \Rightarrow \overline{y}_R \text{ better}$
$\hat{RE}(\cfrac{\overline{y}_{lr}}{\overline{y}}) = \cfrac{V(\overline{y})}{V(\overline{y}_{lr})} = \cfrac{96}{18.55},\ >1 \Rightarrow \overline{y}_{lr} \text{ better}$
$\hat{RE}(\cfrac{\overline{y}_R}{\overline{y}_{lr}}) = \cfrac{V(\overline{y}_{lr})}{V(\overline{y}_R)} = \cfrac{18.55}{23.1},\ <1 \Rightarrow \overline{y}_{lr} \text{ better}$
$\therefore \text{precision : } \overline{y}_{lr} > \overline{y}_{R} > \overline{y}$
:::
## Part 4. 估計樣本大小
估計樣本大小,總共有 2 種估計法
* 估計母體**比例** :
通常題目會提到 : 支持率、比例介在...之間
$P(|p-P| \le d) = 1 - \alpha$
$n_0 = \cfrac{t^2 \cdot P \cdot Q}{d^2}$
通常 $t = 2,\ P$ 會取最接近 $50\%$ 的$,\ Q = 1-P,\ d$ 為題目給定(通常會是 $3$)
最終計算出樣本大小 $n$
$n \ge \cfrac{n_0}{1 - \frac{1}{N} + \frac{n_0}{N}}$
最後是把 $n$ 無條件進位
* 估計母體**均數** :
通常題目會提到 : 在平均$(\overline{Y})$ 的 $5\%$ 內,這樣就代表求出 $95\% \ CI$
$P(|\overline{y}-\overline{Y}| \le d) = 1 - \alpha$
$n_0 = \cfrac{t^2 \cdot S^2}{d^2}$
通常 $t = 2,\ S$ 是標準差$,\ d$ 為題目給定(通常會是 $0.05$)
最終計算出樣本大小 $n$
$n \ge \cfrac{n_0}{1 + \frac{n_0}{N}}$
最後是把 $n$ 無條件進位
最終選取樣本大小時,應該採用這 2 種方法的最大值
---
下方是例題 :
:::spoiler
**題目給定 :**
$N = 1000,\ S = 20,\ P = 65\% \sim 85\%,\ CI : 95\%$
精確度要求 : $P(|p-P| \le 0.03) = 0.95,\ P(|\overline{y}-\overline{Y}| \le 2.5) = 0.95$
**解法 :**
首先先做估計母體比例 :
$P(|p-P| \le 0.03) = 0.95$
$d = 0.03,\ P$ 取 $0.65$ (因為最接近 $50\%$)
$\Rightarrow n_0 = \cfrac{2^2 \cdot 0.65 \cdot (1-0.65)}{(0.03)^2} = 1011.11$
$\Rightarrow n = \cfrac{1011.11}{1 - \frac{1}{1000} + \frac{1011.11}{1000}} = 503.0127$
無條件進位取 $n = 504$
接著做估計母體均數 :
$P(|\overline{y}-\overline{Y}| \le 2.5) = 0.95$
$d = 2.5$
$\Rightarrow n_0 = \cfrac{2^2 \cdot 20^2}{(2.5)^2} = 256$
$\Rightarrow n = \cfrac{256}{1 + \frac{256}{1000}} = 203.82$
無條件進位取 $n = 204$
最終得到答案 $max(504,\ 204) = 504$
:::