Help with fitting linear models and F-tests in R?

#1
Hello! I need some assistance with these problems dealing with the following data set:

Code:
"Brains" <-
structure(list(Species = structure(c(7, 11, 12, 19, 24, 25, 26, 
34, 37, 8, 3, 20, 30, 6, 36, 23, 15, 9, 18, 28, 32, 35, 39, 14, 
31, 38, 27, 5, 4, 21, 2, 13, 10, 17, 22, 33, 29, 1, 16), .Label = c("African.elephant", 
"baboon", "barracuda", "bat", "blue.whale", "brown.trout", "canary", 
"catfish", "cheetah", "chimpanzee", "crow", "flamingo", "grey.monkey", 
"greyhound", "grizzly.bear", "horse", "human", "lion", "loon", 
"mackerel", "mole", "mouse", "northern.trout", "ostrich", "pheasant", 
"pigeon", "porpoise", "raccoon", "rhinoceros", "salmon", "seal", 
"skunk", "squirrel", "stork", "tiger", "tuna", "vulture", "walrus", 
"wolf"), class = "factor"), Brain = c(0.848, 9.3, 8.05, 6.12, 
42.11, 3.289, 2.694, 16.24, 19.6, 1.84, 3.83, 0.64, 1.257, 0.57, 
3.09, 1.233, 233.9, 2.449, 106.7, 40, 10.3, 302, 152, 105.9, 
442, 1126, 1735, 6800, 0.936, 1.16, 140, 66.6, 440, 1377, 0.551, 
3.97, 655, 5712, 618), Body = c(0.0171, 0.337, 1.598, 1.53, 
123, 0.625, 0.282, 3.35, 5.27, 2.894, 5.978, 0.765, 3.93, 0.292, 
5.21, 2.5, 142.88, 22.2, 28.79, 5.175, 1.7, 209, 29.94, 24.49, 
107.3, 667, 142.43, 58059, 0.028, 0.0396, 7.9, 4.55, 56.69, 74, 
0.0177, 0.183, 763, 6654, 461.76), Class = structure(c(1, 1, 
1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3), .Label = c("bird", 
"fish", "mammal"), class = "factor")), .Names = c("Species", 
"Brain.WT", "Body.WT", "Class"), row.names = c("1", "2", "3", 
"4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", 
"16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", 
"27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", 
"38", "39"), class = "data.frame")
a. I need to fit the following models in the log scale and use the ANOVA/F-test to assess which model is best:

M1: log(Brain.WT)~ log(Body.WT)
M2: log(Brain.WT)~ log(Body.WT)+ Class
M3: log(Brain.WT)~ log(Body.WT)*Class​

So I'm a bit confused as to which ones I'm comparing to what. I think you compare M3 to M2 to start because M3 is the full model while M2 is the restricted model; same goes for M3 and M1 (but I'm not sure so please, correct me if I'm wrong). I don't think there's much sense in comparing M2 to M1 because they're both restricted models (I think...).

b. As you can see, there are three classes of animals: bird, fish, and mammal. I know the baseline term is bird, but I have to figure out (1) which group has the highest average log(Brain.WT) after controlling for log(Body.WT) and (2) which species seem unusually big brained or particularly small brained relative to their groups. I'm sure the second part of the question won't be as hard once I figure out how to do the first, but I honestly have no clue as to what I should do!

Any help you guys can provide would be incredibly helpful! Thanks so much for taking the time to read my post!
 

Jake

Cookie Scientist
#2
So I'm a bit confused as to which ones I'm comparing to what. I think you compare M3 to M2 to start because M3 is the full model while M2 is the restricted model; same goes for M3 and M1 (but I'm not sure so please, correct me if I'm wrong). I don't think there's much sense in comparing M2 to M1 because they're both restricted models (I think...).
As you say, M2 is a restricted version of M3, and M1 is also a restricted version of M3. But what you may not have realized is that M1 is also a restricted version of M2. If we start with M3, we can place 1 restriction on the model to arrive at M2, or 2 restrictions on the model to arrive at M1. If we start with M2, we can place 1 restriction on this model to arrive at M1.

(The exact number of restrictions listed above is not quite technically correct because you have 3 Classes, so knocking Class out of the model entirely involves placing restrictions on 2 model parameters at once instead of just 1, and ditto for the interactions with Class, but hopefully you get the conceptual idea... M1 is nested in M2, which is in turn nested in M3.)

As you can see, there are three classes of animals: bird, fish, and mammal. I know the baseline term is bird, but I have to figure out (1) which group has the highest average log(Brain.WT) after controlling for log(Body.WT) and (2) which species seem unusually big brained or particularly small brained relative to their groups.
Testing these more specific questions involve comparisons to restricted model(s) that you have not listed in your post, specifically, models where we place a restriction on only 1 of the 2 parameters that comprise the total Class effect. In terms of nesting, these models would be either in between M1 and M2 or in between M2 and M3 (depending on exactly which question you are asking).