Chapter 5: OLS Asymptotics

Make a histogram of the variable “prate”.

data("k401k")

hist(k401k$prate)

Example 5.2

data("bwght")

lm.1 <- lm(lbwght ~ cigs + lfaminc, data = bwght[1:694,])
s.1 <- summary(lm.1)

lm.2 <- lm(lbwght ~ cigs + lfaminc, data = bwght)
s.2 <- summary(lm.2)

s.2$coefficients[2, 2] / s.1$coefficients[2, 2]
## [1] 0.6443341
lm.3 <- lm(cigs ~ lfaminc, data = bwght[1:694,])
s.3 <- summary(lm.3)

sigma.j <- s.3$coefficients[2, 2]
sigma <- s.3$sigma
r2 <- s.3$r.squared
sigma / (sqrt(1388) * sigma.j * sqrt(1 - r2))
## [1] 0.6609623

Example 5.3

data("crime1")
     
lm.1 <- lm(narr86 ~ pcnv + ptime86 + qemp86, data = crime1)

# LM test
lm.u <- lm(lm.1$residuals ~ pcnv + ptime86 + qemp86 + avgsen + tottime, data = crime1)
summary(lm.u)$r.squared * 2725
## [1] 4.070729
qchisq(.9, 2)
## [1] 4.60517
1 - pchisq(4.09, 2)
## [1] 0.1293802

F-Test

lm.2 <- lm(narr86 ~ pcnv + ptime86 + qemp86 + avgsen + tottime, data = crime1)
anova(lm.1, lm.2)
## Analysis of Variance Table
## 
## Model 1: narr86 ~ pcnv + ptime86 + qemp86
## Model 2: narr86 ~ pcnv + ptime86 + qemp86 + avgsen + tottime
##   Res.Df    RSS Df Sum of Sq      F Pr(>F)
## 1   2721 1927.3                           
## 2   2719 1924.4  2     2.879 2.0339  0.131