# # Epage 65 # # Written by: # -- # John L. Weatherwax 2009-04-21 # # email: wax@alum.mit.edu # # Please send comments and especially bug reports to the # above email address. # #----- if(is.null(version$language) == FALSE) require(alr3) else library(alr3) #UN2 <- read.table("data/UN2.txt",header=TRUE) if(is.null(version$language) == FALSE) data(UN2) attach(UN2) # 3.2.1: # m = lm( logFertility ~ logPPgdp + Purban ) summary(m) # get the added-variable plot for the addition of the variable logPPgdp after Purban # m_no_logPPgdp = lm( logFertility ~ Purban ) r_m_no_logPPgdp = residuals( m_no_logPPgdp ) m_logPPgdp_on_Purban = lm( logPPgdp ~ Purban ) r_m_logPPgdp_on_Purban = residuals( m_logPPgdp_on_Purban ) # the added variable plot plot( r_m_logPPgdp_on_Purban, r_m_no_logPPgdp ) mav = lm( r_m_no_logPPgdp ~ r_m_logPPgdp_on_Purban ) round(coef(mav),4)