# 创建典型的 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() 仅提供额外参数，在这种情况下提供每一行的 ID。如果不使用此函数，则不会加载 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 |