# How are the null distributions created for hypothesis testing?

I'm struggling to connect the idea of a sampling distribution of a test statistic to the null distribution.

If I run many simple linear regressions on samples extracted from a population of data I can create sampling distributions of my test statistics, in this case for the slope and the intercept.

f <- function () {
fit <- lm(dist ~ speed, data = cars, subset = sample(nrow(cars), 30))
coef(fit)
}
set.seed(0); f()
set.seed(0); z <- t(replicate(50, f()))
par(mfrow = c(1,2))
hist(z[,1], main = "intercept")
hist(z[,2], main = "slope") # code taken from http://stackoverflow.com/questions/40210817/replicate-a-regression-using-a-random-subset-of-data-each-time-and-check-distrib?noredirect=1&lq=1
m1<-lm(dist ~ speed, data = cars) # compare to population coeffs
print(m1)


I know that the null distribution will be a t-distribution with mean of 0 and affected by the degrees of freedom I have. But how is this null distribution produced?

• The NULL distribution is assumed to be the correct distribution. Put crudely, it is made up or pulled out of thin air. You could just as soon assume that the NULL distribution is normal with a mean of 5 and a standard deviation of 2. The idea is to compare what you see in the data against whatever distribution you select in order to see if the evidence supports this assumption. – lmo Jan 5 '17 at 12:36
• Thanks for your response. The mean of the null distribution makes sense to me and that it could take on any value depending on our null hypothesis. But how is the standard deviation of the null distribution defined? – adkane Jan 5 '17 at 12:39
• It is defined in the same way. If theory/tradition suggests that you should use a t-distribution as the NULL, then the standard deviation is built into the distribution, based on the sample standard deviation and the sample size. Recall that the t statistic formula of a one sample test: $t = \frac{\bar{x} - \mu}{s / \sqrt{n}}$ – lmo Jan 5 '17 at 13:01
• Ah okay, so for the case of the t statistic formula 's' is the sample standard deviation – adkane Jan 5 '17 at 13:08
• Right. The formula is more complicated in regressions, but it amounts to the same thing, that the standard deviation or measure of spread is a function of the data. – lmo Jan 5 '17 at 13:13