﻿ VisualStat® Examples - Two-Sample t-Test  Software to Simplify Statistical Practice ...

Two-Sample t-Test - Example

Analysis

1. Open the DataBook auto83b.vstz
open this data file via the Help / Open Examples menu; it is in the Sample Data
2. Choose the menu Analyze and the command Two t-Test, under group Basic Statistics
3. In Variables 1, select US
4. In Variables 2, select Japan
5. Check the box Assume Equal Variances.
6. Click OK Output

By default, R code is printed after parsing and before evaluation.

DataSheet is converted to DataFrame, in the form DataBook.DataSheet

> ## Summary Statistics:
> summary.vst(auto83b.Sheet1[,c('US','Japan')], statistics = c('mean','semean',
'sd','nobs'))
nobs     mean       sd    semean
US     249 20.14458 6.414699 0.4065151
Japan   79 30.48101 6.107710 0.6871711

> ## Perform two sample t-test:
> .res <- t.test(auto83b.Sheet1\$US, auto83b.Sheet1\$Japan, alternative = 'two.sided',
mu = 0, conf.level = 0.95, paired = FALSE, var.equal = TRUE)
> .res

Two Sample t-test

data:  auto83b.Sheet1\$US and auto83b.Sheet1\$Japan
t = -12.6206, df = 326, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-11.947653  -8.725216
sample estimates:
mean of x mean of y
20.14458  30.48101

> ## Find two-tailed critical values:
> qt(0.975,.res\$parameter)
 1.967268

Results

The absolute value of the test statistic for our example, 12.62059, is greater than the critical value of 1.9673, so we reject the null hypothesis and conclude that the two population means are different at the 0.05 significance level.