Temperature strongly influences the physiological performance of lizards, and many species rely on behavioral thermoregulation to keep their body temperatures within a preferred range. The Mediterranean gecko (Hemidactylus turcicus) is an introduced species that occurs along the Gulf Coast and has recently expanded its range northward into cooler environments such as Edmond, Oklahoma. Understanding how well these geckos regulate their body temperatures in different environments can help clarify whether they are effective thermoregulators or simply thermoconforming to ambient conditions. To address this question, geckos were collected on building walls at field sites. For each gecko, I measured (1) body temperature (Tb), (2) the temperature of the wall immediately adjacent to the lizard (Tw), (3) environmental wall temperatures taken at random locations along walls where geckos were found (Te), and (4) preferred body temperatures (Tp) measured later in the lab using a thermal gradient. I am interested in whether there are differences among Te, Tw, Tb, and Tp. In particular, I want to know whether geckos maintain body temperatures different from the available environmental temperatures (Te and Tw), and whether their field body temperatures (Tb) are close to their preferred temperatures (Tp).
Tidyverse is used for cleaning up and manipulating data. Rmisc is used to calcualte summary statistics. car is used to conduct the ANOVA. forcats is used to format data in ways that facilitate analysis and graphing of categorical data. FSA is used for running Dunn’s test after a Kruskal-Wallis test.
pacman::p_load(tidyverse, Rmisc, car, forcats, FSA)
The data file is made up of 2 main columns used in this analysis.
Column 1 (Type) contains categorical data identifying the
type of temperature being measured in the study. Values include
environmental wall temperature (Te), wall temperature next to the lizard
(Tw), body temperature (Tb), and preferred body temperature (Tp). Column
2 (Temperature) contains the temperature values (in °C).
This constitutes a single-factor design with temperature type as the
categorical variable.
df <- read.csv("tempdata.csv") # use your actual file name here
head(df) # check the first 6 rows of data
## Season Population Type Temperature
## 1 Summer Galveston Tb 29.89
## 2 Summer Galveston Tb 32.22
## 3 Summer Galveston Tb 30.17
## 4 Summer Galveston Tb 31.44
## 5 Summer Galveston Tb 29.67
## 6 Summer Galveston Tb 30.72
str(df) # get the structure of the dataframe
## 'data.frame': 1255 obs. of 4 variables:
## $ Season : chr "Summer" "Summer" "Summer" "Summer" ...
## $ Population : chr "Galveston" "Galveston" "Galveston" "Galveston" ...
## $ Type : chr "Tb" "Tb" "Tb" "Tb" ...
## $ Temperature: num 29.9 32.2 30.2 31.4 29.7 ...
df$Type <- as.factor(df$Type) # change Type column to a factor
str(df) # recheck structure
## 'data.frame': 1255 obs. of 4 variables:
## $ Season : chr "Summer" "Summer" "Summer" "Summer" ...
## $ Population : chr "Galveston" "Galveston" "Galveston" "Galveston" ...
## $ Type : Factor w/ 4 levels "Tb","Te","Tp",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ Temperature: num 29.9 32.2 30.2 31.4 29.7 ...
summary(df) # get a general summary of the dataframe
## Season Population Type Temperature
## Length:1255 Length:1255 Tb:182 Min. : 6.78
## Class :character Class :character Te:723 1st Qu.:19.00
## Mode :character Mode :character Tp:168 Median :26.00
## Tw:182 Mean :24.32
## 3rd Qu.:29.50
## Max. :35.78
The following code forces R to treat the Temperature Types in the order in which they appear in the experiment rather than reordering them alphabetically. This is useful because the temperature types progress biologically from the ambient environment to the gecko’s preferred temperature. In this order, Te represents environmental temperature, Tw represents the wall temperature next to the lizard, Tb represents field body temperature, and Tp represents preferred body temperature measured in the lab.
df$Type <- factor(df$Type,
levels = c("Te", "Tw", "Tb", "Tp")) # keeps the temperature type levels in order
str(df) # check the structure again
## 'data.frame': 1255 obs. of 4 variables:
## $ Season : chr "Summer" "Summer" "Summer" "Summer" ...
## $ Population : chr "Galveston" "Galveston" "Galveston" "Galveston" ...
## $ Type : Factor w/ 4 levels "Te","Tw","Tb",..: 3 3 3 3 3 3 3 3 3 3 ...
## $ Temperature: num 29.9 32.2 30.2 31.4 29.7 ...
This block of code sets universal formatting instructions for all graphs generated in this script.
th <- theme_bw() +
theme(plot.title = element_text(size = 20, hjust = 0.5),
axis.title.y = element_text(size = 20),
axis.title.x = element_text(size = 20),
axis.text.x = element_text(size = 16),
axis.text.y = element_text(size = 16)) +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank()) +
theme(legend.position = c(0.6, 0.95),
legend.justification = c("right", "top"),
legend.box.just = "right",
legend.margin = margin(6, 6, 6, 6))
It is almost always useful to examine the data prior to analysis because it might reveal some potential problems with the data before getting too far into the analysis. So, the following set of code chunks creates a basic graphic of the data.
plot1 <- ggplot(df, aes(x = Type, y = Temperature,
colour = Type, group = Type, fill = Type)) +
geom_dotplot(binaxis = "y", stackdir = "center") +
xlab("Temperature Type") +
ylab("Temperature (°C)") +
ggtitle("Temperatures by Type in Mediterranean Geckos") +
th
plot1
## Bin width defaults to 1/30 of the range of the data. Pick better value with
## `binwidth`.
The following code calculates summary data for the dataframe and saves it in a dataframe called cipplot.
cipplot <- summarySE(df, measurevar = "Temperature", groupvars = "Type")
cipplot
## Type N Temperature sd se ci
## 1 Te 723 23.11526 6.689431 0.2487826 0.4884238
## 2 Tw 182 25.16308 6.095890 0.4518574 0.8915857
## 3 Tb 182 26.07148 6.444087 0.4776675 0.9425130
## 4 Tp 168 26.73077 2.101961 0.1621698 0.3201671
We can now use these data to add points for the mean with their associated error bars showing the 95% confidence interval.
plot1 +
geom_point(data = cipplot,
aes(x = Type, y = Temperature),
size = 3,
position = position_nudge(x = 0.25)) +
geom_errorbar(data = cipplot,
aes(x = Type,
ymax = Temperature + ci,
ymin = Temperature - ci),
width = 0.1,
position = position_nudge(x = 0.25))
## Bin width defaults to 1/30 of the range of the data. Pick better value with
## `binwidth`.
The code that follows creates a linear model for the ANOVA wherein the response variable (Temperature) is influenced by the independent variable (Type).
model <- lm(Temperature ~ Type, data = df)
I first checked the assumption that the data are normally distributed. I used the Shapiro–Wilk test for this. To increase statistical power, I calculated the residuals (deviations from the Type means; this is basically the within-Type variation), graphed the data with a histogram and a Q–Q plot, and then conducted the Shapiro–Wilk test on the aggregate residuals from the entire experiment.
res <- residuals(model)
res
## 1 2 3 4 5 6
## 3.81851648 6.14851648 4.09851648 5.36851648 3.59851648 4.64851648
## 7 8 9 10 11 12
## 4.09851648 5.03851648 5.70851648 5.09851648 4.92851648 3.20851648
## 13 14 15 16 17 18
## 6.75851648 2.70851648 4.14851648 3.70851648 4.42851648 4.86851648
## 19 20 21 22 23 24
## 6.36851648 4.31851648 8.70851648 3.20851648 3.98851648 3.48851648
## 25 26 27 28 29 30
## 6.20851648 4.98851648 3.03851648 5.03851648 2.03851648 2.70851648
## 31 32 33 34 35 36
## 3.92851648 5.09851648 5.25851648 4.53851648 2.98851648 3.75851648
## 37 38 39 40 41 42
## 2.92851648 4.36851648 3.20851648 3.31851648 5.03851648 4.92851648
## 43 44 45 46 47 48
## 4.31851648 3.92851648 3.36851648 3.25851648 2.70851648 3.14851648
## 49 50 51 52 53 54
## 3.20851648 2.42851648 3.59851648 3.03851648 5.48851648 5.42851648
## 55 56 57 58 59 60
## 5.64851648 4.75851648 5.14851648 4.25851648 3.25851648 3.75851648
## 61 62 63 64 65 66
## 3.20851648 3.64851648 5.64851648 6.86851648 5.81851648 6.14851648
## 67 68 69 70 71 72
## 4.86851648 3.53851648 3.64851648 3.86851648 4.98851648 8.03851648
## 73 74 75 76 77 78
## 4.53851648 5.09851648 7.03851648 7.92851648 3.92851648 4.36851648
## 79 80 81 82 83 84
## 3.86851648 3.48851648 5.92851648 4.59851648 -3.18148352 3.03851648
## 85 86 87 88 89 90
## 2.75851648 3.03851648 3.25851648 1.86851648 3.14851648 3.86851648
## 91 92 93 94 95 96
## 3.31851648 1.64851648 1.81851648 1.86851648 4.48851648 1.36851648
## 97 98 99 100 101 102
## 4.25851648 4.31851648 4.92851648 3.75851648 1.98851648 8.59851648
## 103 104 105 106 107 108
## 2.36851648 6.20851648 1.20851648 2.31851648 2.48851648 2.86851648
## 109 110 111 112 113 114
## 3.09851648 -0.35148352 -0.90148352 0.14851648 11.16474412 10.99474412
## 115 116 117 118 119 120
## 10.88474412 10.60474412 10.60474412 10.38474412 9.66474412 9.49474412
## 121 122 123 124 125 126
## 9.21474412 9.16474412 9.05474412 8.94474412 8.82474412 8.71474412
## 127 128 129 130 131 132
## 8.60474412 8.49474412 8.38474412 7.99474412 7.94474412 7.94474412
## 133 134 135 136 137 138
## 7.82474412 7.82474412 7.77474412 7.71474412 7.71474412 7.66474412
## 139 140 141 142 143 144
## 7.66474412 7.66474412 7.60474412 7.60474412 7.49474412 7.49474412
## 145 146 147 148 149 150
## 7.44474412 7.38474412 7.32474412 7.32474412 7.32474412 7.32474412
## 151 152 153 154 155 156
## 7.32474412 7.27474412 7.27474412 7.21474412 7.21474412 7.21474412
## 157 158 159 160 161 162
## 7.21474412 7.16474412 7.16474412 7.16474412 7.10474412 7.10474412
## 163 164 165 166 167 168
## 7.05474412 7.05474412 7.05474412 6.99474412 6.99474412 6.99474412
## 169 170 171 172 173 174
## 6.94474412 6.94474412 6.94474412 6.82474412 6.71474412 6.71474412
## 175 176 177 178 179 180
## 6.66474412 6.66474412 6.66474412 6.49474412 6.49474412 6.44474412
## 181 182 183 184 185 186
## 6.44474412 6.38474412 6.32474412 6.32474412 6.27474412 6.27474412
## 187 188 189 190 191 192
## 6.27474412 6.27474412 6.21474412 6.21474412 6.16474412 6.16474412
## 193 194 195 196 197 198
## 6.16474412 6.16474412 6.10474412 6.10474412 6.10474412 6.10474412
## 199 200 201 202 203 204
## 6.10474412 6.10474412 6.05474412 6.05474412 5.99474412 5.99474412
## 205 206 207 208 209 210
## 5.99474412 5.99474412 5.99474412 5.94474412 5.94474412 5.94474412
## 211 212 213 214 215 216
## 5.88474412 5.88474412 5.82474412 5.82474412 5.77474412 5.77474412
## 217 218 219 220 221 222
## 5.71474412 5.71474412 5.60474412 5.60474412 5.49474412 5.27474412
## 223 224 225 226 227 228
## 5.27474412 5.21474412 5.16474412 5.05474412 4.88474412 4.77474412
## 229 230 231 232 233 234
## 4.71474412 4.10474412 3.99474412 12.66474412 12.55474412 11.94474412
## 235 236 237 238 239 240
## 11.82474412 11.82474412 10.88474412 10.77474412 10.77474412 10.71474412
## 241 242 243 244 245 246
## 10.60474412 10.27474412 10.27474412 10.21474412 10.21474412 10.05474412
## 247 248 249 250 251 252
## 9.94474412 9.94474412 9.71474412 9.60474412 9.49474412 9.32474412
## 253 254 255 256 257 258
## 9.27474412 9.27474412 9.27474412 9.21474412 9.21474412 9.16474412
## 259 260 261 262 263 264
## 9.16474412 9.10474412 9.10474412 9.05474412 8.99474412 8.94474412
## 265 266 267 268 269 270
## 8.77474412 8.44474412 8.44474412 8.27474412 8.21474412 8.10474412
## 271 272 273 274 275 276
## 8.05474412 7.99474412 7.99474412 7.82474412 7.82474412 7.82474412
## 277 278 279 280 281 282
## 7.77474412 7.77474412 7.66474412 7.66474412 7.66474412 7.66474412
## 283 284 285 286 287 288
## 7.55474412 7.55474412 7.49474412 7.44474412 7.38474412 7.38474412
## 289 290 291 292 293 294
## 7.32474412 7.32474412 7.27474412 7.16474412 7.10474412 7.10474412
## 295 296 297 298 299 300
## 7.10474412 7.05474412 7.05474412 7.05474412 6.99474412 6.99474412
## 301 302 303 304 305 306
## 6.99474412 6.94474412 6.88474412 6.88474412 6.82474412 6.82474412
## 307 308 309 310 311 312
## 6.82474412 6.77474412 6.71474412 6.71474412 6.71474412 6.71474412
## 313 314 315 316 317 318
## 6.71474412 6.71474412 6.66474412 6.60474412 6.60474412 6.60474412
## 319 320 321 322 323 324
## 6.60474412 6.55474412 6.49474412 6.49474412 6.49474412 6.44474412
## 325 326 327 328 329 330
## 6.38474412 6.38474412 6.38474412 6.32474412 6.32474412 6.21474412
## 331 332 333 334 335 336
## 6.21474412 6.21474412 6.16474412 6.10474412 6.10474412 6.10474412
## 337 338 339 340 341 342
## 6.10474412 6.10474412 6.05474412 5.99474412 5.99474412 5.94474412
## 343 344 345 346 347 348
## 5.94474412 5.88474412 5.88474412 5.88474412 5.88474412 5.77474412
## 349 350 351 352 353 354
## 5.77474412 5.71474412 5.71474412 5.66474412 5.66474412 5.49474412
## 355 356 357 358 359 360
## 5.44474412 5.44474412 5.44474412 5.32474412 5.21474412 5.16474412
## 361 362 363 364 365 366
## 5.10474412 5.05474412 4.99474412 4.94474412 4.94474412 4.88474412
## 367 368 369 370 371 372
## 4.88474412 4.88474412 4.88474412 4.82474412 4.71474412 4.66474412
## 373 374 375 376 377 378
## 4.66474412 4.60474412 4.60474412 4.60474412 4.60474412 4.55474412
## 379 380 381 382 383 384
## 4.49474412 4.49474412 4.49474412 4.49474412 4.49474412 4.44474412
## 385 386 387 388 389 390
## 4.44474412 4.38474412 4.38474412 4.38474412 4.27474412 4.21474412
## 391 392 393 394 395 396
## 4.21474412 4.16474412 4.16474412 4.16474412 4.10474412 4.10474412
## 397 398 399 400 401 402
## 3.99474412 3.88474412 3.88474412 3.71474412 3.49474412 3.21474412
## 403 404 405 406 407 408
## 3.05474412 2.99474412 2.88474412 2.82474412 2.82474412 2.77474412
## 409 410 411 412 413 414
## 2.66474412 2.60474412 2.60474412 2.55474412 2.49474412 2.44474412
## 415 416 417 418 419 420
## 2.44474412 2.38474412 2.21474412 2.21474412 2.16474412 2.16474412
## 421 422 423 424 425 426
## 2.16474412 2.10474412 1.99474412 1.99474412 1.99474412 1.99474412
## 427 428 429 430 431 432
## 1.99474412 1.99474412 1.94474412 1.88474412 1.88474412 1.82474412
## 433 434 435 436 437 438
## 1.77474412 1.77474412 1.77474412 1.77474412 1.77474412 1.66474412
## 439 440 441 442 443 444
## 1.66474412 1.66474412 1.60474412 1.55474412 1.49474412 1.44474412
## 445 446 447 448 449 450
## 1.44474412 1.44474412 4.22692308 5.16692308 4.83692308 5.22692308
## 451 452 453 454 455 456
## 5.50692308 5.50692308 3.22692308 5.61692308 6.61692308 5.44692308
## 457 458 459 460 461 462
## 5.66692308 3.27692308 3.27692308 3.22692308 4.22692308 4.27692308
## 463 464 465 466 467 468
## 5.16692308 5.72692308 4.94692308 5.39692308 5.00692308 3.66692308
## 469 470 471 472 473 474
## 5.39692308 4.83692308 6.05692308 5.00692308 3.72692308 3.72692308
## 475 476 477 478 479 480
## 2.16692308 5.50692308 3.83692308 6.16692308 5.89692308 5.00692308
## 481 482 483 484 485 486
## 4.50692308 4.39692308 4.11692308 2.11692308 3.39692308 4.94692308
## 487 488 489 490 491 492
## 4.94692308 3.89692308 5.22692308 4.83692308 4.27692308 4.16692308
## 493 494 495 496 497 498
## 3.61692308 4.05692308 4.11692308 3.33692308 4.50692308 3.94692308
## 499 500 501 502 503 504
## 5.72692308 6.50692308 6.39692308 3.33692308 3.66692308 3.39692308
## 505 506 507 508 509 510
## 3.39692308 3.39692308 3.39692308 3.39692308 6.66692308 6.66692308
## 511 512 513 514 515 516
## 4.55692308 5.77692308 5.27692308 5.55692308 5.16692308 4.61692308
## 517 518 519 520 521 522
## 3.66692308 4.89692308 6.16692308 7.16692308 8.00692308 4.83692308
## 523 524 525 526 527 528
## 4.05692308 5.44692308 4.83692308 3.00692308 3.72692308 4.72692308
## 529 530 531 532 533 534
## 2.89692308 5.16692308 4.66692308 3.44692308 2.11692308 2.27692308
## 535 536 537 538 539 540
## 4.22692308 4.00692308 2.05692308 2.39692308 0.83692308 4.16692308
## 541 542 543 544 545 546
## 3.72692308 2.50692308 5.39692308 2.94692308 5.83692308 2.55692308
## 547 548 549 550 551 552
## 2.89692308 4.72692308 4.33692308 3.33692308 3.05692308 2.05692308
## 553 554 555 556 557 558
## 2.00692308 2.00692308 0.83692308 0.39692308 0.22692308 0.50692308
## 559 560 561 562 563 564
## -3.85148352 -2.79148352 -2.01148352 -3.57148352 -4.96148352 0.75851648
## 565 566 567 568 569 570
## -3.63148352 -0.51148352 -2.29148352 2.03851648 2.42851648 0.64851648
## 571 572 573 574 575 576
## 1.20851648 -2.29148352 -0.35148352 0.25851648 -2.63148352 -2.29148352
## 577 578 579 580 581 582
## -3.63148352 2.09851648 1.81851648 4.92851648 -3.63148352 -0.68148352
## 583 584 585 586 587 588
## 3.75851648 -2.24148352 2.03851648 4.98851648 4.75851648 4.48851648
## 589 590 591 592 593 594
## -11.01148352 -12.90148352 -12.46148352 -12.96148352 -9.24148352 -11.57148352
## 595 596 597 598 599 600
## -10.13148352 -12.79148352 -11.51148352 -12.40148352 -11.18148352 -11.68148352
## 601 602 603 604 605 606
## -13.85148352 -12.57148352 -14.18148352 -14.57148352 -15.29148352 -14.35148352
## 607 608 609 610 611 612
## -12.79148352 -13.85148352 -12.96148352 -13.13148352 -10.18148352 -9.96148352
## 613 614 615 616 617 618
## -8.74148352 -8.74148352 -11.18148352 -9.40148352 -10.18148352 -8.68148352
## 619 620 621 622 623 624
## -7.01148352 -9.24148352 -3.63148352 -5.79148352 -9.63148352 -11.07148352
## 625 626 627 628 629 630
## -10.90148352 -9.96148352 -9.24148352 -11.18148352 3.10474412 2.55474412
## 631 632 633 634 635 636
## 2.32474412 2.32474412 2.16474412 2.10474412 2.05474412 2.05474412
## 637 638 639 640 641 642
## 1.88474412 1.71474412 1.66474412 1.66474412 1.38474412 1.32474412
## 643 644 645 646 647 648
## 1.27474412 1.27474412 1.21474412 0.99474412 0.94474412 0.94474412
## 649 650 651 652 653 654
## 0.82474412 0.82474412 0.71474412 0.60474412 0.55474412 0.55474412
## 655 656 657 658 659 660
## 0.49474412 0.49474412 0.49474412 0.49474412 0.49474412 0.44474412
## 661 662 663 664 665 666
## 0.32474412 0.32474412 0.27474412 0.27474412 0.27474412 0.21474412
## 667 668 669 670 671 672
## 0.16474412 0.16474412 0.10474412 0.10474412 -0.11525588 -0.17525588
## 673 674 675 676 677 678
## -0.17525588 -0.17525588 -0.17525588 -0.22525588 -0.22525588 -0.33525588
## 679 680 681 682 683 684
## -0.61525588 -0.67525588 -0.67525588 -0.67525588 -0.72525588 -0.78525588
## 685 686 687 688 689 690
## -0.78525588 -0.78525588 -0.94525588 -1.00525588 -1.00525588 -1.00525588
## 691 692 693 694 695 696
## -1.05525588 -1.05525588 -1.05525588 -1.17525588 -1.17525588 -1.22525588
## 697 698 699 700 701 702
## -1.22525588 -1.22525588 -1.22525588 -1.28525588 -1.28525588 -1.28525588
## 703 704 705 706 707 708
## -1.33525588 -1.33525588 -1.33525588 -1.33525588 -1.39525588 -1.39525588
## 709 710 711 712 713 714
## -1.44525588 -1.44525588 -1.44525588 -1.44525588 -1.44525588 -1.44525588
## 715 716 717 718 719 720
## -1.44525588 -1.50525588 -1.50525588 -1.50525588 -1.50525588 -1.55525588
## 721 722 723 724 725 726
## -1.55525588 -1.55525588 -1.55525588 -1.55525588 -1.67525588 -1.67525588
## 727 728 729 730 731 732
## -1.72525588 -1.72525588 -1.72525588 -1.78525588 -1.83525588 -1.83525588
## 733 734 735 736 737 738
## -1.89525588 -1.89525588 -1.94525588 -2.00525588 -2.05525588 -2.05525588
## 739 740 741 742 743 744
## -2.11525588 -2.11525588 -2.22525588 -2.22525588 -2.22525588 -2.28525588
## 745 746 747 748 749 750
## -2.28525588 -2.28525588 -2.28525588 -2.33525588 -2.33525588 -2.39525588
## 751 752 753 754 755 756
## -2.44525588 -2.44525588 -2.50525588 -2.50525588 -2.50525588 -2.55525588
## 757 758 759 760 761 762
## -2.55525588 -2.55525588 -2.67525588 -2.72525588 -2.72525588 -2.78525588
## 763 764 765 766 767 768
## -2.83525588 -3.00525588 -3.05525588 -3.28525588 -3.33525588 -3.39525588
## 769 770 771 772 773 774
## -1.28525588 -1.33525588 -1.89525588 -2.05525588 -2.17525588 -3.28525588
## 775 776 777 778 779 780
## -3.44525588 -3.78525588 -3.94525588 -4.05525588 -4.17525588 -4.39525588
## 781 782 783 784 785 786
## -4.44525588 -4.44525588 -4.50525588 -4.50525588 -4.55525588 -4.72525588
## 787 788 789 790 791 792
## -4.83525588 -4.83525588 -4.83525588 -4.89525588 -4.89525588 -4.94525588
## 793 794 795 796 797 798
## -4.94525588 -5.05525588 -5.11525588 -5.28525588 -5.28525588 -5.39525588
## 799 800 801 802 803 804
## -5.39525588 -5.44525588 -5.44525588 -5.44525588 -5.55525588 -5.67525588
## 805 806 807 808 809 810
## -5.78525588 -5.78525588 -5.83525588 -5.83525588 -5.83525588 -5.83525588
## 811 812 813 814 815 816
## -5.94525588 -5.94525588 -6.00525588 -6.11525588 -6.11525588 -6.11525588
## 817 818 819 820 821 822
## -6.11525588 -6.17525588 -6.17525588 -6.17525588 -6.22525588 -6.22525588
## 823 824 825 826 827 828
## -6.28525588 -6.33525588 -6.33525588 -6.33525588 -6.33525588 -6.39525588
## 829 830 831 832 833 834
## -6.39525588 -6.50525588 -6.50525588 -6.50525588 -6.55525588 -6.55525588
## 835 836 837 838 839 840
## -6.61525588 -6.67525588 -6.67525588 -6.72525588 -6.72525588 -6.72525588
## 841 842 843 844 845 846
## -6.78525588 -6.78525588 -6.83525588 -6.83525588 -6.83525588 -6.89525588
## 847 848 849 850 851 852
## -6.94525588 -6.94525588 -7.00525588 -7.00525588 -7.00525588 -7.05525588
## 853 854 855 856 857 858
## -7.05525588 -7.11525588 -7.11525588 -7.17525588 -7.17525588 -7.17525588
## 859 860 861 862 863 864
## -7.22525588 -7.22525588 -7.22525588 -7.22525588 -7.28525588 -7.28525588
## 865 866 867 868 869 870
## -7.28525588 -7.33525588 -7.33525588 -7.33525588 -7.44525588 -7.44525588
## 871 872 873 874 875 876
## -7.44525588 -7.44525588 -7.50525588 -7.50525588 -7.50525588 -7.50525588
## 877 878 879 880 881 882
## -7.55525588 -7.55525588 -7.55525588 -7.55525588 -7.55525588 -7.61525588
## 883 884 885 886 887 888
## -7.61525588 -7.61525588 -7.67525588 -7.67525588 -7.67525588 -7.67525588
## 889 890 891 892 893 894
## -7.67525588 -7.72525588 -7.72525588 -7.72525588 -7.72525588 -7.72525588
## 895 896 897 898 899 900
## -7.78525588 -7.78525588 -7.78525588 -7.83525588 -7.83525588 -7.94525588
## 901 902 903 904 905 906
## -7.94525588 -7.94525588 -8.05525588 -8.05525588 -8.11525588 -8.11525588
## 907 908 909 910 911 912
## -8.11525588 -8.11525588 -8.17525588 -8.17525588 -8.22525588 -8.22525588
## 913 914 915 916 917 918
## -8.22525588 -8.28525588 -8.28525588 -8.33525588 -8.33525588 -8.33525588
## 919 920 921 922 923 924
## -8.39525588 -8.44525588 -8.44525588 -8.44525588 -8.44525588 -8.50525588
## 925 926 927 928 929 930
## -8.50525588 -8.55525588 -8.61525588 -8.61525588 -8.61525588 -8.67525588
## 931 932 933 934 935 936
## -8.67525588 -8.67525588 -8.72525588 -8.78525588 -8.83525588 -8.83525588
## 937 938 939 940 941 942
## -8.83525588 -8.83525588 -8.89525588 -8.89525588 -8.94525588 -8.94525588
## 943 944 945 946 947 948
## -8.94525588 -8.94525588 -9.00525588 -9.00525588 -9.00525588 -9.05525588
## 949 950 951 952 953 954
## -9.05525588 -9.11525588 -9.11525588 -9.11525588 -9.17525588 -9.17525588
## 955 956 957 958 959 960
## -9.22525588 -9.22525588 -9.28525588 -9.28525588 -9.33525588 -9.33525588
## 961 962 963 964 965 966
## -9.33525588 -9.33525588 -9.33525588 -9.39525588 -9.39525588 -9.44525588
## 967 968 969 970 971 972
## -9.50525588 -9.61525588 -9.61525588 -9.61525588 -9.61525588 -9.72525588
## 973 974 975 976 977 978
## -9.72525588 -9.72525588 -9.72525588 -9.78525588 -9.78525588 -9.94525588
## 979 980 981 982 983 984
## -10.00525588 -10.05525588 -10.05525588 -10.11525588 -10.11525588 -10.17525588
## 985 986 987 988 989 990
## -10.22525588 -10.22525588 -10.28525588 -10.28525588 -10.33525588 -10.33525588
## 991 992 993 994 995 996
## -10.39525588 -10.50525588 -10.50525588 -10.50525588 -10.72525588 -10.72525588
## 997 998 999 1000 1001 1002
## -10.78525588 -10.83525588 -10.94525588 -11.05525588 -11.05525588 -11.11525588
## 1003 1004 1005 1006 1007 1008
## -11.22525588 -11.44525588 -11.50525588 -11.83525588 -12.28525588 -12.33525588
## 1009 1010 1011 1012 1013 1014
## -13.50525588 -13.67525588 -14.39525588 -14.94525588 -15.00525588 -15.11525588
## 1015 1016 1017 1018 1019 1020
## -15.17525588 -15.39525588 -16.33525588 3.54922619 2.65922619 2.20922619
## 1021 1022 1023 1024 1025 1026
## 1.87922619 1.76922619 0.54922619 -2.73077381 -2.95077381 1.20922619
## 1027 1028 1029 1030 1031 1032
## 0.82922619 0.09922619 -0.51077381 -1.73077381 -1.84077381 -2.17077381
## 1033 1034 1035 1036 1037 1038
## -2.79077381 6.04922619 0.54922619 -0.51077381 -1.23077381 -1.95077381
## 1039 1040 1041 1042 1043 1044
## -1.95077381 -2.40077381 -2.90077381 5.32922619 1.65922619 1.48922619
## 1045 1046 1047 1048 1049 1050
## 1.20922619 0.09922619 0.04922619 -2.40077381 -2.40077381 2.59922619
## 1051 1052 1053 1054 1055 1056
## 1.82922619 1.82922619 1.76922619 1.59922619 1.37922619 1.32922619
## 1057 1058 1059 1060 1061 1062
## 1.04922619 -0.34077381 -0.73077381 -0.84077381 -1.51077381 -1.62077381
## 1063 1064 1065 1066 1067 1068
## -1.73077381 -2.17077381 -2.56077381 1.59922619 -1.40077381 -1.56077381
## 1069 1070 1071 1072 1073 1074
## -2.12077381 -2.73077381 -2.73077381 -2.84077381 -5.34077381 3.20922619
## 1075 1076 1077 1078 1079 1080
## 1.87922619 0.43922619 0.20922619 -0.06077381 -2.40077381 -3.12077381
## 1081 1082 1083 1084 1085 1086
## -3.73077381 0.37922619 -1.45077381 -1.79077381 -2.17077381 -2.67077381
## 1087 1088 1089 1090 1091 1092
## -2.90077381 -2.90077381 -3.40077381 2.26922619 1.59922619 1.20922619
## 1093 1094 1095 1096 1097 1098
## 1.09922619 0.98922619 0.70922619 0.48922619 0.09922619 -0.62077381
## 1099 1100 1101 1102 1103 1104
## -0.73077381 -1.01077381 -1.29077381 -1.67077381 -1.73077381 -1.84077381
## 1105 1106 1107 1108 1109 1110
## -1.90077381 2.76922619 2.76922619 2.32922619 2.32922619 1.37922619
## 1111 1112 1113 1114 1115 1116
## 0.48922619 0.09922619 -0.01077381 1.87922619 -0.56077381 -0.56077381
## 1117 1118 1119 1120 1121 1122
## -0.62077381 -0.90077381 -1.06077381 -1.12077381 -1.34077381 -0.12077381
## 1123 1124 1125 1126 1127 1128
## -0.29077381 -0.45077381 -0.90077381 -1.12077381 -1.17077381 -1.51077381
## 1129 1130 1131 1132 1133 1134
## -2.06077381 1.15922619 0.54922619 0.15922619 -0.06077381 -0.45077381
## 1135 1136 1137 1138 1139 1140
## -0.45077381 -0.51077381 -0.56077381 4.09922619 4.09922619 4.04922619
## 1141 1142 1143 1144 1145 1146
## 3.70922619 3.43922619 3.09922619 2.82922619 2.70922619 1.04922619
## 1147 1148 1149 1150 1151 1152
## -0.06077381 -0.12077381 -0.45077381 -0.67077381 -1.23077381 -1.45077381
## 1153 1154 1155 1156 1157 1158
## -2.23077381 0.59922619 0.59922619 0.54922619 0.15922619 -0.62077381
## 1159 1160 1161 1162 1163 1164
## -0.73077381 -0.84077381 -2.01077381 3.87922619 3.82922619 3.32922619
## 1165 1166 1167 1168 1169 1170
## 2.98922619 2.82922619 2.76922619 2.76922619 2.70922619 2.98922619
## 1171 1172 1173 1174 1175 1176
## 2.37922619 2.04922619 1.98922619 1.26922619 1.15922619 0.70922619
## 1177 1178 1179 1180 1181 1182
## 0.65922619 -1.56077381 -2.01077381 -2.45077381 -2.67077381 -3.06077381
## 1183 1184 1185 1186 1187 1188
## -3.12077381 -3.17077381 -3.56077381 -2.05307692 -1.88307692 -3.94307692
## 1189 1190 1191 1192 1193 1194
## -3.66307692 -3.94307692 -3.66307692 -3.27307692 -3.49307692 -2.49307692
## 1195 1196 1197 1198 1199 1200
## -1.55307692 -1.55307692 -1.66307692 -2.16307692 -2.60307692 -0.66307692
## 1201 1202 1203 1204 1205 1206
## -0.33307692 -0.77307692 -0.83307692 -1.22307692 -1.55307692 -1.55307692
## 1207 1208 1209 1210 1211 1212
## -3.88307692 -3.33307692 -3.44307692 -2.88307692 -2.99307692 -1.94307692
## 1213 1214 1215 1216 1217 1218
## -1.88307692 -1.88307692 -2.49307692 -10.33307692 -11.38307692 -11.77307692
## 1219 1220 1221 1222 1223 1224
## -11.22307692 -7.33307692 -10.49307692 -9.10307692 -11.44307692 -11.16307692
## 1225 1226 1227 1228 1229 1230
## -11.16307692 -9.55307692 -6.77307692 -11.83307692 -11.83307692 -13.77307692
## 1231 1232 1233 1234 1235 1236
## -11.83307692 -13.83307692 -13.83307692 -12.05307692 -10.99307692 -12.49307692
## 1237 1238 1239 1240 1241 1242
## -11.77307692 -13.05307692 -7.94307692 -7.27307692 -9.33307692 -9.77307692
## 1243 1244 1245 1246 1247 1248
## -8.33307692 -8.33307692 -2.05307692 -12.55307692 -10.22307692 -8.55307692
## 1249 1250 1251 1252 1253 1254
## -6.33307692 -4.33307692 -9.27307692 -12.22307692 -8.83307692 -8.10307692
## 1255
## -9.94307692
histogram(res)
# create a Q-Q plot
qqnorm(res); qqline(res)
shapiro.test(res)
##
## Shapiro-Wilk normality test
##
## data: res
## W = 0.95846, p-value < 2.2e-16
The data were not significantly different from normal, so I proceeded to check for homogeneity of variances. This routine does not accept linear models (lm) so we used the base R routine aov to set up the model.
leveneTest(aov(Temperature ~ Type, data = df))
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 3 57.524 < 2.2e-16 ***
## 1251
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
The observed P-value indicates whether variances are homogeneous across Temperature Types. If the P-value is low, variances are NOT homogeneous. If this occurs, we can implement a data transformation in the hopes of stabilizing variances. In the transformation used here, we take the reciprocal of the raw temperature data and then multiply the result × 100. By taking the reciprocal of the original data, this means that the highest temperature values will become the lowest values of the response variable, which I have called “transTemp”. After making this transformation, I repeated the Shapiro–Wilk test and Levene’s test (and all associated graphs) in a single code chunk below.
df$transTemp <- (1 / (df$Temperature)) * 100 # implement the transformation
str(df) # check to see if it did the transformation
## 'data.frame': 1255 obs. of 5 variables:
## $ Season : chr "Summer" "Summer" "Summer" "Summer" ...
## $ Population : chr "Galveston" "Galveston" "Galveston" "Galveston" ...
## $ Type : Factor w/ 4 levels "Te","Tw","Tb",..: 3 3 3 3 3 3 3 3 3 3 ...
## $ Temperature: num 29.9 32.2 30.2 31.4 29.7 ...
## $ transTemp : num 3.35 3.1 3.31 3.18 3.37 ...
model2 <- lm(transTemp ~ Type, data = df) # build a new model
res2 <- residuals(model2) # get the residuals from the new model
res2
## 1 2 3 4 5 6
## -0.852493954 -1.094432167 -0.883543611 -1.017432911 -0.827686670 -0.942886156
## 7 8 9 10 11 12
## -0.883543611 -0.983693975 -1.051461386 -0.989881464 -0.972288037 -0.782793943
## 13 14 15 16 17 18
## -1.152099972 -0.723459326 -0.889027646 -0.840136128 -0.919405964 -0.966032433
## 19 20 21 22 23 24
## -1.115480432 -0.907538385 -1.322878848 -0.782793943 -0.871414516 -0.815144557
## 25 26 27 28 29 30
## -1.100201056 -0.978519473 -0.762848869 -0.983693975 -0.640641625 -0.723459326
## 31 32 33 34 35 36
## -0.864761156 -0.989881464 -1.006265571 -0.931188249 -0.756938260 -0.845764620
## 37 38 39 40 41 42
## -0.749818627 -0.912943372 -0.782793943 -0.795576626 -0.983693975 -0.972288037
## 43 44 45 46 47 48
## -0.907538385 -0.864761156 -0.801355359 -0.788616139 -0.723459326 -0.775781005
## 49 50 51 52 53 54
## -0.782793943 -0.689322559 -0.827686670 -0.762848869 -1.029526682 -1.023491314
## 55 56 57 58 59 60
## -1.045509369 -0.954500587 -0.995019537 -0.901028877 -0.788616139 -0.845764620
## 61 62 63 64 65 66
## -0.782793943 -0.833356938 -1.045509369 -1.162271781 -1.062315248 -1.094432167
## 67 68 69 70 71 72
## -0.966032433 -0.820857069 -0.833356938 -0.858081129 -0.978519473 -1.266402903
## 73 74 75 76 77 78
## -0.931188249 -0.989881464 -1.177858911 -1.256918018 -0.864761156 -0.912943372
## 79 80 81 82 83 84
## -0.858081129 -0.815144557 -1.073094489 -0.937579328 0.170625476 -0.762848869
## 85 86 87 88 89 90
## -0.729485401 -0.762848869 -0.788616139 -0.618996422 -0.775781005 -0.858081129
## 91 92 93 94 95 96
## -0.795576626 -0.590590881 -0.612579968 -0.618996422 -0.925843180 -0.553779620
## 97 98 99 100 101 102
## -0.901028877 -0.907538385 -0.972288037 -0.845764620 -0.634302614 -1.313756445
## 103 104 105 106 107 108
## -0.681920087 -1.100201056 -0.532405339 -0.675727458 -0.696693929 -0.742669472
## 109 110 111 112 113 114
## -0.769914852 -0.310069606 -0.225110778 -0.384211957 -1.874521141 -1.859982413
## 115 116 117 118 119 120
## -1.850497529 -1.826074949 -1.826074949 -1.806599373 -1.741033365 -1.725129995
## 121 122 123 124 125 126
## -1.698571618 -1.693780567 -1.683187832 -1.672522409 -1.660803618 -1.649983770
## 127 128 129 130 131 132
## -1.639088880 -1.628118163 -1.617070825 -1.577273485 -1.572098983 -1.572098983
## 133 134 135 136 137 138
## -1.559611944 -1.559611944 -1.554380377 -1.548080097 -1.548080097 -1.542811102
## 139 140 141 142 143 144
## -1.542811102 -1.542811102 -1.536465666 -1.536465666 -1.524767760 -1.524767760
## 145 146 147 148 149 150
## -1.519422691 -1.512985475 -1.506522883 -1.506522883 -1.506522883 -1.506522883
## 151 152 153 154 155 156
## -1.506522883 -1.501117896 -1.501117896 -1.494608388 -1.494608388 -1.494608388
## 157 158 159 160 161 162
## -1.494608388 -1.489164092 -1.489164092 -1.489164092 -1.482607156 -1.482607156
## 163 164 165 166 167 168
## -1.477123121 -1.477123121 -1.477123121 -1.470518237 -1.470518237 -1.470518237
## 169 170 171 172 173 174
## -1.464994026 -1.464994026 -1.464994026 -1.451660639 -1.439344130 -1.439344130
## 175 176 177 178 179 180
## -1.433715638 -1.433715638 -1.433715638 -1.414436580 -1.414436580 -1.408724067
## 181 182 183 184 185 186
## -1.408724067 -1.401843491 -1.394934869 -1.394934869 -1.389156136 -1.389156136
## 187 188 189 190 191 192
## -1.389156136 -1.389156136 -1.382195650 -1.382195650 -1.376373453 -1.376373453
## 193 194 195 196 197 198
## -1.376373453 -1.376373453 -1.369360516 -1.369360516 -1.369360516 -1.369360516
## 199 200 201 202 203 204
## -1.369360516 -1.369360516 -1.363494363 -1.363494363 -1.356428379 -1.356428379
## 205 206 207 208 209 210
## -1.356428379 -1.356428379 -1.356428379 -1.350517771 -1.350517771 -1.350517771
## 211 212 213 214 215 216
## -1.343398137 -1.343398137 -1.336248982 -1.336248982 -1.330268669 -1.330268669
## 217 218 219 220 221 222
## -1.323064912 -1.323064912 -1.309779849 -1.309779849 -1.296392629 -1.269306969
## 223 224 225 226 227 228
## -1.269306969 -1.261846961 -1.255606107 -1.241798245 -1.220245428 -1.206159478
## 229 230 231 232 233 234
## -1.198429300 -1.117904712 -1.102998234 -1.996816537 -1.988197689 -1.939420719
## 235 236 237 238 239 240
## -1.929624772 -1.929624772 -1.850497529 -1.840951072 -1.840951072 -1.835717748
## 241 242 243 244 245 246
## -1.826074949 -1.796765344 -1.796765344 -1.791373970 -1.791373970 -1.776901615
## 247 248 249 250 251 252
## -1.766870612 -1.766870612 -1.745679482 -1.735439281 -1.725129995 -1.709059943
## 253 254 255 256 257 258
## -1.704301354 -1.704301354 -1.704301354 -1.698571618 -1.698571618 -1.693780567
## 259 260 261 262 263 264
## -1.693780567 -1.688011678 -1.688011678 -1.683187832 -1.677379387 -1.672522409
## 265 266 267 268 269 270
## -1.655894758 -1.623106192 -1.623106192 -1.605946061 -1.599845082 -1.588599048
## 271 272 273 274 275 276
## -1.583460974 -1.577273485 -1.577273485 -1.559611944 -1.559611944 -1.559611944
## 277 278 279 280 281 282
## -1.554380377 -1.554380377 -1.542811102 -1.542811102 -1.542811102 -1.542811102
## 283 284 285 286 287 288
## -1.531158838 -1.531158838 -1.524767760 -1.519422691 -1.512985475 -1.512985475
## 289 290 291 292 293 294
## -1.506522883 -1.506522883 -1.501117896 -1.489164092 -1.482607156 -1.482607156
## 295 296 297 298 299 300
## -1.482607156 -1.477123121 -1.477123121 -1.477123121 -1.470518237 -1.470518237
## 301 302 303 304 305 306
## -1.470518237 -1.464994026 -1.458340666 -1.458340666 -1.451660639 -1.451660639
## 307 308 309 310 311 312
## -1.451660639 -1.446073464 -1.439344130 -1.439344130 -1.439344130 -1.439344130
## 313 314 315 316 317 318
## -1.439344130 -1.439344130 -1.433715638 -1.426936449 -1.426936449 -1.426936449
## 319 320 321 322 323 324
## -1.426936449 -1.421266180 -1.414436580 -1.414436580 -1.414436580 -1.408724067
## 325 326 327 328 329 330
## -1.401843491 -1.401843491 -1.401843491 -1.394934869 -1.394934869 -1.382195650
## 331 332 333 334 335 336
## -1.382195650 -1.382195650 -1.376373453 -1.369360516 -1.369360516 -1.369360516
## 337 338 339 340 341 342
## -1.369360516 -1.369360516 -1.363494363 -1.356428379 -1.356428379 -1.350517771
## 343 344 345 346 347 348
## -1.350517771 -1.343398137 -1.343398137 -1.343398137 -1.343398137 -1.330268669
## 349 350 351 352 353 354
## -1.330268669 -1.323064912 -1.323064912 -1.317038836 -1.317038836 -1.296392629
## 355 356 357 358 359 360
## -1.290273439 -1.290273439 -1.290273439 -1.275499597 -1.261846961 -1.255606107
## 361 362 363 364 365 366
## -1.248087890 -1.241798245 -1.234221136 -1.227882125 -1.227882125 -1.220245428
## 367 368 369 370 371 372
## -1.220245428 -1.220245428 -1.220245428 -1.212575932 -1.198429300 -1.191961976
## 373 374 375 376 377 378
## -1.191961976 -1.184170392 -1.184170392 -1.184170392 -1.184170392 -1.177651593
## 379 380 381 382 383 384
## -1.169797868 -1.169797868 -1.169797868 -1.169797868 -1.169797868 -1.163226975
## 385 386 387 388 389 390
## -1.163226975 -1.155310363 -1.155310363 -1.155310363 -1.140706493 -1.132691197
## 391 392 393 394 395 396
## -1.132691197 -1.125984850 -1.125984850 -1.125984850 -1.117904712 -1.117904712
## 397 398 399 400 401 402
## -1.102998234 -1.087970296 -1.087970296 -1.064502922 -1.033688280 -0.993724892
## 403 404 405 406 407 408
## -0.970504722 -0.961723789 -0.945520153 -0.936623884 -0.936623884 -0.929178828
## 409 410 411 412 413 414
## -0.912698049 -0.903649116 -0.903649116 -0.896076025 -0.886949283 -0.879310932
## 415 416 417 418 419 420
## -0.879310932 -0.870105372 -0.843786120 -0.843786120 -0.835977797 -0.835977797
## 421 422 423 424 425 426
## -0.835977797 -0.826566942 -0.809196899 -0.809196899 -0.809196899 -0.809196899
## 427 428 429 430 431 432
## -0.809196899 -0.809196899 -0.801251015 -0.791674000 -0.791674000 -0.782050904
## 433 434 435 436 437 438
## -0.773996217 -0.773996217 -0.773996217 -0.773996217 -0.773996217 -0.756161489
## 439 440 441 442 443 444
## -0.756161489 -0.756161489 -0.746366556 -0.738167717 -0.728285133 -0.720012762
## 445 446 447 448 449 450
## -0.720012762 -0.720012762 -0.913564994 -1.019017246 -0.982749524 -1.025526753
## 451 452 453 454 455 456
## -1.055567696 -1.055567696 -0.793715827 -1.067219959 -1.169449755 -1.049176618
## 457 458 459 460 461 462
## -1.072488955 -0.799908455 -0.799908455 -0.793715827 -0.913564994 -0.919343727
## 463 464 465 466 467 468
## -1.019017246 -1.078789235 -0.994927095 -1.043831548 -1.001531979 -0.847473770
## 469 470 471 472 473 474
## -1.043831548 -0.982749524 -1.113007905 -1.001531979 -0.854677527 -0.854677527
## 475 476 477 478 479 480
## -0.657100055 -1.055567696 -0.867806995 -1.124253939 -1.096507841 -1.001531979
## 481 482 483 484 485 486
## -0.945675038 -0.933132925 -0.900782311 -0.650393708 -0.814682297 -0.994927095
## 487 488 489 490 491 492
## -0.994927095 -0.874926629 -1.025526753 -0.982749524 -0.919343727 -0.906604507
## 493 494 495 496 497 498
## -0.841447694 -0.893769373 -0.900782311 -0.807310927 -0.945675038 -0.880837237
## 499 500 501 502 503 504
## -1.078789235 -1.158520495 -1.147515050 -0.807310927 -0.847473770 -0.814682297
## 505 506 507 508 509 510
## -0.814682297 -0.814682297 -0.814682297 -0.814682297 -1.174392628 -1.174392628
## 511 512 513 514 515 516
## -0.951345307 -1.084020802 -1.030931740 -1.060874524 -1.019017246 -0.958124496
## 517 518 519 520 521 522
## -0.847473770 -0.989402884 -1.124253939 -1.222980476 -1.301310473 -0.982749524
## 523 524 525 526 527 528
## -0.893769373 -1.049176618 -0.982749524 -0.766207103 -0.854677527 -0.970482322
## 529 530 531 532 533 534
## -0.752290983 -1.019017246 -0.963752988 -0.820801487 -0.650393708 -0.671767989
## 535 536 537 538 539 540
## -0.913564994 -0.887903221 -0.642313570 -0.687635833 -0.469929011 -0.906604507
## 541 542 543 544 545 546
## -0.854677527 -0.702060450 -1.043831548 -0.758629994 -1.090276406 -0.708579250
## 547 548 549 550 551 552
## -0.752290983 -0.970482322 -0.926252349 -0.807310927 -0.772496748 -0.642313570
## 553 554 555 556 557 558
## -0.635552861 -0.635552861 -0.469929011 -0.403719790 -0.377524370 -0.420484883
## 559 560 561 562 563 564
## 0.302355556 0.097438157 -0.041818512 0.246349955 0.538996937 -0.470923412
## 565 566 567 568 569 570
## 0.258233497 -0.285731422 0.007119977 -0.640641625 -0.689322559 -0.455579519
## 571 572 573 574 575 576
## -0.532405339 0.007119977 -0.310069606 -0.400145381 0.068117115 0.007119977
## 577 578 579 580 581 582
## 0.258233497 -0.648218735 -0.612579968 -0.972288037 0.258233497 -0.259536001
## 583 584 585 586 587 588
## -0.845764620 -0.001703385 -0.640641625 -0.978519473 -0.954500587 -0.925843180
## 589 590 591 592 593 594
## 2.442011753 3.394919938 3.149444086 3.429670576 1.743676159 2.698457235
## 595 596 597 598 599 600
## 2.075431232 3.332025993 2.670037379 3.117194465 2.517822234 2.751175838
## 601 602 603 604 605 606
## 3.985211567 3.209312918 4.212334443 4.497557685 5.078343359 4.334328719
## 607 608 609 610 611 612
## 3.332025993 3.985211567 3.429670576 3.529880782 2.095171716 2.009230154
## 613 614 615 616 617 618
## 1.572245961 1.572245961 2.517822234 1.800705751 2.095171716 1.552336793
## 619 620 621 622 623 624
## 1.048495228 1.743676159 0.258233497 0.732871980 1.884630572 2.468572178
## 625 626 627 628 629 630
## 2.393863323 2.009230154 1.743676159 2.517822234 -0.977791467 -0.896076025
## 631 632 633 634 635 636
## -0.860856389 -0.860856389 -0.835977797 -0.826566942 -0.818690289 -0.818690289
## 637 638 639 640 641 642
## -0.791674000 -0.764287773 -0.756161489 -0.756161489 -0.710041346 -0.700020972
## 643 644 645 646 647 648
## -0.691632999 -0.691632999 -0.681521924 -0.644017425 -0.635398023 -0.635398023
## 649 650 651 652 653 654
## -0.614564559 -0.614564559 -0.595282896 -0.575822398 -0.566916923 -0.566916923
## 655 656 657 658 659 660
## -0.556180565 -0.556180565 -0.556180565 -0.556180565 -0.556180565 -0.547191826
## 661 662 663 664 665 666
## -0.525462395 -0.525462395 -0.516342661 -0.516342661 -0.516342661 -0.505347381
## 667 668 669 670 671 672
## -0.496141353 -0.496141353 -0.485041786 -0.485041786 -0.443847913 -0.432476092
## 673 674 675 676 677 678
## -0.432476092 -0.432476092 -0.432476092 -0.422954034 -0.422954034 -0.401858372
## 679 680 681 682 683 684
## -0.347229555 -0.335346014 -0.335346014 -0.335346014 -0.325394410 -0.313393659
## 685 686 687 688 689 690
## -0.313393659 -0.313393659 -0.281074090 -0.268833656 -0.268833656 -0.268833656
## 691 692 693 694 695 696
## -0.258582431 -0.258582431 -0.258582431 -0.233788858 -0.233788858 -0.223377974
## 697 698 699 700 701 702
## -0.223377974 -0.223377974 -0.223377974 -0.210821961 -0.210821961 -0.210821961
## 703 704 705 706 707 708
## -0.200305772 -0.200305772 -0.200305772 -0.200305772 -0.187622434 -0.187622434
## 709 710 711 712 713 714
## -0.176999334 -0.176999334 -0.176999334 -0.176999334 -0.176999334 -0.176999334
## 715 716 717 718 719 720
## -0.176999334 -0.164186725 -0.164186725 -0.164186725 -0.164186725 -0.153455076
## 721 722 723 724 725 726
## -0.153455076 -0.153455076 -0.153455076 -0.153455076 -0.127494895 -0.127494895
## 727 728 729 730 731 732
## -0.116592186 -0.116592186 -0.116592186 -0.103441463 -0.092425879 -0.092425879
## 733 734 735 736 737 738
## -0.079138656 -0.079138656 -0.068008435 -0.054582574 -0.043335918 -0.043335918
## 739 740 741 742 743 744
## -0.029769238 -0.029769238 -0.004694584 -0.004694584 -0.004694584 0.009094123
## 745 746 747 748 749 750
## 0.009094123 0.009094123 0.009094123 0.020645538 0.020645538 0.034580827
## 751 752 753 754 755 756
## 0.046255367 0.046255367 0.060339586 0.060339586 0.060339586 0.072139230
## 757 758 759 760 761 762
## 0.072139230 0.072139230 0.100693907 0.112690885 0.112690885 0.127165154
## 763 764 765 766 767 768
## 0.139292470 0.180976423 0.193370866 0.251190347 0.263937729 0.279319915
## 769 770 771 772 773 774
## -0.210821961 -0.200305772 -0.079138656 -0.043335918 -0.016124811 0.251190347
## 775 776 777 778 779 780
## 0.292210088 0.381631743 0.424810090 0.454915717 0.488157046 0.550206342
## 781 782 783 784 785 786
## 0.564512396 0.564512396 0.581781132 0.581781132 0.596257035 0.646063902
## 787 788 789 790 791 792
## 0.678785519 0.678785519 0.678785519 0.696800205 0.696800205 0.711903326
## 793 794 795 796 797 798
## 0.711903326 0.745424561 0.763881556 0.816850958 0.816850958 0.851666858
## 799 800 801 802 803 804
## 0.851666858 0.867635565 0.867635565 0.867635565 0.903086821 0.942270955
## 805 806 807 808 809 810
## 0.978666451 0.978666451 0.995363038 0.995363038 0.995363038 0.995363038
## 811 812 813 814 815 816
## 1.032437823 1.032437823 1.052861360 1.090678942 1.090678942 1.090678942
## 817 818 819 820 821 822
## 1.090678942 1.111513722 1.111513722 1.111513722 1.128989115 1.128989115
## 823 824 825 826 827 828
## 1.150096648 1.167801567 1.167801567 1.167801567 1.167801567 1.189187244
## 829 830 831 832 833 834
## 1.189187244 1.228795597 1.228795597 1.228795597 1.246973343 1.246973343
## 835 836 837 838 839 840
## 1.268932061 1.291051061 1.291051061 1.309607270 1.309607270 1.309607270
## 841 842 843 844 845 846
## 1.332024714 1.332024714 1.350832143 1.350832143 1.350832143 1.373554114
## 847 848 849 850 851 852
## 1.392617899 1.392617899 1.415650644 1.415650644 1.415650644 1.434976063
## 853 854 855 856 857 858
## 1.434976063 1.458326000 1.458326000 1.481851722 1.481851722 1.481851722
## 859 860 861 862 863 864
## 1.501592206 1.501592206 1.501592206 1.501592206 1.525445394 1.525445394
## 865 866 867 868 869 870
## 1.525445394 1.545461615 1.545461615 1.545461615 1.589946932 1.589946932
## 871 872 873 874 875 876
## 1.589946932 1.589946932 1.614475904 1.614475904 1.614475904 1.614475904
## 877 878 879 880 881 882
## 1.635061219 1.635061219 1.635061219 1.635061219 1.635061219 1.659938904
## 883 884 885 886 887 888
## 1.659938904 1.659938904 1.685009938 1.685009938 1.685009938 1.685009938
## 889 890 891 892 893 894
## 1.685009938 1.706051796 1.706051796 1.706051796 1.706051796 1.706051796
## 895 896 897 898 899 900
## 1.731483209 1.731483209 1.731483209 1.752828618 1.752828618 1.800283812
## 901 902 903 904 905 906
## 1.800283812 1.800283812 1.848432242 1.848432242 1.874992667 1.874992667
## 907 908 909 910 911 912
## 1.874992667 1.874992667 1.901766429 1.901766429 1.924242723 1.924242723
## 913 914 915 916 917 918
## 1.924242723 1.951414335 1.951414335 1.974225865 1.974225865 1.974225865
## 919 920 921 922 923 924
## 2.001804261 2.024958584 2.024958584 2.024958584 2.024958584 2.052952968
## 925 926 927 928 929 930
## 2.052952968 2.076457869 2.104877725 2.104877725 2.104877725 2.133533757
## 931 932 933 934 935 936
## 2.133533757 2.133533757 2.157596327 2.186693063 2.211127121 2.211127121
## 937 938 939 940 941 942
## 2.211127121 2.211127121 2.240674805 2.240674805 2.265489021 2.265489021
## 943 944 945 946 947 948
## 2.265489021 2.265489021 2.295498219 2.295498219 2.295498219 2.320701534
## 949 950 951 952 953 954
## 2.320701534 2.351183143 2.351183143 2.351183143 2.381927148 2.381927148
## 955 956 957 958 959 960
## 2.407750047 2.407750047 2.438983990 2.438983990 2.465220050 2.465220050
## 961 962 963 964 965 966
## 2.465220050 2.465220050 2.465220050 2.496955738 2.496955738 2.523614954
## 967 968 969 970 971 972
## 2.555864575 2.615733408 2.615733408 2.615733408 2.615733408 2.676585896
## 973 974 975 976 977 978
## 2.676585896 2.676585896 2.676585896 2.710201469 2.710201469 2.801340427
## 979 980 981 982 983 984
## 2.836091065 2.865293841 2.865293841 2.900633693 2.900633693 2.936301271
## 985 986 987 988 989 990
## 2.966277901 2.966277901 3.002558269 3.002558269 3.033052135 3.033052135
## 991 992 993 994 995 996
## 3.069961221 3.138540116 3.138540116 3.138540116 3.279351021 3.279351021
## 997 998 999 1000 1001 1002
## 3.318626082 3.351648476 3.425252870 3.500199964 3.500199964 3.541659334
## 1003 1004 1005 1006 1007 1008
## 3.618754932 3.777306292 3.821590428 4.073574227 4.441936342 4.484763848
## 1009 1010 1011 1012 1013 1014
## 5.614153264 5.801546339 6.676215909 7.448228081 7.538782227 7.708326000
## 1015 1016 1017 1018 1019 1020
## 7.802784439 8.161693876 9.957588537 -0.461335689 -0.361327734 -0.308420579
## 1021 1022 1023 1024 1025 1026
## -0.268564227 -0.255073667 -0.098156447 0.402821070 0.441368869 -0.184747529
## 1027 1028 1029 1030 1031 1032
## -0.135398572 -0.036674520 0.050036936 0.236154403 0.253832185 0.307815641
## 1033 1034 1035 1036 1037 1038
## 0.413263844 -0.713204962 -0.098156447 0.050036936 0.157723031 0.271666913
## 1039 1040 1041 1042 1043 1044
## 0.271666913 0.346306479 0.432545507 -0.644694006 -0.241478566 -0.220259488
## 1045 1046 1047 1048 1049 1050
## -0.184747529 -0.036674520 -0.029715649 0.346306479 0.346306479 -0.354367247
## 1051 1052 1053 1054 1055 1056
## -0.262445037 -0.262445037 -0.255073667 -0.234018558 -0.206392733 -0.200053722
## 1057 1058 1059 1060 1061 1062
## -0.164133574 0.025468537 0.082308249 0.098649575 0.201261461 0.218631504
## 1063 1064 1065 1066 1067 1068
## 0.236154403 0.307815641 0.373514767 -0.234018558 0.184042283 0.209138114
## 1069 1070 1071 1072 1073 1074
## 0.299543270 0.402821070 0.402821070 0.422006224 0.911236217 -0.423832237
## 1075 1076 1077 1078 1079 1080
## -0.268564227 -0.083315600 -0.051893110 -0.014314288 0.346306479 0.471647838
## 1081 1082 1083 1084 1085 1086
## 0.583980490 -0.075169831 0.191850606 0.245777499 0.307815641 0.392430380
## 1087 1088 1089 1090 1091 1092
## 0.432545507 0.432545507 0.522481021 -0.315569735 -0.234018558 -0.184747529
## 1093 1094 1095 1096 1097 1098
## -0.170600897 -0.156341989 -0.119530728 -0.090076309 -0.036674520 0.066104614
## 1099 1100 1101 1102 1103 1104
## 0.082308249 0.124179287 0.166972013 0.226577388 0.236154403 0.253832185
## 1105 1106 1107 1108 1109 1110
## 0.263540630 -0.374015088 -0.374015088 -0.322689368 -0.322689368 -0.206392733
## 1111 1112 1113 1114 1115 1116
## -0.090076309 -0.036674520 -0.021330627 -0.268564227 0.057323681 0.057323681
## 1117 1118 1119 1120 1121 1122
## 0.066104614 0.107621689 0.131752378 0.140879120 0.174712891 -0.005859877
## 1123 1124 1125 1126 1127 1128
## 0.018302663 0.041329441 0.107621689 0.140879120 0.148517471 0.201261461
## 1129 1130 1131 1132 1133 1134
## 0.289660686 -0.178331075 -0.098156447 -0.044991004 -0.014314288 0.041329441
## 1135 1136 1137 1138 1139 1140
## 0.041329441 0.050036936 0.057323681 -0.520251695 -0.520251695 -0.514982699
## 1141 1142 1143 1144 1145 1146
## -0.478694480 -0.449294718 -0.411515728 -0.380895664 -0.367106466 -0.164133574
## 1147 1148 1149 1150 1151 1152
## -0.014314288 -0.005859877 0.041329441 0.073452945 0.157723031 0.191850606
## 1153 1154 1155 1156 1157 1158
## 0.317787056 -0.104862794 -0.104862794 -0.098156447 -0.044991004 0.066104614
## 1159 1160 1161 1162 1163 1164
## 0.082308249 0.098649575 0.281461847 -0.496939357 -0.491594288 -0.437165623
## 1165 1166 1167 1168 1169 1170
## -0.399108046 -0.380895664 -0.374015088 -0.374015088 -0.367106466 -0.399108046
## 1171 1172 1173 1174 1175 1176
## -0.328599977 -0.289210433 -0.281951446 -0.192417025 -0.178331075 -0.119530728
## 1177 1178 1179 1180 1181 1182
## -0.112878090 0.209138114 0.281461847 0.354770548 0.392430380 0.460911480
## 1183 1184 1185 1186 1187 1188
## 0.471647838 0.480636576 0.552080169 0.011048255 -0.020550211 0.396452487
## 1189 1190 1191 1192 1193 1194
## 0.335079933 0.396452487 0.335079933 0.252213168 0.298591808 0.095033155
## 1195 1196 1197 1198 1199 1200
## -0.080589422 -0.080589422 -0.060763708 0.031743230 0.116541256 -0.234450204
## 1201 1202 1203 1204 1205 1206
## -0.288696631 -0.216041857 -0.205930782 -0.138973417 -0.080589422 -0.080589422
## 1207 1208 1209 1210 1211 1212
## 0.383165263 0.264769181 0.287968708 0.172247484 0.194517052 -0.009450644
## 1213 1214 1215 1216 1217 1218
## -0.020550211 -0.020550211 0.095033155 2.427005477 2.940811192 3.152177038
## 1219 1220 1221 1222 1223 1224
## 2.857518290 1.292442101 2.500549726 1.910567205 2.972546880 2.826774286
## 1225 1226 1227 1228 1229 1230
## 2.826774286 2.090067047 1.121655044 3.185792612 3.185792612 4.463548398
## 1231 1232 1233 1234 1235 1236
## 3.185792612 4.510042474 4.510042474 3.311682208 2.741080163 3.576576969
## 1237 1238 1239 1240 1241 1242
## 3.152177038 3.941555458 1.491118072 1.273632067 2.001036536 2.181642939
## 1243 1244 1245 1246 1247 1248
## 1.625687790 1.625687790 0.011048255 3.614131258 2.377357571 1.704386739
## 1249 1250 1251 1252 1253 1254
## 0.994591598 0.484685266 1.977183348 3.411892413 1.807615857 1.545581855
## 1255
## 2.254219377
# Generate a Q-Q Plot
qqnorm(res2); qqline(res2)
shapiro.test(res2) # test for normality
##
## Shapiro-Wilk normality test
##
## data: res2
## W = 0.86114, p-value < 2.2e-16
leveneTest(aov(transTemp ~ Type, data = df)) # test for homogeneity of variances
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 3 38.208 < 2.2e-16 ***
## 1251
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
The transformation instituted solved the homogeneity of variances issue (if the Levene’s test P-value becomes nonsignificant) and did not alter the normality assumption, so we can proceed with the analysis. However, before moving further we will graph the transformed data to make sure we can interpret the differences in a biologically meaningful way.
cipplot2 <- summarySE(df, measurevar = "transTemp", groupvars = "Type")
cipplot2
## Type N transTemp sd se ci
## 1 Te 723 4.791674 1.7136306 0.06373061 0.1251194
## 2 Tw 182 4.316083 1.4597611 0.10820469 0.2135048
## 3 Tb 182 4.198094 1.5137137 0.11220392 0.2213960
## 4 Tp 168 3.763846 0.2934756 0.02264213 0.0447017
plot2 <- ggplot(df, aes(x = Type,
y = transTemp,
colour = Type,
group = Type,
fill = Type)) +
geom_dotplot(binaxis = "y", stackdir = "center") +
geom_point(data = cipplot2,
aes(x = Type, y = transTemp),
size = 3,
position = position_nudge(x = 0.25)) +
geom_errorbar(data = cipplot2,
aes(x = Type,
ymax = transTemp + ci,
ymin = transTemp - ci),
width = 0.1,
position = position_nudge(x = 0.25)) +
xlab("Temperature Type") +
ylab("Transformed Temperature (1 / °C × 100)") +
ggtitle("Transformed Temperatures by Type in Mediterranean Geckos") +
th
plot2
## Bin width defaults to 1/30 of the range of the data. Pick better value with
## `binwidth`.
The following code performs an ANOVA on the transformed response
variable (transTemp) using the linear model created
earlier. This tests whether meantransformed temperature differs among
the Temperature Types.
Anova(model2)
## Anova Table (Type II tests)
##
## Response: transTemp
## Sum Sq Df F value Pr(>F)
## Type 175.3 3 24.906 1.184e-15 ***
## Residuals 2935.0 1251
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Unfortunately, these data will require people to think in reverse
when they look at your graphics (low values mean high Temperature; high
values mean low Temperature). So we probably want to back-transform the
means and 95% Confidence Intervals into their original units. We can do
this by forming additional columns in the cipplot2 dataframe that make
this conversion. First, remind yourself how the output from
summarySE is arranged.
cipplot2 # Check the structure of the cipplot2 dataframe
## Type N transTemp sd se ci
## 1 Te 723 4.791674 1.7136306 0.06373061 0.1251194
## 2 Tw 182 4.316083 1.4597611 0.10820469 0.2135048
## 3 Tb 182 4.198094 1.5137137 0.11220392 0.2213960
## 4 Tp 168 3.763846 0.2934756 0.02264213 0.0447017
cipplot2$Temp_mean <- 100 / cipplot2$transTemp # perform the back-transformation
cipplot2 # Check to see that it did it
## Type N transTemp sd se ci Temp_mean
## 1 Te 723 4.791674 1.7136306 0.06373061 0.1251194 20.86953
## 2 Tw 182 4.316083 1.4597611 0.10820469 0.2135048 23.16916
## 3 Tb 182 4.198094 1.5137137 0.11220392 0.2213960 23.82033
## 4 Tp 168 3.763846 0.2934756 0.02264213 0.0447017 26.56857
cipplot2$LL <- 100 / (cipplot2$transTemp + cipplot2$ci)
cipplot2
## Type N transTemp sd se ci Temp_mean LL
## 1 Te 723 4.791674 1.7136306 0.06373061 0.1251194 20.86953 20.33846
## 2 Tw 182 4.316083 1.4597611 0.10820469 0.2135048 23.16916 22.07706
## 3 Tb 182 4.198094 1.5137137 0.11220392 0.2213960 23.82033 22.62704
## 4 Tp 168 3.763846 0.2934756 0.02264213 0.0447017 26.56857 26.25673
cipplot2$UL <- 100 / (cipplot2$transTemp - cipplot2$ci)
cipplot2
## Type N transTemp sd se ci Temp_mean LL UL
## 1 Te 723 4.791674 1.7136306 0.06373061 0.1251194 20.86953 20.33846 21.42909
## 2 Tw 182 4.316083 1.4597611 0.10820469 0.2135048 23.16916 22.07706 24.37492
## 3 Tb 182 4.198094 1.5137137 0.11220392 0.2213960 23.82033 22.62704 25.14649
## 4 Tp 168 3.763846 0.2934756 0.02264213 0.0447017 26.56857 26.25673 26.88791
cipplot # original means on the Temperature scale
## Type N Temperature sd se ci
## 1 Te 723 23.11526 6.689431 0.2487826 0.4884238
## 2 Tw 182 25.16308 6.095890 0.4518574 0.8915857
## 3 Tb 182 26.07148 6.444087 0.4776675 0.9425130
## 4 Tp 168 26.73077 2.101961 0.1621698 0.3201671
cipplot2 # back-transformed means and confidence limits
## Type N transTemp sd se ci Temp_mean LL UL
## 1 Te 723 4.791674 1.7136306 0.06373061 0.1251194 20.86953 20.33846 21.42909
## 2 Tw 182 4.316083 1.4597611 0.10820469 0.2135048 23.16916 22.07706 24.37492
## 3 Tb 182 4.198094 1.5137137 0.11220392 0.2213960 23.82033 22.62704 25.14649
## 4 Tp 168 3.763846 0.2934756 0.02264213 0.0447017 26.56857 26.25673 26.88791
plot3 <- ggplot(df, aes(x = Type,
y = Temperature,
colour = Type,
group = Type,
fill = Type)) +
geom_dotplot(binaxis = "y", stackdir = "center") +
geom_point(data = cipplot2,
aes(x = Type, y = Temp_mean),
size = 3,
position = position_nudge(x = 0.25),
inherit.aes = FALSE) +
geom_errorbar(data = cipplot2,
aes(x = Type,
ymin = LL,
ymax = UL),
width = 0.1,
position = position_nudge(x = 0.25),
inherit.aes = FALSE) +
xlab("Temperature Type") +
ylab("Temperature (°C)") +
ggtitle("Effect of Temperature Type on Gecko Body Temperatures") +
th
plot3
## Bin width defaults to 1/30 of the range of the data. Pick better value with
## `binwidth`.
Since we observed a significant ANOVA, we can examine which Temperature Types differ from one another using the Tukey–Kramer test. This test examines all pairwise comparisons of the Type means. NOTE: I am doing Tukey’s test on the transformed data column.
TukeyHSD(aov(transTemp ~ Type, data = df))
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = transTemp ~ Type, data = df)
##
## $Type
## diff lwr upr p adj
## Tw-Te -0.4755911 -0.8023646 -0.14881766 0.0010848
## Tb-Te -0.5935795 -0.9203530 -0.26680603 0.0000195
## Tp-Te -1.0278284 -1.3653040 -0.69035277 0.0000000
## Tb-Tw -0.1179884 -0.5310422 0.29506547 0.8830743
## Tp-Tw -0.5522373 -0.9738086 -0.13066595 0.0043071
## Tp-Tb -0.4342489 -0.8558202 -0.01267758 0.0406180
I have recreated the graphic to include the results of the Tukey–Kramer test results. Treatments (Temperature Types) that share the same letter are not significantly different from one another, whereas Types with different letters are significantly different.
cipplot2$Tukey <- c("A", "B", "C", "C")
cipplot2
## Type N transTemp sd se ci Temp_mean LL UL
## 1 Te 723 4.791674 1.7136306 0.06373061 0.1251194 20.86953 20.33846 21.42909
## 2 Tw 182 4.316083 1.4597611 0.10820469 0.2135048 23.16916 22.07706 24.37492
## 3 Tb 182 4.198094 1.5137137 0.11220392 0.2213960 23.82033 22.62704 25.14649
## 4 Tp 168 3.763846 0.2934756 0.02264213 0.0447017 26.56857 26.25673 26.88791
## Tukey
## 1 A
## 2 B
## 3 C
## 4 C
plot4 <- plot3 +
geom_text(data = cipplot2,
aes(x = Type, y = Temp_mean, label = Tukey),
position = position_nudge(x = 0.4),
color = "black",
na.rm = TRUE) +
th
plot4
## Bin width defaults to 1/30 of the range of the data. Pick better value with
## `binwidth`.
This plot shows the raw Temperature data in a dotplot, the means and confidence intervals to the right of the raw data (confidence intervals based on back-transformed confidence intervals), with letters indicating the results of a Tukey–Kramer test where Types with the same letter are not different from one another while Types with different letters are different from one another.
A suitable caption for this figure would be: Figure 1. Effect of different temperature types on Mediterranean gecko body temperatures. Field body temperature (Tb) and preferred temperature (Tp) are compared to environmental wall temperatures (Te) and wall temperatures next to the lizard (Tw). Overall ANOVA on transformed temperatures indicates a significant effect of Temperature Type on gecko temperature (report your F-value and P-value here). Raw data, means, and 95% confidence intervals are plotted with letters to the right of the means indicating the results of the Tukey–Kramer tests, with like letters indicating Types that are not different from one another. Key: Te = environmental wall temperature, Tw = wall temperature next to the lizard, Tb = field body temperature, Tp = preferredbody temperature measured in the lab. The above caption is a pretty good description of the results. If you are concerned about the violation of the homogeneity of variances assumption, you can use the Kruskal–Wallis test, which ranks the data and then repartitions the data to the respective Temperature Types. Keep in mind that one of the assumptions of this test is that the distributions differ only in location, so this test does NOT relax the homogeneity of variances assumption.
kruskal.test(Temperature ~ Type, data = df)
##
## Kruskal-Wallis rank sum test
##
## data: Temperature by Type
## Kruskal-Wallis chi-squared = 52.768, df = 3, p-value = 2.055e-11
Dunn’s test is a non-parametric procedure for conducting all possible pairwise comparisons. Because Dunn’s test does not control for an experiment-wide alpha level of 0.05, we must apply a correction to account for the large number of comparisons. In this case, we used the Bonferroni correction, which divides the experiment-wide alpha (0.05) by the number of pairwise comparisons. With ten pairwise comparisons, our corrected alpha = 0.05 / 10 = 0.005.
dunnTest(Temperature ~ Type, data = df, method = "bonferroni")
## Dunn (1964) Kruskal-Wallis multiple comparison
## p-values adjusted with the Bonferroni method.
## Comparison Z P.unadj P.adj
## 1 Tb - Te 6.339770 2.301081e-10 1.380648e-09
## 2 Tb - Tp 1.677865 9.337338e-02 5.602403e-01
## 3 Te - Tp -4.042748 5.282843e-05 3.169706e-04
## 4 Tb - Tw 2.047458 4.061309e-02 2.436785e-01
## 5 Te - Tw -3.751707 1.756350e-04 1.053810e-03
## 6 Tp - Tw 0.328226 7.427408e-01 1.000000e+00
The Dunn’s test results differ slightly from the Tukey–Kramer test on the transformed data. In this case: - The simple sugars (glucose, fructose, and the glucose:fructose mix) are not different from one another. - 2% Sucrose (Tp) is not different from 2% Glucose (Te) when using Bonferroni-corrected Dunn’s tests. - Control and 2% Sucrose remain distinct from the three simple sugar treatments. - Control plants still differ significantly from all other treatments except 2% Sucrose. These rankings are similar to the parametric post hoc results, but some borderline differences lose significance under Dunn’s test. This is expected because Kruskal–Wallis + Dunn procedures have lower statistical power than parametric methods when the assumptions of ANOVA are met. For this reason, the parametric tests on the transformed data (which satisfied both normality and homogeneity of variances) should be considered the primary analysis, while the Dunn’s test provides supportive nonparametric verification.
This experiment examined whether Mediterranean geckos maintain different body temperatures depending on environmental wall temperatures (Te), wall temperatures immediately next to the gecko (Tw), field body temperatures (Tb), and preferred laboratory body temperatures (Tp). Statistical analyses on the transformed data revealed a highly significant effect of Temperature Type on recorded body temperature measurements. Post hoc testing with the Tukey–Kramer test indicated clear groupings: Tp (preferred temperature) belonged to the highest temperature group. Tb (field body temperature) was the next highest. Tw and Te had similar values and represented the lowest temperatures. These results show that geckos in the field are not fully thermoconforming; rather, they maintain body temperatures higher than available environmental temperatures (Te and Tw) and regulate their physiology toward temperatures closer to those they prefer in the laboratory (Tp). Thus, Mediterranean geckos appear to be effective behavioral thermoregulators. Non-parametric analyses (Kruskal-Wallis followed by Dunn’s test) returned generally similar results, but with slightly reduced resolution among the treatment levels. Given that the transformed data passed the assumptions of normality and homogeneity of variances, the parametric results should be considered the most reliable.
Taken together, the findings support the conclusion that Mediterranean geckos actively regulate their body temperatures rather than passively matching ambient conditions. Their field body temperatures fall between their preferred laboratory temperatures and the temperatures available in their microhabitats, demonstrating behavioral thermoregulation in a newly expanded geographic range.