# This sample program is a prelim analysis of weight and height # data t<-matrix(scan("hawn.txt"),ncol=3,byrow=T) hawn <-data.frame(gender=as.factor(t[,1]),height=t[,2],weight=t[,3]) # Input gender, height and weight and declare gender as factor attach(hawn) # Numerical Summary summary(hawn) # Graphical Displays par(mfrow=c(2,2)); # Setup the graphical device hist(height); boxplot(height); qqnorm(height); plot(density(height)); stem(height); hist(weight); boxplot(weight); qqnorm(weight); plot(density(weight)); stem(weight); plot(height,weight,main="Weight (Y) vs Height (X)") windows() coplot(weight~height|gender) par(mfrow=c(2,2)); m1<-lm(weight~height) m2<-lm(height~weight) a0<-m2$coef[1];a1<-m2$coef[2]; p0<--a0/a1; p1<-1/a1; plot.lm(m1) plot.lm(m2) windows() par(mfrow=c(2,2)); plot(height,weight,main="I"); abline(m1$coef) plot(weight,height,main="II"); abline(m2$coef) plot(height,weight,main="III"); abline(c(p0,p1)) # Question: # a. Could you construct the missing Figure IV? # b. What's the difference between I vs. III? # c. What's the difference between II vs. IV? # d. Which one of the figure is more appropriate to # summarize the relation between weight and height? Explain.