# 建立一般 t-test 報表

一般的學生 t-test 報表可能包含具有 Group Statistics 和 Independent Samples Test 結果的表格。以下章節中將使用套用到兩個獨立樣本群組 Observation 和 Comparison 的 QlikViewt-test 函數，進而建置三個表格。這些樣本的對應表格看起來應像這樣：

Group Statistics

群組統計資料範例表格輸出

| Type | N | Mean | Standard Deviation | Standard Error Mean |
| --- | --- | --- | --- | --- |
| Comparison | 20 | 11.95 | 14.61245 | 3.2674431 |
| Observation | 20 | 27.15 | 12.507997 | 2.7968933 |

Independent Sample Test

獨立樣本測試範例表格輸出

| - | t | df | Sig. (2-tailed) | Mean Difference | Standard Error Difference | 95% Confidence Interval of the Difference (Lower) | 95% Confidence Interval of the Difference (Upper) |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Equal Variance not Assumed | 3.534 | 37.116717335823 | 0.001 | 15.2 | 4.30101 | 6.48625 | 23.9137 |
| Equal Variance Assumed | 3.534 | 38 | 0.001 | 15.2 | 4.30101 | 6.49306 | 23.9069 |

## 載入樣本資料

請執行下列動作：

1. 建立新的文件。

2. 選取工具列中的編輯指令碼，然後將以下內容輸入指令碼：

   `Table1:` `crosstable LOAD recno() as ID, * inline [` `Observation|Comparison` `35|2` `40|27` `12|38` `15|31` `21|1` `14|19` `46|1` `10|34` `28|3` `48|1` `16|2` `30|3` `32|2` `48|1` `31|2` `22|1` `12|3` `39|29` `19|37` `25|2 ] (delimiter is '|');`

   此載入指令碼中包含 recno()，因為 crosstable 需要三個引數。因此 recno() 只需提供一個額外引數，在這種情況下，每列需要一個識別碼。若沒有，則不會載入 Comparison 樣本值。

3. 儲存指令碼，並按一下重新載入以載入資料。

## 建立 Group Statistics 表格

請執行下列動作：

1. 在工作表上新增一個連續表，並選取 Type 作為維度。

2. 新增以下運算式：

   要新增的運算式

   | 標籤 | 運算式 |
   | --- | --- |
   | N | Count(Value) |
   | Mean | Avg(Value) |
   | Standard Deviation | Stdev(Value) |
   | Standard Error Mean | Sterr(Value) |

3. 確認 Type 位於排序清單頂端。

**結果：**

這些樣本的 Group Statistics 表格看起來應像這樣：

群組統計資料範例表格輸出

| Type | N | Mean | Standard Deviation | Standard Error Mean |
| --- | --- | --- | --- | --- |
| Comparison | 20 | 11.95 | 14.61245 | 3.2674431 |
| Observation | 20 | 27.15 | 12.507997 | 2.7968933 |

## 建立 Two Independent Sample Student's T-test 表格

請執行下列動作：

1. 在工作表上新增一個表格。

2. 將以下計算維度作為維度新增至表格。 `=ValueList (Dual('Equal Variance not Assumed', 0), Dual('Equal Variance Assumed', 1))`

3. 新增以下運算式：

   要新增的運算式

   | 標籤 | 運算式 |
   | --- | --- |
   | conf | if(ValueList (Dual('Equal Variance not Assumed', 0), Dual('Equal Variance Assumed', 1)),TTest\_conf(Type, Value),TTest\_conf(Type, Value, 0)) |
   | t | if(ValueList (Dual('Equal Variance not Assumed', 0), Dual('Equal Variance Assumed', 1)),TTest\_t(Type, Value),TTest\_t(Type, Value, 0)) |
   | df | if(ValueList (Dual('Equal Variance not Assumed', 0), Dual('Equal Variance Assumed', 1)),TTest\_df(Type, Value),TTest\_df(Type, Value, 0)) |
   | Sig. (2-tailed) | if(ValueList (Dual('Equal Variance not Assumed', 0), Dual('Equal Variance Assumed', 1)),TTest\_sig(Type, Value),TTest\_sig(Type, Value, 0)) |
   | Mean Difference | TTest\_dif(Type, Value) |
   | Standard Error Difference | if(ValueList (Dual('Equal Variance not Assumed', 0), Dual('Equal Variance Assumed', 1)),TTest\_sterr(Type, Value),TTest\_sterr(Type, Value, 0)) |
   | 95% Confidence Interval of the Difference (Lower) | if(ValueList (Dual('Equal Variance not Assumed', 0), Dual('Equal Variance Assumed', 1)),TTest\_lower(Type, Value,(1-(95)/100)/2),TTest\_lower(Type, Value,(1-(95)/100)/2, 0)) |
   | 95% Confidence Interval of the Difference (Upper) | if(ValueList (Dual('Equal Variance not Assumed', 0), Dual('Equal Variance Assumed', 1)),TTest\_upper(Type, Value,(1-(95)/100)/2),TTest\_upper(Type, Value,(1-(95)/100)/2, 0)) |

**結果：**

這些樣本的 Independent Sample Test 表格看起來應像這樣：

獨立樣本測試範例表格輸出

| - | t | df | Sig. (2-tailed) | Mean Difference | Standard Error Difference | 95% Confidence Interval of the Difference (Lower) | 95% Confidence Interval of the Difference (Upper) |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Equal Variance not Assumed | 3.534 | 37.116717335823 | 0.001 | 15.2 | 4.30101 | 6.48625 | 23.9137 |
| Equal Variance Assumed | 3.534 | 38 | 0.001 | 15.2 | 4.30101 | 6.49306 | 23.9069 |