During a lesson at university, we ran this simulation to assess the fact that p-value distribution under alternative hypothesis is stochastically smaller than the uniform distribution.
So suppose we want to make an F-test for a linear regression (joint nullity of parameters)
n=10
p=3
beta=c(1,2,0) #beta_2=2,null hypothesis of test f is false
sim<-function(n,p)
{
x<-cbind(1,matrix(runif(n*(p-1)),ncol=p-1))
y<-x%*%beta+rnorm(n)
X<-as.data.frame(x)
anova(lm(y~1),lm(y~.,X))
#prendo il p value
pval<-anova(lm(y~1),lm(y~.,X))$'Pr(>F)'[2]
return (pval)
}
res<-replicate(100,sim(10,3))
hist(res)
plot(ecdf(res))
curve(punif,0,1,add=T,col="red")
and I obtain this graph
Could anyone explain (and maybe provide a little proof) of the above statement:
p-value distribution under alternative hypothesis is stochastically smaller than the uniform distribution