# # 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(DAAG) funRel = function(x=leafshape$logpet, y=leafshape$loglen, scale=c(1,1)){ ## Find principal components rotation; see section 11.1 xy.pcr = prcomp( cbind(x,y), scale=scale ) b = xy.pcr$rotation[,2]/scale bxy = -b[1]/b[2] # slope - functional eqn line bint = mean(y) - bxy * mean(x) # intercept - functional eqn line c(bint,bxy) } x = leafshape$logpet y = leafshape$loglen x = softbacks$volume y = softbacks$weight x = elastic2$stretch y = elastic2$distance #postscript("../../WriteUp/Graphics/Chapter5/prob_12_plot.eps", onefile=FALSE, horizontal=FALSE) res1 = funRel(x,y,scale=c(1,1)) plot( x, y, xlab="logpet", ylab="loglen" ) abline( a=res1[1], b=res1[2], col="red" ) res2 = funRel(x,y,scale=c(1,10)) abline( a=res2[1], b=res2[2], col="blue" ) res3 = funRel(x,y,scale=c(10,1)) abline( a=res3[1], b=res3[2], col="green" ) #dev.off()