# # Epage # # 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. # #----- library(alr3) data(galtonpeas) attach(galtonpeas) # 5.1.1: see below for this plot # # 5.1.2: # m <- lm( Progeny ~ Parent, weights=1/(SD^2) ) postscript("../../WriteUp/Graphics/Chapter5/prob_1.eps", onefile=FALSE, horizontal=FALSE) plot( Parent, Progeny, xlab="Parent", ylab="Progeny") abline( m ) dev.off() s <- summary(m) beta_hat_1 <- s$coefficients[2,1] se_beta_hat_1 <- s$coefficients[2,2] t <- ( beta_hat_1 - 1 ) / se_beta_hat_1 n <- length(m$residuals) t_dof <- n - 2 pt( t, t_dof )