Section 2 Collar temperature and ambient temperature

Here we model the relationship between the temperature reported by inbuilt temperature sensors on the elephants’ GPS collars, and the ambient temperature recorded at Skukuza. For this comparison, we will only use data from positions recorded within 10 km of the weathe weather tower at Skukuza.

2.3 Select ele data near tower

2.3.2 Clean filtered data

Here, process the date and time by converting the Date_Time column to POSIXct. Then convert time to POSIXct by adding the proportional daily time to the numeric date. Finally, round the time to the nearest half hour. As a sanity check, do the increments of Time_Number follow the increments in time?

2.4 Combine collar and ambient temp

2.4.1 Prepare data for Bland-Altman

Join the elephant data within 10 km of the tower with ambient temperature data from the tower by the time column. Exploring the data reveals that ambient temperature data records NA as -9999. Filter the data to exclude these values.

2.5 Exploring collar and ambient temp

2.5.4 Prepare Bland-Altman plots

Plot the hour-wise relationship between collar temperature and ambient temperature, and the hour-wise Bland-Altman plots.

#'make appendix figure a
fig_temp_rel_hr = 
  ggplot()+
  geom_rangeframe(data = data_frame(x=c(10,40), y = c(0,40)), aes(x,y))+
  geom_point(data = ele.BA.data, aes(x = temp.a, y = temp), size = 0.1, alpha = 0.2)+
  geom_smooth(data = ele.tempmod.fit, aes(x = temp.a, y = pred), method = "glm", 
              col = "steelblue")+
  geom_abline(slope = 1, lty = 2, col = 1, lwd = 0.2)+
  scale_x_continuous(breaks = c(10,25,40))+
  facet_wrap(~hour.plot, nrow = 4)+
  theme_few()+
  coord_fixed()+
  theme(panel.border = element_blank())+
  labs(x = "Ambient temperature (°C)", y = "Collar temperature (°C)", title = "(a)")

#'appendix figure b
fig_ba_hour = 
  ggplot()+
  geom_rangeframe(data = data_frame(x=c(10,40), y = c(-10,30)), aes(x,y))+
  geom_point(data = ele.BA.data, aes(x = mean.temp, y = diff), 
             size = 0.1, alpha = 0.2)+
  geom_abline(slope = 0, lty = 2, col = 1, lwd = 0.2)+
  geom_hline(data = mean_diff, aes(yintercept = diff), col = "brown")+
  geom_hline(data = mean_diff, aes(yintercept = 1.96*sd_id + diff), col = "steelblue")+
  geom_hline(data = mean_diff, aes(yintercept = diff - 1.96*sd_id), col = "steelblue")+
  #coord_cartesian(ylim = c(0,40), xlim = c(0,40))+
  scale_y_continuous(breaks = seq(-10,30, 10))+
  
  scale_x_continuous(breaks = c(10,25,40))+
  theme_few()+
  theme(panel.background = element_blank())+
  facet_wrap(~hour.plot, nrow = 4)+
  coord_fixed()+
  theme(panel.border = element_blank())+
  labs(x = "Mean (amb & collar) temp. (°C)", y = "Collar - amb. temp. (°C)", title = "(b)")

fig_hourwise_collar_ambient = patchwork::wrap_plots(fig_temp_rel_hr, fig_ba_hour, nrow = 1)

ggsave(fig_hourwise_collar_ambient, 
       filename = "figs/fig_hourwise_collar_ambient.png", 
       device = png(), height = 180/25.4, width = 1.5*180*1.2/25.4, dpi = 300)

2.6 Model collar and ambient temp

2.6.1 LMM collar and ambient temp

Run a global linear mixed effects model for collar temperature as a function of ambient temperature. Write the model summary to a text file.

Print the model summary.

Linear mixed model fit by REML ['lmerMod']
Formula: temp ~ temp.a + season + (1 | hour) + (1 | id)
   Data: data.tow.clean.ba

REML criterion at convergence: 24309.2

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-4.4298 -0.5697  0.1309  0.6407  3.2027 

Random effects:
 Groups   Name        Variance Std.Dev.
 hour     (Intercept) 13.695   3.701   
 id       (Intercept)  1.067   1.033   
 Residual              9.683   3.112   
Number of obs: 4730, groups:  hour, 24; id, 3

Fixed effects:
            Estimate Std. Error t value
(Intercept) 12.56467    1.00625  12.487
temp.a       0.70310    0.01238  56.783
seasonwet    0.13777    0.09352   1.473

Correlation of Fixed Effects:
          (Intr) temp.a
temp.a    -0.278       
seasonwet -0.058  0.062
Analysis of Deviance Table (Type II Wald chisquare tests)

