# Lecture 2

A p-value is the probability you would get the results you got or more extreme results if the null hypothesis is true. For our current example, if self-esteem boosting measure had NO EFFECT (the null hypothesis), then the scores that were obtained in the treatment and control groups should have arisen by a chance assignment of the pooled scores.

Recall that the data are:
Treatment Control
10 5
15 9
16 10
16 10
17 14
19 18
20 20

The difference in mean scores in the observed data is 3.85.

We can intuitively explore whether this difference is likely due to chance by

1. Pooling the data
2. Randomly assigning the data to treatment and control (1000 times)
3. Calculating the difference for each random assignment
4. Determining the proportion of times the difference obtained by random assignment exceeds the actual difference obtained by the data
To do any proceedure 1000 times, it is useful to be able to write a little code. You just need to be able to repeat what you can do once. To see the written commands, click on the session window, go to Editor and click on Enable Commands. To do this proceedure once using the pre-programmed menu items, we:
1. Stack the data and the lables (Data > Stack > Columns)
2. Randomize the labels (Calc > Random Data > Sample from Columns)
3. Unstack using the new lables (Data > Unstack Columns...)
4. Calculate the difference of the randomized data (Calc > Calculator)
The Minitab code is the following:
```MTB > Stack 'Treatment' 'Control' c3;
SUBC>   Subscripts c4;
SUBC>   UseNames.
MTB > Sample 14 C4 c5.
MTB > Unstack (C3);
SUBC>   Subscripts C5;
SUBC>   After;
SUBC>   VarNames.
MTB > let c8(1) = mean(c6) - mean(c7)
```
In order not to use up unecessary space, it is useful to know the following modification so that you unstack into the same columns each time:
```MTB > Sample 14 C4 c5.
MTB > Unstack c3 c6 c7;
SUBC>   Subscripts C5;
SUBC>   VarNames.
MTB > let c8(2) = mean(c6) - mean(c7)
```
Now we have the basis for writing a Macro (saved as Randomize.MAC):
```GMACRO
Randomize

Do k1 = 1:100

Sample 14 C4 c5.
Unstack c3 c6 c7;
Subscripts C5;
VarNames.
let c8(k1) = mean(c6) - mean(c7)

ENDDO

ENDMACRO
```

```MTB >  %Randomize