...

We can also plot the results, including a plot of the likelihood surface of λ (which is well worth investigating - sometimes unexpected patterns are found, with peaks at 0 or 1!):

plot(log(GestationLen_d)~ log(AdultBodyMass_g), data = primatedata)abline(model.pgls) profile_lambda=pgls.profile(model.pgls, which="lambda") # vary lambda plot(profile_lambda)

The parameters κ and δ are additional branch-length transformations implemented in caper that can improve the fit of the data to the tree (See 7.3: Common branch length transformations for more details). To optimise κ or δ, use the arguments delta = "ML" or kappa = "ML" instead of lambda = "ML" in the code above. Note that optimising more than one of these parameters at the same time is not advisable because it would be nearly impossible to interpret the results! Also note that for κ, you will need a different variance-covariance structure from that used above, specifically a 3D vcv.array. To do so, use the vcv.dim argument when constructing your comparative data object:

...

## Other considerations

### Outliers

Outliers can seriously affect the parameter estimates for any regression model and PGLS models are no exception. Some researchers recommend the removal of outliers with studentized residuals >±3 (Jones and Purvis 1997). Note that caper does not at present have an automated outlier removal option (compare to crunch, section 7.2.2), but it may in the near future. Check ?pgls for updates.

To identify the outliers in a PGLS model, first you need to extract the phylogenetic residuals from the model:

res<- residuals(model.pgls, phylo = TRUE) #extracts phylogenetic residuals from the pgls model

...

Here are the model diagnostics for our model above:

Essentially what you are looking for in these plots are:

1) No studentised model residuals >±3. Any species with such large residuals should be removed. These outliers may overly influence the results of the regression.

2) The points of the Q-Q plot should approximately form a straight line (rather than a banana shape).

3 and 4) These should show a fairly random scattering of points. You want to avoid any clear patterns.

It takes practice to know what is “good”, “bad” and “acceptable” with these plots. These plots look OK, but there appear to be several outliers; it may be worth investigating how these outliers affect the results.

## References

Jones, K. E. & Purvis, A. 1997. An optimum body size for mammals? Comparative evidence from bats.Funct. Ecol.11: 751-756.

Orme, C. D. L., Freckleton, R. P., Thomas, G. H., Petzoldt, T., Fritz, S. A. & Isaac, N. J. B. in press. caper: Comparative Analyses of Phylogenetics and Evolution in R.Methods Ecol. Evol.