The aim of these exercises is to improve your ability to deal with multi-predictor linear models where we have a single continuous response and the two or more predictors are all continuous or a mixture of continuous and categorical.
Let’s continue with the Martello et al. (2022) example from Chapter 7 assessing whether dietary supplements improve the perceived health of dogs with osteoarthritis. The model we focused on at the end of that exercise was one modelling the pain index of dogs after 60 days as a function of whether they received dietary supplements or a placebo and the sex of the dog. The dogs unavoidably varied in body weight, ranging from 14-47 kg. To partly account for this, the authors adjusted the doses to a constant amount per kg of body weight. However, you can probably think of a range of ways in which weight might affect osteoarthritis. The model using treatment and sex fitted the data fairly well, with r2 around 0.6. We detected a strong treatment effect, but it is possible that if we reduced background noise, we might see sex-specific responses and we’d also get a more precise estimate of the effects.
Think about the steps you’d take to see if it would be helpful to include body weight in the model, then go back to the data and run the analysis.
df <- read.csv("../data/martello.csv")
La Rosa and Conner (2017) examined effects of several floral traits on fitness components of milkweeds, Asclepias spp. The fitness components were male and female pollination success and female reproductive success.
In the paper, their analysis focused on 6 predictors, They measured six floral traits, although one of them, hood height, was not relevant for Asclepias viridiflora, which was the species with the largest sample size:
Their Figure 2 shows what these measurements represent on flowers.
The data are available from Dryad here.
Fitness component estimates were relativized by dividing by the mean, and the traits were standardized to a mean of zero and standard deviation of one.
First look at the removals per flower
What checks should you do before assessing the predictors’ effects?
If you’re happy with your pre-flight checks, fit the model and make some conclusions about the effects of each predictor, including any notes of caution
What would you need to check in doing analyses on three different fitness components as response variables?
What do you conclude about the floral traits’ influence on fitness components of this species?
What do you conclude about the role of floral traits in these two species?
Is there anything you’d be cautious about in making this comparison?
Recall the sengi example (Kaufman et al. (2013)) from Chapter 5 (or go back and look at it ;-)) where we looked at the relationship between brain mass and body mass in small insectivore species. Now we will look at how this relationship varies between families of insectivores, including whether sengis are different from the rest. There are 3 groups of insectivores, sengis and closely (afrotherian) and more distantly (laurasiatherian) species, and the research question is about where sengis fit. We can frame this as 2 or 3 questions.
Does the new species (udzugwensis) fit within the pattern of other sengi?
Are sengi different from the other small insectivores in their brain size?
sengi vs all others, or
sengi vs closely-related vs distantly related insectivores
Get started by loading the kaufman data.
df <- read.csv("../data/kaufman.csv")
head(df,10)
## family genus species bodymass brainmass relation
## 1 Solenodontidae Solenodon paradoxus 672.0 4723 laurasiatherian
## 2 Tenrecidae Tenrec ecaudatus 852.0 2588 afrotherian
## 3 Tenrecidae Setifer setosus 237.0 1516 afrotherian
## 4 Tenrecidae Hemicentetes semispin 116.0 839 afrotherian
## 5 Tenrecidae Echinops telfairi 87.5 623 afrotherian
## 6 Tenrecidae Oryzorictes talpoides 44.2 580 afrotherian
## 7 Tenrecidae Microgale cowani 15.2 420 afrotherian
## 8 Tenrecidae Limnogale mergulus 92.0 1150 afrotherian
## 9 Tenrecidae Microgale dobsoni 31.9 557 afrotherian
## 10 Tenrecidae Microgale talazaci 48.2 766 afrotherian
## relation2
## 1 other insectivore
## 2 other insectivore
## 3 other insectivore
## 4 other insectivore
## 5 other insectivore
## 6 other insectivore
## 7 other insectivore
## 8 other insectivore
## 9 other insectivore
## 10 other insectivore
In Chapter 5, you should have decided that log-transforming both variables was sensible, so lets also start by defining new variables logbrain and logbody. That will make the coding tidier, without having to log things repeatedly.
df$logbrain <- log(df$brainmass)
df$logbody <- log(df$bodymass)
For the first question, cast your mind back to Chapter 6. How would you decide whether the new species is unusual?
** You could make this comparison in two ways:
**Before you start, are there any things to check in the original data, linked to the assumptions of the linear model you’ll fit?
Outline the steps you’ll take
Run the analysis
We’ll return to the elephant seal example in the study by Le Boeuf et al. (2000) and see whether body weight plays any role in foraging. In Chapter 5, you should have noticed that while the focus of the initial analysis was on the relationship between time spend on the foraging grounds and distance travelled, the authors recorded weight on departure for each animal. Your exploratory data analysis should have shown a relationship between body weight and the original predictor and response variables. Now try and make some sense of what’s going on here.
Think about how body mass might influence distance travelled and how it might contribute to time on foraging areas
How will you assess whether including body weight as a second predictor helps us understand feeding time better?
Write out the linear model you’d apply
What checks do you need when fitting the model?
#Get the data file back
df <- read.csv("../data/leboeuf.csv")
head(df,10)
## male departwt distance FFAduration durationto durationfrom
## 1 Pop NA 534 31 18 11
## 2 Alt 973 755 89 9 8
## 3 Pro 977 1210 77 12 18
## 4 Hal 1121 NA NA NA NA
## 5 Blu NA 1297 76 19 25
## 6 Dua 996 1487 68 18 23
## 7 Rov 1100 2073 69 29 25
## 8 Ric 1068 2181 46 21 42
## 9 Ori 1097 NA NA NA NA
## 10 Jer 1199 NA NA NA NA
Fit the appropriate model to the data, interpret the results, and explain whether body weight helps us.
Is there anything else you might look at?