# # MATH 3330 B, October 2001 # # Week 5a: Where Regression Got Its Name # Galton & Pearson ca 1900 # # Fathers' heights and son's heights # generate your own data by removing comments in next two lines: # fs.dat <- data.frame( father = 68 + 3*rnorm(2000)) # fs.dat$son <- 68 + 3*((fs.dat$father - 68)*0.6/3 + 0.8*rnorm(2000)) summary( fs.dat ) attach( fs.dat ) par( pty = "s" ) lab.vals <- seq( 59, 77, by = 3 ) labs <- list( labels = lab.vals, at = lab.vals ) plot( father, son , xlim = c(58,78), ylim = c(58,78) ,axes = F ) box() axis( 1, at = lab.vals ) axis( 2, at = lab.vals ) cor( dd$son, dd$father ) sqrt( var(father) ) sqrt( var(son) ) plot( father, son , xlim = c(58,78), ylim = c(58,78), type = 'n',axes=F) box() axis( 1, at = lab.vals ) axis( 2, at = lab.vals ) data.ell( father, son ) data.ell( father, son, radius = 2 ) data.ell( father, son, radius = 3 ) plot( father, son , xlim = c(58,78), ylim = c(58,78), type = 'n',axes=F) box() axis( 1, at = lab.vals ) axis( 2, at = lab.vals ) abline( coef(lm(son ~ father ))) plot( father, son , xlim = c(58,78), ylim = c(58,78), type = 'n',axes=F) box() axis( 1, at = lab.vals ) axis( 2, at = lab.vals ) abline( coef(lm(son ~ father ))) abline( a = 0 , b = 1 ) inv.reg <- coef( lm ( father ~ son ) ) abline( a = - inv.reg[1]/inv.reg[2], b = 1/inv.reg[2] )