Listed below are the log body weights and log brain weights ofthe primates species in the data set ”mammals”. Find the equationof the least squares line with y = log brain weight and x = logbody weight. Do it by hand, by constructing a table like the one inExample 9.1. Then do it with your calculator as efficiently aspossible. Finally, use the lm function in R to do it by creating alinear model object ”primates.lm”. The model formula is”log(brain)?log(body)”. You can select the primates and put them ina new data frame by first listing the primate species names:
> primatenames=c(”Owl monkey”, ”Patas monkey”, ”Gorilla”,etc.)
and then
> primates=mammals[primatenames, ]
Your ”data” argument in calling lm would be ”data=primates”, asin
> primates.lm=lm(log(brain)?log(body),data=primates)
Alternatively, you can just use ”mammals[primatenames, ]” as thedata argument in lm, that is,
> primates.lm=lm(log(brain)?log(body),data=mammals[primatenames,])
log body log brain
Owl monkey -0.7339692 2.740840
Patas monkey 2.3025851 4.744932
Gorilla 5.3327188 6.006353
Human 4.1271344 7.185387
Rhesus monkey 1.9169226 5.187386
Chimpanzee 3.9543159 6.086775
Baboon 2.3561259 5.190175
Verbet 1.4327007 4.060443
Galago -1.6094379 1.609438
Slow loris 0.3364722 2.525729