Andreas Krause, José Pinheiro:
Modeling and Simulation to adjust p-values in Presence of a Regression to the Mean Effect
The American Statistician, Vol. 61, No. 4 (November 2007), pp.302-307.

This web page contains material to supplement the publication.
The publication itself is available online at the AmStat web page. We have implemented the algorithm described in the paper (based on the paired t-test) in S-Plus and R. The figures shown in the paper were generated using S-Plus.
In addition, the SAS code was kindly provided by Eugene Komaroff (thank you!).

The algorithm steps are:

A subgroup of the (simulated) data set is selected.
A paired t-test is carried out that produces p-values with an inherent regression to the mean effect.
These values are adjusted by the procedure described in the paper. See the paper for the full details.

Note: On Windows sytems, clicking on the program code below starts the program if the extension (.ssc, .R, .sas) is known to the system. We suggest you click on the links with the right mouse button and select the desired action from the menu.

S-Plus code 1,000 simulations take about half an hour on a Windows XP desktop with 2 GHz clock speed. To change the number of iterations, change the line nsim <- 1000 to the desired value.
R code The code is almost identical to the S-Plus code.
Differences:
% diff rttm.R rttm.ssc
3c3
< # This code is for the R programming system.
---
> # This code is for the S-Plus programming system.
119c119
< library(lattice)
---
> #library(lattice)
120a121
>
149,150c150,151
<       scales=list(limits=c(-0.05, 1.05)),  # for R
< #      scales=list(limits=c(0, 1)),         # for S-PLUS
---
> #      scales=list(limits=c(-0.05, 1.05)),  # for R
>       scales=list(limits=c(0, 1)),         # for S-PLUS
153c154
<               panel.xyplot(x, y, col = 8, ...)
---
>               panel.xyplot(x, y, ...)
1,000 simulations take about seven minutes on a Windows XP desktop with 2 GHz clock speed, running R version 2.5.0. To change the number of iterations, change the line nsim <- 1000 to the desired value.
SAS code SAS output. 1,000 simulations take about 2.5 hours on an HP workstation with 3.2 GHz clock speed. See the top of the code for how to change the number of iterations.

Andreas Krause, José Pinheiro
August 2007