Exercise C2 – Law School Salaries

Load necessary packages

if(!require(wooldridge)) install.packages(“wooldridge”) if(!require(lmtest)) install.packages(“lmtest”) if(!require(sandwich)) install.packages(“sandwich”) if(!require(car)) install.packages(“car”)

library(wooldridge) library(lmtest) library(sandwich) library(car)

Load data

data(“lawsch85”) str(lawsch85) summary(lawsch85)

Base model: salary ~ rank + LSAT + GPA

model1 <- lm(salary ~ rank + LSAT + GPA, data = lawsch85) summary(model1)

Robust SEs

coeftest(model1, vcov = vcovHC(model1, type=“HC1”))

Joint significance of LSAT and GPA

linearHypothesis(model1, c(“LSAT = 0”, “GPA = 0”), vcov=vcovHC(model1,type=“HC1”))

Interpretation:

Extended model including class size and faculty

model2 <- lm(salary ~ rank + LSAT + GPA + clsize + faculty, data = lawsch85) summary(model2)

Joint test: clsize and faculty

linearHypothesis(model2, c(“clsize = 0”, “faculty = 0”), vcov=vcovHC(model2,type=“HC1”))

Interpretation:

Exercise C8 – Pension & Wealth

Load data

Load data

data(“k401ksubs”) single <- subset(k401ksubs, fsize == 1)

Define number of single-person households

n_single <- nrow(single)

Output it

n_single

Interpretation: Number of single-person households is r n_single.

Regression: nettfa ~ inc + age

model3 <- lm(nettfa ~ inc + age, data = single) summary(model3)

Robust SEs

coeftest(model3, vcov=vcovHC(model3,type=“HC1”))

Interpretation:

One-sided t-test: H0: β_age = 1, H1: β_age < 1

b2 <- coef(model3)[“age”] se_b2 <- sqrt(diag(vcovHC(model3,type=“HC1”)))[“age”] t_stat <- (b2 - 1)/se_b2 p_val <- pt(t_stat, df.residual(model3)) # one-sided lower-tail t_stat p_val

Interpretation: Reject H0 at 1% level if p-value < 0.01.

Simple regression: nettfa ~ inc

model4 <- lm(nettfa ~ inc, data = single) summary(model4)

Compare income coefficients

cbind(Multiple_reg=coef(model3)[“inc”], Simple_reg=coef(model4)[“inc”])

Interpretation: