SLID1 <- read.table("c:/temp/SLID-Ontario.txt",sep = "\t",header=F,skip=1) names(SLID1) <- c("age","sex","wages","yearsed") SLID1$male <- as.numeric(SLID1$sex == "Male") SLID1$log2wages <- log2(SLID1$wages) SLID1$agectr <- SLID1$age - 15 --------------------------- Box Tidwell -------------------------------------- library(car) # the result with the original age value differs alot from that presented in the text boxTidwell(log2wages ~ age +yearsed, ~ male, data=SLID1[SLID1$yearsed!=0,]) # using age - 15 gives a result similar to in the text boxTidwell(log2wages ~ agectr +yearsed, ~ male, data=SLID1[SLID1$yearsed!=0,]) ----------------------- Cook and Weisberg HOV test ---------------------------- # Below we follow Cook and Weisberg's approach to a HOV test SLID1.lm1 <- lm(wages ~ male +agectr +yearsed, data=SLID1) SLID1$u <- SLID1.lm1$residuals^2/summary(SLID1.lm1)$sigma^2 SLID1.CWmodel <- lm(SLID1$u ~ fitted.values(SLID1.lm1)) SLID1.CWteststat <- anova(SLID1.CWmodel)$"Sum Sq"[1]/2 # p value for the test 1 -pchisq(SLID1.CWteststat,1)