Red Panda example from Bista et al (2024). 10 red pandas were captured and collared with GPS trackers from December 2019 to March 2020 to analyze the relationship between weather and disturbance effects on habitat preference.
red_panda <- read.csv("red_panda_data.csv")
pairs(red_panda[, c("Solar", "Elevation", "Road")], lower.panel = NULL)
correlation.matrix <- cor(red_panda[, c("Solar", "Elevation", "Road")])
round(correlation.matrix, 3)
## Solar Elevation Road
## Solar 1.000 0.000 -0.055
## Elevation 0.000 1.000 -0.096
## Road -0.055 -0.096 1.000
There is no collinearity because there are no predictor outputs that are above ~0.5.This means that all predictors are independent of each other.
parms_red_panda <- lm(Settlement ~ Solar + Elevation + Road, data = red_panda, na.action = na.fail)
olsrr::ols_plot_added_variable(parms_red_panda)
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
Both solar and elevation have a flat slope so it seems as if they do not contribute much explanatory power to the full model.
results <- MuMIn::dredge(parms_red_panda)
## Fixed term is "(Intercept)"
results
## Global model call: lm(formula = Settlement ~ Solar + Elevation + Road, data = red_panda,
## na.action = na.fail)
## ---
## Model selection table
## (Intrc) Elvtn Road Solar df logLik AICc delta weight
## 8 -267.8 0.21980 0.9396 -0.0008785 5 -4982.951 9976.0 0.00 0.772
## 7 357.4 0.9332 -0.0008805 4 -4985.183 9978.4 2.44 0.228
## 4 -383.7 0.22270 0.9487 4 -4996.184 10000.4 24.44 0.000
## 3 249.6 0.9422 3 -4998.392 10002.8 26.83 0.000
## 5 685.6 -0.0011590 3 -5271.021 10548.1 572.09 0.000
## 6 905.3 -0.07749 -0.0011590 4 -5270.897 10549.9 573.86 0.000
## 1 547.4 2 -5281.262 10566.5 590.55 0.000
## 2 766.9 -0.07742 3 -5281.141 10568.3 592.33 0.000
## Models ranked by AICc(x)
subset(results, delta <5)
## Global model call: lm(formula = Settlement ~ Solar + Elevation + Road, data = red_panda,
## na.action = na.fail)
## ---
## Model selection table
## (Intrc) Elvtn Road Solar df logLik AICc delta weight
## 8 -267.8 0.2198 0.9396 -0.0008785 5 -4982.951 9976.0 0.00 0.772
## 7 357.4 0.9332 -0.0008805 4 -4985.183 9978.4 2.44 0.228
## Models ranked by AICc(x)
Models 8 and 7 are the best results. Model 8 is about 3.39 times more likely than model 7 (0.772/0.228).
MuMIn::sw(results)
## Road Solar Elevation
## Sum of weights: 1.00 1.00 0.77
## N containing models: 4 4 4
All these predictors are useful because they are above 0.5, so I do not need to subset the data.
p3 <- ggplot(red_panda, aes(Solar, Settlement, colour = Elevation)) +
geom_point(size = 3) +
geom_smooth(method = "lm") +
scale_colour_gradientn(colours = heat.colors(10, rev=TRUE))
p4 <- ggplot(red_panda, aes(Elevation, Settlement, colour = Road)) +
geom_point(size = 3) +
geom_smooth(method = "lm") +
scale_colour_gradientn(colours = heat.colors(10, rev=TRUE))
p3+p4
## `geom_smooth()` using formula = 'y ~ x'
## Warning: The following aesthetics were dropped during statistical transformation:
## colour.
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
## the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
## variable into a factor?
## `geom_smooth()` using formula = 'y ~ x'
## Warning: The following aesthetics were dropped during statistical transformation:
## colour.
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
## the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
## variable into a factor?
Model 8 is still 3.39 times more likely than model 7 (0.772/0.228), this rescaled result is the same as before.