Response: temp
           Chisq Df Pr(>Chisq)    
temp.a 3224.2777  1     <2e-16 ***
season    2.1701  1     0.1407    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

2.7 Global Bland-Altman test

Prepare a global Bland Altman test and associated plots.

2.7.2 GAMM for Bland-Altman trend

Print the GAMM summary.


Family: gaussian 
Link function: identity 

Formula:
diff.measures ~ s(mean.measures, by = season)

Parametric coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)   6.1849     0.2935   21.07   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Approximate significance of smooth terms:
                           edf Ref.df     F  p-value    
s(mean.measures):seasondry   1  1.001 16.91 0.000235 ***
s(mean.measures):seasonwet   1  1.000 17.05 0.000224 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

R-sq.(adj) =  0.485   Deviance explained = 51.5%
GCV = 3.2899  Scale est. = 3.0079    n = 35

2.8 Figure 3: Collar and ambient temperature

**(a)** Mean collar temperature (solid lines) and measured ambient temperature from Skukuza flux tower (dashed lines) at each hour of day in each season (dry: red lines, wet: blue lines) over the study period. Ninety-Five percent confidence intervals (CI) about each line are shaded. **(b)** Correlation between mean collar temperature from elephants within 10 km of the Skukuza flux tower (from n = 3 elephants) and time-matched ambient temperatures measured by the flux tower in each season (dry: red circles, wet: blue triangles). The dashed line denotes the line of identity where collar temperature equals ambient temperature. Bars represent 95% CI at each point. **(c)** Bland-Altman limits of agreement plot comparing collar temperatures and ambient temperatures from the Skukuza flux tower, accounting for repeated measures of individual elephants and hour of day (n = 28,853 total comparisons). The bias between the two measures at each mean temperature is marked by symbols colored by season (dry: red circles, wet: blue triangles). The black dashed line marks zero difference between the two measures. The upper and lower limits of agreement are shown as the standard normal deviate (1.96) times the standard deviation due to elephant identity, and are marked by solid blue lines, while the mean difference in measures is marked by the solid red line.

(#fig:show_figure_03)(a) Mean collar temperature (solid lines) and measured ambient temperature from Skukuza flux tower (dashed lines) at each hour of day in each season (dry: red lines, wet: blue lines) over the study period. Ninety-Five percent confidence intervals (CI) about each line are shaded. (b) Correlation between mean collar temperature from elephants within 10 km of the Skukuza flux tower (from n = 3 elephants) and time-matched ambient temperatures measured by the flux tower in each season (dry: red circles, wet: blue triangles). The dashed line denotes the line of identity where collar temperature equals ambient temperature. Bars represent 95% CI at each point. (c) Bland-Altman limits of agreement plot comparing collar temperatures and ambient temperatures from the Skukuza flux tower, accounting for repeated measures of individual elephants and hour of day (n = 28,853 total comparisons). The bias between the two measures at each mean temperature is marked by symbols colored by season (dry: red circles, wet: blue triangles). The black dashed line marks zero difference between the two measures. The upper and lower limits of agreement are shown as the standard normal deviate (1.96) times the standard deviation due to elephant identity, and are marked by solid blue lines, while the mean difference in measures is marked by the solid red line.

2.9 Collar temperature and LANDSAT temperatures

Having examined the correlation between collar temperature and ambient temperature over the diel cycle at a small spatial scale, we now look at the correlation with LANDSAT-5 temperature data at the spatial scale of the study area, i.e., southern Kruger.

2.9.2 Run model

Print the model summary.

[[1]]
Linear mixed model fit by REML ['lmerMod']
Formula: temp ~ temp.a + season + (1 | hour) + (1 | id)
   Data: data.tow.clean.ba

REML criterion at convergence: 24309.2

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-4.4298 -0.5697  0.1309  0.6407  3.2027 

Random effects:
 Groups   Name        Variance Std.Dev.
 hour     (Intercept) 13.695   3.701   
 id       (Intercept)  1.067   1.033   
 Residual              9.683   3.112   
Number of obs: 4730, groups:  hour, 24; id, 3

Fixed effects:
            Estimate Std. Error t value
(Intercept) 12.56467    1.00625  12.487
temp.a       0.70310    0.01238  56.783
seasonwet    0.13777    0.09352   1.473

Correlation of Fixed Effects:
          (Intr) temp.a
temp.a    -0.278       
seasonwet -0.058  0.062

[[2]]
Analysis of Deviance Table (Type II Wald chisquare tests)

Response: temp
           Chisq Df Pr(>Chisq)    
temp.a 3224.2777  1     <2e-16 ***
season    2.1701  1     0.1407    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1