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

Advice: Until you debug your macros, keep your DO loops small. You must save your minitab project and your minitab macro in the same folder.

Your run the macro by issuing the command:

MTB >  %Randomize
Let's do it with 1000 (if it works with 100). Then we sort the difference we get by randomizing the data, count the number greater than or equal to 3.85, and figure out the proportion of times randomizing the results would give us a difference greater than the one we got with the actual data. This is one way of obtaining an intuitive p-value.