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") # ----------- fit the model on the original scale ----------------------------- SLID1$log2wages <- log2(SLID1$wages) SLID1.lm1 <- lm(wages ~ male +age +yearsed, data=SLID1) # automatically generates several useful plots par(mfrow=c(2,2)) plot(SLID1.lm1) par(mfrow=c(1,1)) # A kernel density estimate of the residuals SLID1dens <- density(rstudent(SLID1.lm1)) # A plot of the histogram and kernel density estimate hist(rstudent(SLID1.lm1),prob=T,ylim=c(0,.46),main="Distribution of studentized residuals") lines(SLID1dens) # ---------- now try the log base 2 data --------------------------------------- SLID1.lm2 <- lm(log2wages ~ male +age +yearsed, data=SLID1) # automatically generates several useful plots par(mfrow=c(2,2)) plot(SLID1.lm2) par(mfrow=c(1,1)) # A kernel density estimate of the residuals SLID1dens2 <- density(rstudent(SLID1.lm2)) # A plot of the histogram and kernel density estimate hist(rstudent(SLID1.lm2),prob=T,ylim=c(0,.46), main="Distribution of studentized residuals for log data") lines(SLID1dens2) # remove objects when finished rm(SLID1.lm1,SLID1dens,SLID1.lm2,SLID1dens2)