mm<-read.table("http://www.uwyo.edu/crawford/datasets/morphometrics.txt",header=TRUE)
plot(mm)
plot(Bicep~Chest,data=mm)
plot(Bicep~Fore,data=mm)
#some plots hint that multicollinearity
#is going to be a problem here
fit<-lm(Mass~Fore+Bicep+Chest+Neck+Shoulder+Waist+Height+Calf+Thigh+Head,data=mm)
par(mfrow=c(2,2))
plot(fit)
par(mfrow=c(1,1))
#Looks good with residuals
#let's see if we need all those variables
summary(fit)
#let's remove shoulder because the p-value is largest
fit<-lm(Mass~Fore+Bicep+Chest+Neck+Waist+Height+Calf+Thigh+Head,data=mm)
summary(fit)
#let's remove bicep because the p-value is largest
fit<-lm(Mass~Fore+Chest+Neck+Waist+Height+Calf+Thigh+Head,data=mm)
summary(fit)
#let's remove neck because the p-value is largest
fit<-lm(Mass~Fore+Chest+Waist+Height+Calf+Thigh+Head,data=mm)
summary(fit)
#let's remove chest because the p-value is largest
fit<-lm(Mass~Fore+Waist+Height+Calf+Thigh+Head,data=mm)
summary(fit)
#let's remove calf because the p-value is largest
fit<-lm(Mass~Fore+Waist+Height+Thigh+Head,data=mm)
summary(fit)
#let's remove head because the p-value is largest
fit<-lm(Mass~Fore+Waist+Height+Thigh,data=mm)
summary(fit)
#check the residuals just as a sanity check
par(mfrow=c(2,2))
plot(fit)
par(mfrow=c(1,1))
#let's start over with a different tactic
fit<-lm(Mass~Fore+Bicep+Chest+Neck+Shoulder+Waist+Height+Calf+Thigh+Head,data=mm)
summary(fit)
#Let's delete thigh because it was not significant and it's
#weird to measure someone's thigh
fit<-lm(Mass~Fore+Bicep+Chest+Neck+Shoulder+Waist+Height+Calf+Head,data=mm)
summary(fit)
#Let's delete chest because it was not significant and it's
#weird to imagine
fit<-lm(Mass~Fore+Bicep+Neck+Shoulder+Waist+Height+Calf+Head,data=mm)
summary(fit)
#Let's delete calf because it was not significant and it's
#hard to measure
fit<-lm(Mass~Fore+Bicep+Neck+Shoulder+Waist+Height+Head,data=mm)
summary(fit)
#Let's delete shoulder because of the large pvalue
fit<-lm(Mass~Fore+Bicep+Neck+Waist+Height+Head,data=mm)
summary(fit)
#Let's delete bicep because I feel intimidated by large biceps
fit<-lm(Mass~Fore+Neck+Waist+Height+Head,data=mm)
summary(fit)
#Let's delete neck because of the large pvalue
fit<-lm(Mass~Fore+Waist+Height+Head,data=mm)
summary(fit)
#Let's delete head because it's got a big p-value
fit<-lm(Mass~Fore+Waist+Height,data=mm)
summary(fit)
#let's start over again
fit<-lm(Mass~Fore+Bicep+Chest+Neck+Shoulder+Waist+Height+Calf+Thigh+Head,data=mm)
summary(fit)
#delete waist because it's such a sensative topic
fit<-lm(Mass~Fore+Bicep+Chest+Neck+Shoulder+Height+Calf+Thigh+Head,data=mm)
summary(fit)
#delete the biggest p-value bicep
fit<-lm(Mass~Fore+Chest+Neck+Shoulder+Height+Calf+Thigh+Head,data=mm)
summary(fit)
#delete the biggest p-value chest
fit<-lm(Mass~Fore+Chest+Neck+Shoulder+Height+Calf+Thigh+Head,data=mm)
summary(fit)
#delete the biggest p-value Head
fit<-lm(Mass~Fore+Neck+Shoulder+Height+Calf+Thigh,data=mm)
summary(fit)
#delete the biggest p-value Neck
fit<-lm(Mass~Fore+Shoulder+Height+Calf+Thigh,data=mm)
summary(fit)
#delete the biggest p-value Calf
fit<-lm(Mass~Fore+Shoulder+Height+Thigh,data=mm)
summary(fit)
#delete the biggest p-value Shoulder
fit<-lm(Mass~Fore+Height+Thigh,data=mm)
summary(fit)
#check the residuals just as a sanity check
par(mfrow=c(2,2))
plot(fit)
par(mfrow=c(1,1))