We re-analysed the data from Loyn (1987; see Box 8.2 ) by fitting a simpler model that just included grazing and log patch area (based on our model selection criteria – see Box 9.1). First we treated grazing as a continuous variable like we did in the original analysis by fitting the following model:

(bird abundance)i = β0 + β1(log10 area)i + β2(grazing)i + εi

Preliminaries

First, load the required packages (car, lm.beta)

Import loyncat data file

This file is the loyn data, with grazing classified into five categories (“grazecat”). We could have simply turned the numerical grazing level into a factor, but this way the grazing levels have meaningful names

loyncat <- read.csv("../data/loyncat.csv")
head(loyncat,10)
loyncat$grazecat<-factor(loyncat$grazecat)

Fit linear model with grazing as continuous variable

loyncat1.lm <- lm(abund~log10(area)+graze, data=loyncat)
tidy(loyncat1.lm, conf.int=TRUE)

Get standardized coefficients

lm.beta(loyncat1.lm)

Call:
lm(formula = abund ~ log10(area) + graze, data = loyncat)

Standardized Coefficients::
(Intercept) log10(area)       graze 
         NA       0.521      -0.391 

Fit linear model with grazing as a categorical predictor

Use zero grazing as the reference category

loyncat2.lm <- lm(abund~log10(area)+relevel(grazecat,ref="zero"), data=loyncat)
tidy(loyncat2.lm, conf.int=TRUE)

Check residuals - look fine

plot(loyncat2.lm)

Get standardised coefficients

lm.beta(loyncat2.lm)

Call:
lm(formula = abund ~ log10(area) + relevel(grazecat, ref = "zero"), 
    data = loyncat)

Standardized Coefficients::
                           (Intercept)                            log10(area)    relevel(grazecat, ref = "zero")high relevel(grazecat, ref = "zero")intense     relevel(grazecat, ref = "zero")low 
                                    NA                                0.54847                               -0.04948                               -0.47202                                0.01259 
 relevel(grazecat, ref = "zero")medium 
                              -0.00788 

Get added variable plots

avPlots(loyncat2.lm, ask=F)

LS0tCnRpdGxlOiAiUUsgQm94IDguMTEiCgpvdXRwdXQ6IAogIGh0bWxfbm90ZWJvb2s6CiAgICB0aGVtZTogZmxhdGx5Ci0tLQoKYGBge3Igc2V0dXAsIGluY2x1ZGU9RkFMU0V9CmtuaXRyOjpvcHRzX2NodW5rJHNldChlY2hvID0gVFJVRSkKYGBgCgpXZSByZS1h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