OLS Asymptotics (Chapter 5)

After setting the working directory and loading the foreign package download the files we are going to use.

setwd('...')
library(foreign)
download.file('http://fmwww.bc.edu/ec-p/data/wooldridge/401k.dta','401k.dta',mode='wb')
download.file('http://fmwww.bc.edu/ec-p/data/wooldridge/crime1.dta','crime1.dta',mode='wb')
download.file('http://fmwww.bc.edu/ec-p/data/wooldridge/bwght.dta','bwght.dta',mode='wb')

Make a histogram of the variable “prate”.

a401k <- read.dta('401k.dta')
hist(a401k$prate)

Example 5.2

bwght <- read.dta("bwght.dta")

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]

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))

Example 5.3

crime1 <- read.dta("crime1.dta")
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
qchisq(.9,2)
1-pchisq(4.09,2)

# F test
lm.2 <- lm(narr86 ~ pcnv + ptime86 + qemp86 + avgsen + tottime,data=crime1)
anova(lm.1,lm.2)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s