# # MATH 3330 B, October 2001 # # Week 5b: Multiple Regression # prestige pairs( prestige ) # simple regression fit1 <- lm( Income ~ Education , prestige ) summary( fit1 ) # multiple regression fit2 <- lm( Income ~ Education + Women , prestige) summary ( fit2 ) # predicting a model over a grid of points pred <- expand.grid( Education = 6:16, Women = 10*(0:10) ) pred pred$Income2 <- predict(fit2, newdata = pred ) pred$Income1 <- predict(fit1, newdata = pred ) pred td() # see in Fun.SSC wireframe( Income2 ~ Education + Women , pred ) wireframe( Income1 ~ Education + Women , pred ) pred1 <- pred pred1$Income <- pred$Income1 pred2 <- pred pred2$Income <- pred$Income2 pred.comb <- stack( pred1, pred2) # get the 'stack' function from Fun.ssc wireframe( Income ~ Education + Women | Type., pred.comb) plot( prestige$Women, prestige$Education ) data.ell( prestige$Women, prestige$Education ) # surprise!