n <- 30 # Number of observations
x <- runif(n, min = 0, max = 1) # Generate the x values once5 Linear Regression Through Monte Carlo Simulation
5.1 From sample means to regression coefficients
In the previous chapters, one sample consisted of observations
\[ X_1,X_2,\ldots,X_n. \]
From that sample, we calculated the sample mean
\[ \bar X. \]
Now our data will consist of pairs of observations:
\[ (X_1,Y_1),(X_2,Y_2),\ldots,(X_n,Y_n). \]
Instead of using the sample to calculate \(\bar X\), we will use these pairs to calculate regression coefficients.
The basic Monte Carlo idea does not change.
Before: repeated samples and the sample mean
In Chapters 3 and 4, the parent distribution was characterized by fixed quantities such as
\[ \mu \qquad\text{and}\qquad \sigma^2. \]
One Monte Carlo repetition generated a sample
\[ X_1,\ldots,X_n \]
from that parent distribution.
From the sample, we calculated
\[ \bar X. \]
A new sample produced a new value of \(\bar X\). Repeating the experiment gave us
\[ \bar X_1,\bar X_2,\ldots,\bar X_R. \]
The parent mean
\[ \mu \]
was fixed, but the sample mean
\[ \bar X \]
was a random variable.
Now: repeated samples and regression coefficients
Suppose the true relationship between \(X\) and \(Y\) is
\[ Y_i=\beta_0+\beta_1X_i+u_i. \]
The quantities
\[ \beta_0 \qquad\text{and}\qquad \beta_1 \]
are the true regression coefficients.
For our example, let
\[ \beta_0=2, \qquad \beta_1=5. \]
Suppose also that the errors are independent and identically distributed (iid), with
\[ u_i\sim N(0,\sigma^2) \]
and
\[ \sigma^2=0.1. \]
Then the true model is
\[ Y_i=2+5X_i+u_i. \]
The \(X_i\)’s are fixed
In the regression simulations in this chapter, we begin with a given set of values
\[ X_1,\ldots,X_n. \]
We will keep these values fixed across Monte Carlo repetitions.
For our example, generate one fixed set of \(X_i\)’s:
Once these \(X_i\)’s have been generated, we do not generate them again in each Monte Carlo repetition.
The quantities
\[ X_1,\ldots,X_n, \qquad \beta_0, \qquad \beta_1, \qquad \sigma^2 \]
will all remain fixed.
What changes from sample to sample are the random errors.
One generated sample
To generate one sample, first generate
\[ u_1,\ldots,u_n. \]
Then use the true model
\[ Y_i=\beta_0+\beta_1X_i+u_i \]
to generate the \(Y_i\)’s.
beta.0 <- 2 # True intercept
beta.1 <- 5 # True slope
sig2 <- 0.1 # Variance of the errors
u <- rnorm(n, # Generate n random errors
mean = 0,
sd = sqrt(sig2))
y <- beta.0 + beta.1 * x + u # Generate the y valuesWe now have one generated sample consisting of
\[ (X_1,Y_1),\ldots,(X_n,Y_n). \]
The \(X_i\)’s were already fixed.
The errors \(u_i\) were random.
Therefore, the \(Y_i\)’s are random.
Calculate the regression coefficients
From this sample, we calculate the OLS regression
\[ Y_i=\hat\beta_0+\hat\beta_1X_i+\hat u_i. \]
In R, lm() calculates a linear regression.
fit <- lm(y ~ x) # Regress y on x
beta.0.hat <- unname(coef(fit)["(Intercept)"]) # Calculated intercept
beta.1.hat <- unname(coef(fit)["x"]) # Calculated slope
cat("beta.0.hat =", round(beta.0.hat, 3), "\n")beta.0.hat = 1.858
cat("beta.1.hat =", round(beta.1.hat, 3), "\n")beta.1.hat = 5.209
The true coefficients are
\[ \beta_0=2 \qquad\text{and}\qquad \beta_1=5. \]
The calculated coefficients,
\[ \hat\beta_0 \qquad\text{and}\qquad \hat\beta_1, \]
will usually be close to these values, but they will not be exactly equal to them.
Why?
Because this particular sample contains a particular set of random errors.
True regression and estimated regression
The dashed line below is the true regression line
\[ Y=2+5X. \]
The solid line is the regression calculated from this particular generated sample.
plot(x, y,
xlab = "X",
ylab = "Y",
main = "")
abline(a = beta.0, # True regression line
b = beta.1,
lty = 2,
lwd = 2)
abline(fit, # Regression calculated from this sample
lwd = 2)
legend("topleft",
legend = c("True regression", "Estimated regression"),
lty = c(2, 1),
lwd = c(2, 2),
bty = "n")
If we generated a new set of errors, we would obtain new \(Y_i\)’s and therefore a new estimated regression line.
The connection to the sample mean
The parallel with the previous chapters is close.
| Previous chapters | Regression |
|---|---|
| Sample: \(X_1,\ldots,X_n\) | Sample: \((X_1,Y_1),\ldots,(X_n,Y_n)\) |
| True parameter: \(\mu\) | True parameter: \(\beta_1\) |
| Calculate \(\bar X\) | Calculate \(\hat\beta_1\) |
| Different samples give different \(\bar X\)’s | Different samples give different \(\hat\beta_1\)’s |
Before,
\[ \mu \]
was fixed while
\[ \bar X \]
changed from sample to sample.
Now,
\[ \beta_1 \]
is fixed while
\[ \hat\beta_1 \]
changes from sample to sample.
Therefore,
\[ \boxed{ \hat\beta_1\text{ is a random variable} } \]
just as
\[ \bar X \]
was a random variable.
One sample gives us one value of
\[ \hat\beta_1. \]
Many possible samples give us
\[ \hat\beta_{1,1}, \hat\beta_{1,2}, \ldots, \hat\beta_{1,R}. \]
The next question is therefore the same kind of question we asked about \(\bar X\):
What does the distribution of the OLS slope look like across repeated samples?
5.2 The distribution of the OLS slope
In the previous section, one generated sample produced one estimated slope,
\[ \hat\beta_1. \]
If we generate another set of errors,
\[ u_1,\ldots,u_n, \]
we get another set of \(Y_i\)’s and therefore another value of
\[ \hat\beta_1. \]
Repeating the experiment gives
\[ \hat\beta_{1,1}, \hat\beta_{1,2}, \ldots, \hat\beta_{1,R}. \]
This is directly analogous to what happened with the sample mean:
\[ \bar X_1,\bar X_2,\ldots,\bar X_R. \]
So we ask the same three questions:
What is the center of the distribution of \(\hat\beta_1\)?
What is its spread?
What is its shape?
The theoretical distribution
Recall the model
\[ Y_i=\beta_0+\beta_1X_i+u_i, \]
where the \(X_i\)’s are fixed and
\[ u_i\sim N(0,\sigma^2). \]
The OLS slope can be written as
\[ \hat\beta_1 = \beta_1 + \frac{ \sum_{i=1}^n(X_i-\bar X)u_i }{ \sum_{i=1}^n(X_i-\bar X)^2 }. \]
This expression shows where the randomness in \(\hat\beta_1\) comes from.
The quantities
\[ X_1,\ldots,X_n \]
and
\[ \beta_1 \]
are fixed.
The errors
\[ u_1,\ldots,u_n \]
are random.
Therefore,
\[ \hat\beta_1 \]
is random.
Center
Because
\[ E(u_i)=0, \]
the random part has mean zero. Therefore,
\[ \boxed{ E(\hat\beta_1)=\beta_1 } \]
So across repeated samples, the distribution of the estimated slope is centered at the true slope.
For our example,
\[ \beta_1=5. \]
Therefore, we predict that the distribution of \(\hat\beta_1\) will be centered at
\[ 5. \]
Spread
The variance of the OLS slope is
\[ \boxed{ \operatorname{Var}(\hat\beta_1) = \frac{\sigma^2} {\sum_{i=1}^n(X_i-\bar X)^2} } \]
This formula has a useful interpretation.
Larger
\[ \sigma^2 \]
means more noise in \(Y\), so the estimated slopes vary more from sample to sample.
Larger
\[ \sum_{i=1}^n(X_i-\bar X)^2 \]
means that the \(X_i\)’s are more spread out, so we can estimate the slope more precisely.
We can calculate the theoretical variance for our fixed set of \(X_i\)’s in R:
x.bar <- mean(x) # Mean of the fixed x values
Sxx <- sum((x - x.bar)^2) # Sum of squared deviations of x
var.beta.1 <- sig2 / Sxx # Theoretical variance of beta.1.hat
cat("theoretical variance =", round(var.beta.1, 4), "\n")theoretical variance = 0.0435
Shape
Because the errors are normally distributed,
\[ u_i\sim N(0,\sigma^2), \]
the OLS slope is also normally distributed.
Therefore,
\[ \boxed{ \hat\beta_1 \sim N\left( \beta_1, \frac{\sigma^2} {\sum_{i=1}^n(X_i-\bar X)^2} \right) } \]
For our example, the theoretical prediction is:
- center: \(\beta_1=5\);
- spread: \(\sigma^2/S_{xx}\);
- shape: normal.
Watch 10 estimated slopes
Start with
\[ R=10 \]
so we can see each repetition.
R <- 10
for (i in 1:R) {
u <- rnorm(n, mean = 0, sd = sqrt(sig2)) # Generate new errors
y <- beta.0 + beta.1 * x + u # Generate new y values
fit <- lm(y ~ x) # Run the regression
beta.1.hat <- unname(coef(fit)["x"]) # Calculate the slope
cat("sample =", i,
"first y's =", round(y[1], 3),
round(y[2], 3),
round(y[3], 3),
"beta.1.hat =", round(beta.1.hat, 3), "\n")
}sample = 1 first y's = 3.034 4.674 5.051 beta.1.hat = 5.012
sample = 2 first y's = 3.398 4.427 4.659 beta.1.hat = 4.979
sample = 3 first y's = 3.224 3.897 5.043 beta.1.hat = 5.298
sample = 4 first y's = 3.762 3.968 4.864 beta.1.hat = 5.102
sample = 5 first y's = 3.484 4.4 4.357 beta.1.hat = 5.051
sample = 6 first y's = 3.699 4.427 4.723 beta.1.hat = 4.984
sample = 7 first y's = 3.073 4.849 4.607 beta.1.hat = 5.151
sample = 8 first y's = 3.688 4.351 4.578 beta.1.hat = 5.134
sample = 9 first y's = 3.197 4.242 4.982 beta.1.hat = 4.8
sample = 10 first y's = 3.757 4.281 5.263 beta.1.hat = 5.128
The \(X_i\)’s are the same in every repetition.
The true slope
\[ \beta_1=5 \]
is also the same.
What changes are the errors, the \(Y_i\)’s, and therefore the estimated slope.
Many repeated samples
Now increase the number of repetitions to
\[ R=10{,}000. \]
R <- 10000
beta.1.hat <- rep(0, R) # Store the estimated slopes
for (i in 1:R) {
u <- rnorm(n, mean = 0, sd = sqrt(sig2)) # Generate new errors
y <- beta.0 + beta.1 * x + u # Generate new y values
fit <- lm(y ~ x) # Run the regression
beta.1.hat[i] <- unname(coef(fit)["x"]) # Save the estimated slope
}
cat("Monte Carlo mean =", round(mean(beta.1.hat), 3), "\n")Monte Carlo mean = 5.003
cat("theoretical mean =", beta.1, "\n")theoretical mean = 5
cat("Monte Carlo variance =", round(var(beta.1.hat), 4), "\n")Monte Carlo variance = 0.0436
cat("theoretical variance =", round(var.beta.1, 4), "\n")theoretical variance = 0.0435
The Monte Carlo mean should be close to
\[ \beta_1=5, \]
and the Monte Carlo variance should be close to
\[ \frac{\sigma^2}{\sum(X_i-\bar X)^2}. \]
Comparison
Finally, compare the simulated distribution of the slopes with the theoretical normal distribution.
hist(beta.1.hat,
probability = TRUE,
breaks = 35,
xlab = expression(hat(beta)[1]),
main = "")
curve(dnorm(x,
mean = beta.1,
sd = sqrt(var.beta.1)),
add = TRUE,
lwd = 2)
abline(v = beta.1,
lty = 2,
lwd = 2)
The figure shows that the simulated distribution is centered near the true slope,
\[ \beta_1, \]
and has the normal shape predicted by the theory. The numerical comparison above checks the predicted variance.
Complete Monte Carlo Algorithm
1. Theoretical Prediction
For fixed \(X_i\)’s and normally distributed errors,
\[ \hat\beta_1 \sim N\left( \beta_1, \frac{\sigma^2} {\sum_{i=1}^n(X_i-\bar X)^2} \right). \]
2. Numerical Simulation
- Keep \(X_1,\ldots,X_n\) fixed.
- Generate \(n\) errors from \(N(0,\sigma^2)\).
- Generate \[ Y_i=\beta_0+\beta_1X_i+u_i. \]
- Regress \(Y\) on \(X\) and save \(\hat\beta_1\).
- Repeat steps 2–4 \(R\) times.
3. Comparison
Compare the simulated histogram of
\[ \hat\beta_1 \]
with the theoretically predicted normal density.
5.3 The t-statistic for the slope
In Chapter 4, we used a t-statistic to ask whether a sample mean was far from a particular value of the parent mean.
We considered
\[ H_0:\mu=\mu_0 \]
and calculated
\[ t= \frac{\bar X-\mu_0} {SE(\bar X)}. \]
We can use exactly the same idea for a regression coefficient.
Now the parameter of interest is
\[ \beta_1, \]
and our sample gives us
\[ \hat\beta_1. \]
So the connection with Chapter 4 is
\[ \mu \quad\longleftrightarrow\quad \beta_1 \]
and
\[ \bar X \quad\longleftrightarrow\quad \hat\beta_1. \]
Suppose we want to test
\[ H_0:\beta_1=\beta_{1,0}. \]
The regression t-statistic is
\[ \boxed{ t= \frac{\hat\beta_1-\beta_{1,0}} {\widehat{SE}(\hat\beta_1)} } \]
It tells us how many estimated standard errors the calculated slope is from the value assumed under the null hypothesis.
Make the null hypothesis true
As in Chapter 4, we can use Monte Carlo simulation to study what happens when the null hypothesis is true.
Suppose
\[ H_0:\beta_1=0. \]
In a real application, we would not know whether the true slope is zero.
But in a Monte Carlo simulation, we choose the true model ourselves.
So we make the null hypothesis true by generating the data using
\[ \beta_1=0. \]
We use
\[ Y_i=2+0X_i+u_i, \]
with
\[ u_i\sim N(0,0.1). \]
We keep the same fixed \(X_i\)’s from the previous sections.
Thus,
\[ \beta_{1,0}=0 \]
is both the value specified under the null and the true value used to generate the data.
One new feature: we estimate the standard error
There is one important difference from Chapter 4.
There, we treated
\[ \sigma^2 \]
as known.
For the regression, we usually do not know the variance of the errors. We estimate it from the sample.
After estimating
\[ Y_i=\hat\beta_0+\hat\beta_1X_i+\hat u_i, \]
we have regression residuals
\[ \hat u_1,\ldots,\hat u_n. \]
We use them to estimate the error variance:
\[ \boxed{ \hat\sigma^2 = \frac{\sum_{i=1}^n\hat u_i^2}{n-2} } \]
Why \(n-2\)?
Because we use the sample to calculate two regression coefficients,
\[ \hat\beta_0 \qquad\text{and}\qquad \hat\beta_1. \]
The estimated standard error of the slope is then
\[ \boxed{ \widehat{SE}(\hat\beta_1) = \sqrt{ \frac{\hat\sigma^2} {\sum_{i=1}^n(X_i-\bar X)^2} } } \]
Compare this with the theoretical standard deviation of \(\hat\beta_1\) from the previous section:
\[ \sqrt{ \frac{\sigma^2} {\sum_{i=1}^n(X_i-\bar X)^2} }. \]
The structure is the same.
The difference is that
\[ \sigma^2 \]
has been replaced by its estimate
\[ \hat\sigma^2. \]
One Monte Carlo repetition: \(R=1\)
Generate one simulated sample under
\[ H_0:\beta_1=0. \]
beta.1.null <- 0 # True slope under H0
beta.1.0 <- 0 # Value specified under H0
u <- rnorm(n,
mean = 0,
sd = sqrt(sig2)) # Generate one set of errors
y <- beta.0 + beta.1.null * x + u # Generate one sample under H0
fit <- lm(y ~ x) # Regress y on x
beta.1.hat.one <- unname(coef(fit)["x"])
u.hat <- resid(fit) # Regression residuals
sig2.hat <- sum(u.hat^2) / (n - 2) # Estimated error variance
se.beta.1.one <- sqrt(sig2.hat / Sxx) # Estimated standard error
t.manual <- (beta.1.hat.one - beta.1.0) /
se.beta.1.one # Calculate t-statistic ourselves
t.reported <- summary(fit)$coefficients[
"x", "t value"] # t-statistic reported by R
cat("beta.1.hat =", round(beta.1.hat.one, 3), "\n")beta.1.hat = -0.278
cat("estimated SE =", round(se.beta.1.one, 3), "\n")estimated SE = 0.17
cat("t-statistic calculated =", round(t.manual, 3), "\n")t-statistic calculated = -1.629
cat("t-statistic reported by R =", round(t.reported, 3), "\n")t-statistic reported by R = -1.629
The two t-statistics should be the same.
R’s reported t-statistic tests
\[ H_0:\beta_1=0. \]
If we wanted to test another value, such as
\[ H_0:\beta_1=3, \]
we would calculate
\[ t= \frac{\hat\beta_1-3} {\widehat{SE}(\hat\beta_1)} \]
ourselves using the coefficient and standard error from the regression output.
What is the distribution of the t-statistic?
If the errors are normally distributed and
\[ H_0:\beta_1=\beta_{1,0} \]
is true, then
\[ \boxed{ t= \frac{\hat\beta_1-\beta_{1,0}} {\widehat{SE}(\hat\beta_1)} \sim t(n-2) } \]
For our example,
\[ n=30, \]
so the theoretical prediction is
\[ t\sim t(28). \]
This is different from the standard normal distribution we used in Chapter 4.
The reason is that the denominator now contains an estimated error variance.
Watch 10 t-statistics
Now use
\[ R=10. \]
R <- 10
for (i in 1:R) {
u <- rnorm(n,
mean = 0,
sd = sqrt(sig2)) # Generate new errors under H0
y <- beta.0 + beta.1.null * x + u # Generate new y values
fit <- lm(y ~ x) # Run the regression
beta.1.hat.one <- unname(coef(fit)["x"])
t.stat.one <- summary(fit)$coefficients[
"x", "t value"] # Use t-statistic reported by OLS
cat("sample =", i,
"beta.1.hat =", round(beta.1.hat.one, 3),
"t =", round(t.stat.one, 3), "\n")
}sample = 1 beta.1.hat = -0.085 t = -0.335
sample = 2 beta.1.hat = 0.042 t = 0.186
sample = 3 beta.1.hat = -0.043 t = -0.221
sample = 4 beta.1.hat = 0.001 t = 0.005
sample = 5 beta.1.hat = 0.218 t = 1.116
sample = 6 beta.1.hat = 0.211 t = 0.942
sample = 7 beta.1.hat = 0.026 t = 0.118
sample = 8 beta.1.hat = 0.096 t = 0.412
sample = 9 beta.1.hat = 0.215 t = 0.939
sample = 10 beta.1.hat = -0.295 t = -1.097
The calculated slope and t-statistic both change from sample to sample.
The true slope,
\[ \beta_1=0, \]
does not change.
Many repeated samples
Now increase the number of repetitions to
\[ R=10{,}000. \]
R <- 10000
t.stat <- rep(0, R)
for (i in 1:R) {
u <- rnorm(n,
mean = 0,
sd = sqrt(sig2)) # Generate new errors under H0
y <- beta.0 + beta.1.null * x + u # Generate new y values
fit <- lm(y ~ x) # Run the regression
t.stat[i] <- summary(fit)$coefficients[
"x", "t value"] # Save reported t-statistic
}The main comparison is with the entire theoretical distribution,
\[ t(28). \]
Comparison
In R, dt() gives the density of a Student t distribution. This is analogous to dnorm() for the normal distribution.
For example,
dt(x, df = n - 2)gives the density of a \(t(n-2)\) distribution at \(x\).
hist(t.stat,
probability = TRUE,
breaks = 35,
xlab = "t-statistic",
main = "")
curve(dt(x, df = n - 2), # Density of the t(n-2) distribution
add = TRUE,
lwd = 2)
Connection to Chapter 4
The logic has not changed.
In Chapter 4,
\[ t= \frac{\bar X-\mu_0} {SE(\bar X)}. \]
Now,
\[ t= \frac{\hat\beta_1-\beta_{1,0}} {\widehat{SE}(\hat\beta_1)}. \]
In both cases, the t-statistic answers the same question:
How many standard errors is our estimate from the value specified under the null hypothesis?
The new feature in regression is that the error variance, and therefore the standard error of the slope, is estimated from the sample.
Complete Monte Carlo Algorithm
1. Theoretical Prediction
Under
\[ H_0:\beta_1=\beta_{1,0}, \]
with normally distributed errors,
\[ t= \frac{\hat\beta_1-\beta_{1,0}} {\widehat{SE}(\hat\beta_1)} \sim t(n-2). \]
2. Numerical Simulation
- Keep \(X_1,\ldots,X_n\) fixed.
- Generate new errors under a model in which \(H_0\) is true.
- Generate the corresponding \(Y_i\)’s.
- Regress \(Y\) on \(X\) and save the reported t-statistic for the slope.
- Repeat steps 2–4 \(R\) times.
3. Comparison
Compare the simulated distribution of the t-statistics with the theoretical
\[ t(n-2) \]
distribution.
5.4 A confidence interval for the slope
In Chapter 4, we constructed a confidence interval for the parent mean,
\[ \mu. \]
Now we want a confidence interval for the true regression slope,
\[ \beta_1. \]
The connection is the same one we have used throughout this chapter:
\[ \mu \quad\longleftrightarrow\quad \beta_1 \]
and
\[ \bar X \quad\longleftrightarrow\quad \hat\beta_1. \]
In Chapter 4, the confidence interval took the form
\[ \bar X \pm 1.96\,SE(\bar X). \]
For the regression slope, we use
\[ \boxed{ \hat\beta_1 \pm 1.96\,\widehat{SE}(\hat\beta_1) } \]
as a large-sample approximation.
Strictly speaking, because we estimate the error variance, the exact critical value comes from a Student t distribution with \(n-2\) degrees of freedom.
For our sample size, we will use the familiar approximation
\[ 1.96. \]
One Monte Carlo repetition: \(R=1\)
Return to our original data-generating process,
\[ Y_i=2+5X_i+u_i, \]
where
\[ u_i\sim N(0,0.1). \]
The true slope is
\[ \beta_1=5. \]
u <- rnorm(n,
mean = 0,
sd = sqrt(sig2)) # Generate one set of errors
y <- beta.0 + beta.1 * x + u # Generate one sample
fit <- lm(y ~ x) # Run the regression
beta.1.hat.one <- unname(coef(fit)["x"])
se.beta.1.one <- summary(fit)$coefficients[
"x", "Std. Error"]
lower <- beta.1.hat.one - 1.96 * se.beta.1.one
upper <- beta.1.hat.one + 1.96 * se.beta.1.one
cat("beta.1.hat =", round(beta.1.hat.one, 3), "\n")beta.1.hat = 5.036
cat("estimated SE =", round(se.beta.1.one, 3), "\n")estimated SE = 0.211
cat("95% CI =", round(lower, 3), "to", round(upper, 3), "\n")95% CI = 4.623 to 5.45
This is one confidence interval produced by one Monte Carlo repetition.
The true parameter
\[ \beta_1=5 \]
is fixed.
What changes from sample to sample are
\[ \hat\beta_1, \]
its estimated standard error, and therefore the confidence interval.
Watch 10 confidence intervals
Now use
\[ R=10. \]
R <- 10
for (i in 1:R) {
u <- rnorm(n,
mean = 0,
sd = sqrt(sig2)) # Generate new errors
y <- beta.0 + beta.1 * x + u # Generate new y values
fit <- lm(y ~ x) # Run the regression
beta.1.hat.one <- unname(coef(fit)["x"])
se.beta.1.one <- summary(fit)$coefficients[
"x", "Std. Error"]
lower <- beta.1.hat.one - 1.96 * se.beta.1.one
upper <- beta.1.hat.one + 1.96 * se.beta.1.one
contains.beta.1 <- 0
if ((lower < beta.1) && (beta.1 < upper)) {
contains.beta.1 <- 1
}
cat("sample =", i,
"beta.1.hat =", round(beta.1.hat.one, 3),
"CI =", round(lower, 3), "to", round(upper, 3),
"contains beta.1 =", contains.beta.1, "\n")
}sample = 1 beta.1.hat = 4.855 CI = 4.452 to 5.258 contains beta.1 = 1
sample = 2 beta.1.hat = 4.917 CI = 4.597 to 5.237 contains beta.1 = 1
sample = 3 beta.1.hat = 5.305 CI = 4.834 to 5.775 contains beta.1 = 1
sample = 4 beta.1.hat = 5.066 CI = 4.568 to 5.565 contains beta.1 = 1
sample = 5 beta.1.hat = 4.905 CI = 4.54 to 5.271 contains beta.1 = 1
sample = 6 beta.1.hat = 5.068 CI = 4.72 to 5.417 contains beta.1 = 1
sample = 7 beta.1.hat = 5.186 CI = 4.74 to 5.631 contains beta.1 = 1
sample = 8 beta.1.hat = 4.859 CI = 4.475 to 5.243 contains beta.1 = 1
sample = 9 beta.1.hat = 5.008 CI = 4.586 to 5.429 contains beta.1 = 1
sample = 10 beta.1.hat = 5.082 CI = 4.718 to 5.445 contains beta.1 = 1
The true slope,
\[ \beta_1=5, \]
does not move.
Different samples produce different values of
\[ \hat\beta_1, \]
and therefore different confidence intervals.
Check the coverage with Monte Carlo
Now increase the number of repetitions to
\[ R=10{,}000. \]
R <- 10000
success <- 0
for (i in 1:R) {
u <- rnorm(n,
mean = 0,
sd = sqrt(sig2)) # Generate new errors
y <- beta.0 + beta.1 * x + u # Generate new y values
fit <- lm(y ~ x) # Run the regression
beta.1.hat.one <- unname(coef(fit)["x"])
se.beta.1.one <- summary(fit)$coefficients[
"x", "Std. Error"]
lower <- beta.1.hat.one - 1.96 * se.beta.1.one
upper <- beta.1.hat.one + 1.96 * se.beta.1.one
if ((lower < beta.1) && (beta.1 < upper)) {
success <- success + 1
}
}
p.hat <- success / R
cat("Monte Carlo coverage =", round(p.hat, 3), "\n")Monte Carlo coverage = 0.941
Because \(1.96\) is a large-sample approximation, the Monte Carlo coverage may not be exactly 0.95.
The important point is the same as in Chapter 4:
\[ \boxed{ \text{the confidence level describes the repeated-sampling procedure} } \]
A particular interval either contains the true slope or it does not.
Connection to Chapter 4
Nothing fundamental has changed.
Before,
\[ \bar X \pm 1.96\,SE(\bar X) \]
gave us a confidence interval for
\[ \mu. \]
Now,
\[ \hat\beta_1 \pm 1.96\,\widehat{SE}(\hat\beta_1) \]
gives us an approximate confidence interval for
\[ \beta_1. \]
In both cases,
\[ \boxed{\text{parameter is fixed}} \]
while
\[ \boxed{\text{estimate and confidence interval change across samples}}. \]
Complete Monte Carlo Algorithm
1. Theoretical Prediction
Using the large-sample approximation, construct the 95% confidence interval
\[ \hat\beta_1 \pm 1.96\,\widehat{SE}(\hat\beta_1). \]
2. Numerical Simulation
- Keep \(X_1,\ldots,X_n\) fixed.
- Generate \(n\) new errors from \(N(0,\sigma^2)\).
- Generate \[ Y_i=\beta_0+\beta_1X_i+u_i. \]
- Regress \(Y\) on \(X\).
- Use \(\hat\beta_1\) and its estimated standard error to construct \[ \hat\beta_1\pm1.96\,\widehat{SE}(\hat\beta_1). \]
- Count a success if the interval contains the true \(\beta_1\).
- Repeat steps 2–6 \(R\) times.
- Calculate \[ \hat p= \frac{\text{number of intervals containing }\beta_1}{R}. \]
3. Comparison
Compare the Monte Carlo coverage with the predicted coverage of the confidence-interval procedure.
5.5 The p-value for the slope
In Chapter 4, after calculating a t-statistic, we asked a concrete question.
Suppose the null hypothesis says that the true parameter is zero. How unusual would it be to obtain an estimate this far from zero?
We ask exactly the same question in regression.
Suppose we want to test
\[ H_0:\beta_1=0. \]
Then our question is:
If the true slope is zero, how unusual would it be to obtain an estimated slope this far from zero?
Equivalently:
If the true slope is zero, how unusual would it be to obtain a t-statistic this far from zero?
The observed sample
The observed sample is not a Monte Carlo repetition.
It is the sample whose evidence we want to evaluate.
Suppose our observed regression gives
\[ \hat\beta_{1,1}=0.22 \]
and
\[ \widehat{SE}(\hat\beta_{1,1})=0.12. \]
Then
\[ t_1= \frac{0.22}{0.12}. \]
beta.1.hat.obs <- 0.22 # Slope from the observed sample
se.beta.1.obs <- 0.12 # Its estimated standard error
beta.1.0 <- 0 # Value under H0
t.1 <- (beta.1.hat.obs - beta.1.0) /
se.beta.1.obs # Observed t-statistic
cat("observed beta.1.hat =", round(beta.1.hat.obs, 3), "\n")observed beta.1.hat = 0.22
cat("observed SE =", round(se.beta.1.obs, 3), "\n")observed SE = 0.12
cat("observed t-statistic =", round(t.1, 3), "\n")observed t-statistic = 1.833
The t-statistic tells us how many estimated standard errors the observed slope is from zero.
The p-value on the t-statistic scale
Under the null hypothesis,
\[ t\sim t(n-2). \]
For our example,
\[ t\sim t(28). \]
For a two-sided test, a result at least as extreme as the observed one can occur on either side of zero:
\[ t\le -|t_1| \]
or
\[ t\ge |t_1|. \]
Therefore,
\[ \boxed{ p=P(|t|\ge |t_1|\mid H_0) } \]
In R, pt() calculates probabilities from a Student t distribution.
For
\[ T\sim t(n-2), \]
left.tail <- pt(-abs(t.1), df = n - 2) # P(T <= -|t.1|)
p.value <- 2 * left.tail # Two-sided: count both tails
cat("one tail =", round(left.tail, 3), "\n")one tail = 0.039
cat("p-value =", round(p.value, 3), "\n")p-value = 0.077
The figure below shows this probability on the t-statistic scale.
xx <- seq(-4.5, 4.5, length.out = 900)
yy <- dt(xx, df = n - 2)
plot(xx, yy,
type = "l",
lwd = 2,
xlab = "t-statistic",
ylab = "Density",
main = "")
left <- xx <= -abs(t.1)
right <- xx >= abs(t.1)
polygon(c(min(xx[left]), xx[left], max(xx[left])),
c(0, yy[left], 0),
density = 15,
border = NA)
polygon(c(min(xx[right]), xx[right], max(xx[right])),
c(0, yy[right], 0),
density = 15,
border = NA)
lines(xx, yy, lwd = 2)
abline(v = c(-abs(t.1), abs(t.1)), lty = 2)
The same p-value on the slope scale
The t-statistic does not change the evidence in the observed sample.
It simply expresses the distance between
\[ \hat\beta_1 \]
and the null value in standard-error units.
We can express the same reference distribution in units of the slope using the standard error from the observed sample.
beta.grid <- beta.1.0 + xx * se.beta.1.obs
beta.density <- dt((beta.grid - beta.1.0) / se.beta.1.obs,
df = n - 2) / se.beta.1.obs
plot(beta.grid, beta.density,
type = "l",
lwd = 2,
xlab = expression(hat(beta)[1]),
ylab = "Density",
main = "")
lower.cut <- beta.1.0 - abs(beta.1.hat.obs - beta.1.0)
upper.cut <- beta.1.0 + abs(beta.1.hat.obs - beta.1.0)
left <- beta.grid <= lower.cut
right <- beta.grid >= upper.cut
polygon(c(min(beta.grid[left]), beta.grid[left], max(beta.grid[left])),
c(0, beta.density[left], 0),
density = 15,
border = NA)
polygon(c(min(beta.grid[right]), beta.grid[right], max(beta.grid[right])),
c(0, beta.density[right], 0),
density = 15,
border = NA)
lines(beta.grid, beta.density, lwd = 2)
abline(v = c(lower.cut, upper.cut), lty = 2)
abline(v = beta.1.0, lty = 3)
These two figures show the same probability on two different scales.
The first measures distance from zero in standard-error units.
The second measures the same distance in units of the estimated slope.
One Monte Carlo repetition: \(R=1\)
Now begin the Monte Carlo experiment.
This simulated sample is different from the observed sample above.
We assume
\[ H_0:\beta_1=0 \]
is true and generate one new sample under the null.
u <- rnorm(n,
mean = 0,
sd = sqrt(sig2)) # Generate one sample under H0
y <- beta.0 + beta.1.0 * x + u
fit <- lm(y ~ x)
beta.1.hat.mc <- unname(coef(fit)["x"])
se.beta.1.mc <- summary(fit)$coefficients[
"x", "Std. Error"]
t.mc <- summary(fit)$coefficients[
"x", "t value"]
ext.t <- abs(t.mc) >= abs(t.1)
ext.b1 <-
abs(beta.1.hat.mc - beta.1.0) >=
abs(t.1) * se.beta.1.mc
cat("simulated beta.1.hat =", round(beta.1.hat.mc, 3), "\n")simulated beta.1.hat = 0.016
cat("simulated t =", round(t.mc, 3), "\n")simulated t = 0.063
cat("ext.t =", ext.t, "\n")ext.t = FALSE
cat("ext.b1 =", ext.b1, "\n")ext.b1 = FALSE
For this one simulated sample, the two success rules give the same answer.
Watch 10 simulated samples
Now use
\[ R=10. \]
R <- 10
for (i in 1:R) {
u <- rnorm(n,
mean = 0,
sd = sqrt(sig2)) # Generate errors under H0
y <- beta.0 + beta.1.0 * x + u
fit <- lm(y ~ x)
beta.1.hat.mc <- unname(coef(fit)["x"])
se.beta.1.mc <- summary(fit)$coefficients[
"x", "Std. Error"]
t.mc <- summary(fit)$coefficients[
"x", "t value"]
ext.t <- abs(t.mc) >= abs(t.1)
ext.b1 <-
abs(beta.1.hat.mc - beta.1.0) >=
abs(t.1) * se.beta.1.mc
cat("sample =", i,
"beta.1.hat =", round(beta.1.hat.mc, 3),
"t =", round(t.mc, 3),
"ext.t =", ext.t,
"ext.b1 =", ext.b1, "\n")
}sample = 1 beta.1.hat = 0.321 t = 1.44 ext.t = FALSE ext.b1 = FALSE
sample = 2 beta.1.hat = -0.17 t = -0.824 ext.t = FALSE ext.b1 = FALSE
sample = 3 beta.1.hat = 0.265 t = 1.616 ext.t = FALSE ext.b1 = FALSE
sample = 4 beta.1.hat = 0.273 t = 1.473 ext.t = FALSE ext.b1 = FALSE
sample = 5 beta.1.hat = 0.181 t = 0.839 ext.t = FALSE ext.b1 = FALSE
sample = 6 beta.1.hat = -0.105 t = -0.485 ext.t = FALSE ext.b1 = FALSE
sample = 7 beta.1.hat = -0.172 t = -0.934 ext.t = FALSE ext.b1 = FALSE
sample = 8 beta.1.hat = 0.162 t = 0.799 ext.t = FALSE ext.b1 = FALSE
sample = 9 beta.1.hat = -0.312 t = -1.571 ext.t = FALSE ext.b1 = FALSE
sample = 10 beta.1.hat = -0.226 t = -0.854 ext.t = FALSE ext.b1 = FALSE
For every simulated sample,
ext.t
and
ext.b1
should give the same answer.
That is the key point:
\[ \boxed{ \text{t-statistic scale and slope scale describe the same extremeness} } \]
Verify the p-value with Monte Carlo
Now use
\[ R=10{,}000. \]
R <- 10000
success.t <- 0
success.beta <- 0
for (i in 1:R) {
u <- rnorm(n,
mean = 0,
sd = sqrt(sig2)) # Generate errors under H0
y <- beta.0 + beta.1.0 * x + u
fit <- lm(y ~ x)
beta.1.hat.mc <- unname(coef(fit)["x"])
se.beta.1.mc <- summary(fit)$coefficients[
"x", "Std. Error"]
t.mc <- summary(fit)$coefficients[
"x", "t value"]
if (abs(t.mc) >= abs(t.1)) {
success.t <- success.t + 1
}
if (abs(beta.1.hat.mc - beta.1.0) >=
abs(t.1) * se.beta.1.mc) {
success.beta <- success.beta + 1
}
}
p.hat.t <- success.t / R
p.hat.beta <- success.beta / R
cat("Monte Carlo p-value using t =", round(p.hat.t, 3), "\n")Monte Carlo p-value using t = 0.081
cat("Monte Carlo p-value using beta.1.hat =", round(p.hat.beta, 3), "\n")Monte Carlo p-value using beta.1.hat = 0.081
cat("Theoretical p-value =", round(p.value, 3), "\n")Theoretical p-value = 0.077
All three numbers should be very close.
Connection to Chapter 4
In Chapter 4, we calculated the same p-value using either
\[ \bar X \]
or its t-statistic.
Now we calculate the same p-value using either
\[ \hat\beta_1 \]
or its t-statistic.
The principle is unchanged:
\[ \boxed{ \text{a t-statistic does not change the evidence} } \]
It simply expresses the distance from the null value in standard-error units.
Complete Monte Carlo Algorithm
1. Theoretical Prediction
Under
\[ H_0:\beta_1=0, \]
\[ t\sim t(n-2). \]
For the observed statistic \(t_1\), the two-sided p-value is
\[ p=P(|t|\ge |t_1|\mid H_0). \]
2. Numerical Simulation
- Keep \(X_1,\ldots,X_n\) fixed.
- Generate new errors under \(H_0:\beta_1=0\).
- Generate the corresponding \(Y_i\)’s.
- Regress \(Y\) on \(X\).
- Calculate the slope and its t-statistic, and count a success if the simulated result is at least as extreme as the observed sample.
- Repeat steps 2–5 \(R\) times.
- Calculate \[ \hat p= \frac{\text{number of successes}}{R}. \]
3. Comparison
Compare the Monte Carlo estimate
\[ \hat p \]
with the theoretical p-value calculated using pt().
5.6 The F-statistic
So far, we have used the t-statistic to test a hypothesis about one regression coefficient.
For example,
\[ H_0:\beta_1=0. \]
The \(F\)-statistic is more general.
It allows us to test one or more restrictions jointly.
For example, in a regression with several explanatory variables, we might want to test
\[ H_0: \beta_1=0 \quad\text{and}\quad \beta_2=0. \]
The question is whether these restrictions are jointly consistent with the data.
More generally, an \(F\)-test can test
\[ q \]
restrictions at the same time.
In our current simple regression,
\[ Y_i=\beta_0+\beta_1X_i+u_i, \]
there is only one slope coefficient. So we consider the single restriction
\[ H_0:\beta_1=0. \]
With one restriction, the \(F\)-test gives the same conclusion as the corresponding t-test. In fact,
\[ F=t^2. \]
Under the null hypothesis,
\[ \boxed{ F\sim F(1,n-2) } \]
For our example,
\[ F\sim F(1,28). \]
The first degree of freedom,
\[ 1, \]
is the number of restrictions being tested.
The second,
\[ n-2=28, \]
is the regression error degrees of freedom.
One Monte Carlo repetition: \(R=1\)
To study the distribution of the \(F\)-statistic under the null hypothesis, generate data using
\[ \beta_1=0. \]
u <- rnorm(n,
mean = 0,
sd = sqrt(sig2)) # Generate errors under H0
y <- beta.0 + 0 * x + u # Generate y when beta.1 = 0
fit <- lm(y ~ x) # Run the regression
f.stat.one <- unname(
summary(fit)$fstatistic["value"]) # Regression F-statistic
cat("F-statistic =", round(f.stat.one, 3), "\n")F-statistic = 0.524
This is one simulated \(F\)-statistic under the null.
Watch 10 F-statistics
Now use
\[ R=10. \]
R <- 10
for (i in 1:R) {
u <- rnorm(n,
mean = 0,
sd = sqrt(sig2)) # Generate new errors under H0
y <- beta.0 + 0 * x + u # Generate new y values
fit <- lm(y ~ x) # Run the regression
f.stat.one <- unname(
summary(fit)$fstatistic["value"])
cat("sample =", i,
"F =", round(f.stat.one, 3), "\n")
}sample = 1 F = 2.625
sample = 2 F = 2.653
sample = 3 F = 0.17
sample = 4 F = 0.368
sample = 5 F = 0.389
sample = 6 F = 0.008
sample = 7 F = 0.009
sample = 8 F = 0.757
sample = 9 F = 8.132
sample = 10 F = 0.524
The \(F\)-statistic changes from sample to sample.
Many repeated samples
Now use
\[ R=10{,}000. \]
R <- 10000
f.stat <- rep(0, R)
for (i in 1:R) {
u <- rnorm(n,
mean = 0,
sd = sqrt(sig2)) # Generate new errors under H0
y <- beta.0 + 0 * x + u # Generate y under H0
fit <- lm(y ~ x) # Run the regression
f.stat[i] <- unname(
summary(fit)$fstatistic["value"]) # Save reported F-statistic
}Our theoretical prediction is
\[ F\sim F(1,28). \]
Comparison
In R, df() gives the density of an \(F\) distribution.
For example,
df(x, df1 = 1, df2 = n - 2)gives the density of an \(F(1,n-2)\) distribution at \(x\).
hist(f.stat,
probability = TRUE,
breaks = 40,
xlab = "F-statistic",
main = "")
curve(df(x, df1 = 1, df2 = n - 2), # Density of F(1,n-2)
add = TRUE,
lwd = 2)
If the theory is correct, the simulated \(F\)-statistics should follow
\[ F(1,n-2). \]
Complete Monte Carlo Algorithm
1. Theoretical Prediction
Under
\[ H_0:\beta_1=0, \]
the regression \(F\)-statistic has distribution
\[ F\sim F(1,n-2). \]
2. Numerical Simulation
- Keep \(X_1,\ldots,X_n\) fixed.
- Generate new errors under \(H_0:\beta_1=0\).
- Generate the corresponding \(Y_i\)’s.
- Regress \(Y\) on \(X\) and save the regression \(F\)-statistic.
- Repeat steps 2–4 \(R\) times.
3. Comparison
Compare the simulated distribution of the \(F\)-statistics with the theoretical
\[ F(1,n-2) \]
distribution.
5.7 Omitted variable bias
So far, the regression we estimated was the same as the model that generated the data.
Now suppose the true model is
\[ Y_i=\beta_0+\beta_1X_i+\beta_2Z_i+u_i. \]
The true coefficient on \(X\) is
\[ \beta_1. \]
But suppose we make a mistake and omit \(Z\).
Instead of regressing \(Y\) on both \(X\) and \(Z\), we regress
\[ Y_i\text{ on }X_i \]
only.
What happens to the distribution of the estimated coefficient on \(X\)?
Where is the distribution centered?
This brings us back to one of the questions we have asked throughout the chapter:
Where is the sampling distribution centered?
If we estimate the correct model, the distribution of the estimated coefficient on \(X\) is centered at
\[ \beta_1. \]
If \(Z\) affects \(Y\) and \(Z\) is related to \(X\), omitting \(Z\) shifts the center of the distribution away from
\[ \beta_1. \]
The figure below shows the idea.
The important idea is
\[ \boxed{ \text{omitted variable bias shifts the center of the sampling distribution} } \]
For omitted variable bias to arise, two things are needed.
First, the omitted variable must affect \(Y\).
Second, the omitted variable must be related to \(X\).
We will create an example in which both conditions hold.
Set up the data-generating process
Keep our original fixed \(X_i\)’s.
Now generate a fixed \(Z_i\) that is related to \(X_i\).
z <- 0.6 * x + rnorm(n, mean = 0, sd = 0.2) # z is related to xWe generate z only once.
After that, both
\[ X_1,\ldots,X_n \]
and
\[ Z_1,\ldots,Z_n \]
stay fixed across Monte Carlo repetitions.
Suppose the true model is
\[ Y_i=2+5X_i+3Z_i+u_i, \]
so
\[ \beta_1=5. \]
Our question is simple:
If we repeatedly generate data from this model but omit \(Z\) from the regression, will the average value of \(\hat\beta_1\) still be close to 5?
One Monte Carlo repetition: \(R=1\)
beta.2 <- 3
u <- rnorm(n,
mean = 0,
sd = sqrt(sig2)) # Generate one set of errors
y <- beta.0 + beta.1 * x + beta.2 * z + u # Generate y from the true model
fit.omit <- lm(y ~ x) # Deliberately omit z
beta.1.hat.one <- unname(coef(fit.omit)["x"])
cat("true beta.1 =", beta.1, "\n")true beta.1 = 5
cat("beta.1.hat =", round(beta.1.hat.one, 3), "\n")beta.1.hat = 6.23
This is one Monte Carlo repetition.
One estimate by itself cannot tell us whether the estimator is biased.
For that, we need repeated samples.
Watch 10 estimates
Now use
\[ R=10. \]
R <- 10
for (i in 1:R) {
u <- rnorm(n,
mean = 0,
sd = sqrt(sig2)) # Generate new errors
y <- beta.0 + beta.1 * x + beta.2 * z + u # Generate new y values
fit.omit <- lm(y ~ x) # Deliberately omit z
beta.1.hat.one <- unname(coef(fit.omit)["x"])
cat("sample =", i,
"beta.1.hat =", round(beta.1.hat.one, 3), "\n")
}sample = 1 beta.1.hat = 6.906
sample = 2 beta.1.hat = 6.502
sample = 3 beta.1.hat = 6.376
sample = 4 beta.1.hat = 6.436
sample = 5 beta.1.hat = 6.99
sample = 6 beta.1.hat = 6.635
sample = 7 beta.1.hat = 6.677
sample = 8 beta.1.hat = 6.711
sample = 9 beta.1.hat = 6.555
sample = 10 beta.1.hat = 6.686
The estimates change from sample to sample because the errors change.
But do they appear to vary around
\[ \beta_1=5? \]
With only 10 repetitions, it may still be difficult to tell.
Many repeated samples
Now use
\[ R=10{,}000. \]
R <- 10000
beta.1.hat.omit <- rep(0, R)
for (i in 1:R) {
u <- rnorm(n,
mean = 0,
sd = sqrt(sig2))
y <- beta.0 + beta.1 * x + beta.2 * z + u
fit.omit <- lm(y ~ x)
beta.1.hat.omit[i] <- unname(coef(fit.omit)["x"])
}
cat("true beta.1 =", beta.1, "\n")true beta.1 = 5
cat("Monte Carlo mean =", round(mean(beta.1.hat.omit), 3), "\n")Monte Carlo mean = 6.651
Now the comparison is immediate.
If there were no bias, we would expect
\[ \text{Monte Carlo mean of }\hat\beta_1 \approx \beta_1. \]
Instead, the Monte Carlo mean is systematically away from
\[ 5. \]
That is omitted variable bias.
\[ \boxed{ E(\hat\beta_1)\neq\beta_1 } \]
The estimates are still random from sample to sample, but they are varying around the wrong center.
Complete Monte Carlo Algorithm
1. Theoretical Prediction
If an omitted variable affects \(Y\) and is related to \(X\), the estimated coefficient on \(X\) is biased:
\[ E(\hat\beta_1)\neq\beta_1. \]
2. Numerical Simulation
- Keep \(X_1,\ldots,X_n\) and \(Z_1,\ldots,Z_n\) fixed.
- Generate new errors.
- Generate \[ Y_i=\beta_0+\beta_1X_i+\beta_2Z_i+u_i. \]
- Regress \(Y\) on \(X\), deliberately omitting \(Z\), and save \(\hat\beta_1\).
- Repeat steps 2–4 \(R\) times.
- Calculate the mean of the saved \(\hat\beta_1\)’s.
3. Comparison
Compare the Monte Carlo mean of
\[ \hat\beta_1 \]
with the true value
\[ \beta_1. \]
5.8 One sample, many possible samples
In most applications, we observe only one sample:
\[ (X_1,Y_1),\ldots,(X_n,Y_n). \]
From that sample, we calculate an estimated regression and quantities such as
\[ \hat\beta_1, \]
its standard error, a t-statistic, a confidence interval, a p-value, and an \(F\)-statistic.
But the theory behind regression inference asks what would happen if we could obtain many possible samples generated by the same underlying model.
Monte Carlo simulation lets us see those repeated samples.
In this chapter, we kept the \(X_i\)’s fixed. Each repetition generated a new set of errors,
\[ u_1,\ldots,u_n, \]
which generated a new set of \(Y_i\)’s:
\[ Y_i=\beta_0+\beta_1X_i+u_i. \]
Each new sample therefore produced new values of the statistics we calculated.
The true parameter
\[ \beta_1 \]
remained fixed, while
\[ \hat\beta_1 \]
changed from sample to sample.
This is the same distinction we used earlier:
\[ \mu \quad\longleftrightarrow\quad \beta_1 \]
and
\[ \bar X \quad\longleftrightarrow\quad \hat\beta_1. \]
The inferential logic also stayed the same.
We used repeated samples to understand the behavior of an estimator, its standard error, confidence intervals, t-statistics, p-values, and \(F\)-statistics.
Regression added several new ideas.
Because the error variance is estimated, the regression t-statistic follows a Student t distribution under the assumptions we used.
The \(F\)-statistic allows us to test restrictions jointly.
And omitted variable bias showed what can happen when the regression we estimate does not match the model that generated the data.
Monte Carlo does more than let us see many possible samples.
Because each sample produces a new value of the statistics we calculate, Monte Carlo lets us see the entire sampling distributions of quantities such as
\[ \hat\beta_1, \qquad t, \qquad F, \]
as well as confidence intervals and other statistics.
Instead of only being told what these distributions should look like, we can generate them ourselves and compare what we see with the theoretical predictions.
The central repeated-sampling idea is therefore:
\[ \boxed{\text{applications usually give us one sample}} \]
\[ \boxed{\text{theory considers many possible samples}} \]
\[ \boxed{\text{Monte Carlo lets us see those samples and the distributions they generate}} \]