summaryrefslogtreecommitdiff
path: root/smallPValueCanAriseByChance.R
blob: 8c69f90613f64a0eea6c653afeb57557f412970e (plain)
1
2
3
4
5
6
7
8
9
10
11
# Purpose: "we expect to see approximately five small p-values even in the absence of
# any true association between the predictors and the response"
# Created by Hui Lan on 19 April 2018 (zjnu)
N <- 200 # number of data points
p <- 100  # number of dimensions
X <- cbind(rep(1,N), matrix(rnorm(N*p), N, p))
beta = matrix(c(12, rep(0, p)), p+1, 1)
y = X %*% beta + rnorm(N,0,0.5) # H0 is true

model <- lm(y ~ X)
summary(model)