Se tienen datos del número de especies (sp.rich) de aves
insectívoras, en dos continentes.Se quiere contestar si el número de
especies de esa familia de aves en el continente a es mayor
que en el b. Pero, los muestreos se hicieron a lo largo de
distintos gradientes latitudinales (latitude), y ya se se
sabe que existe una relación negativa entre la latitud y el número de
especies. Además, la lattitud utilizada para los muestreos varía en
ambos continentes. Entonces se necesita hacer un análisis para comparar
la riqueza de spp. entre los dos continentes pero que tome en cuenta
dicha relación entre la latitud y la riqueza de especies y la diferencia
entre las latitudes utilizadas para los muestreos en ambos continentes
(ver figuras).
library(ggplot2)
library(ggpubr)
library(rcompanion)
library(car)
library(googlesheets4)
library(plotly)
gs4_deauth()
ss= "https://docs.google.com/spreadsheets/d/1DTTlT8hUJ5DXfwJXm9L6eb9ShiNS8Foov6gIClYRKb8/edit?usp=sharing"
hoja= "hoja1"
rango = "B1:D18"
sp <- read_sheet(ss,
sheet= hoja,
range= rango,
col_names= TRUE
)
✔ Reading from Riqueza spp.
✔ Range ''hoja1'!B1:D18'.
sp$continent <- as.factor(sp$continent)
str(sp)
tibble [17 × 3] (S3: tbl_df/tbl/data.frame)
$ latitude : num [1:17] 37.2 38.3 38.8 38.6 39.2 ...
$ sp.rich : num [1:17] 157 152 137 135 128 125 121 118 118 118 ...
$ continent: Factor w/ 2 levels "a","b": 2 2 2 2 2 2 2 1 2 1 ...
head(sp); tail(sp)
p <- ggdensity(sp$sp.rich)
ggplotly(p)
shapiro.test(sp$sp.rich)
Shapiro-Wilk normality test
data: sp$sp.rich
W = 0.94747, p-value = 0.4177
p <- ggplot(aes(y = sp.rich, x= continent, col= continent), data=sp) +
geom_boxplot() + geom_point(position=position_jitter(width=0.15))
ggplotly(p)
p <- ggplot(aes(y = sp.rich, x= latitude), data=sp) +
geom_point(aes(col= continent)) +
geom_smooth(method = "lm")
ggplotly(p)
p <- ggplot(aes(y = latitude, x= continent, col= continent), data=sp) +
geom_boxplot() + geom_point(position=position_jitter(width=0.15))
ggplotly(p)
p <- ggplot(aes(y = sp.rich, x= latitude, col= continent), data= sp)
p +
geom_point() +
geom_smooth(method = "lm")
latitude y
sp.richmod <- lm( sp.rich ~ latitude, data= sp)
summary(mod)
Call:
lm(formula = sp.rich ~ latitude, data = sp)
Residuals:
Min 1Q Median 3Q Max
-25.694 -11.251 -2.046 14.510 28.101
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 585.473 228.523 2.562 0.0217 *
latitude -12.046 5.914 -2.037 0.0597 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 16.27 on 15 degrees of freedom
Multiple R-squared: 0.2167, Adjusted R-squared: 0.1644
F-statistic: 4.149 on 1 and 15 DF, p-value: 0.05971
latitude y
continentmod <- lm( sp.rich ~ latitude * continent, data= sp )
summary(mod)
Call:
lm(formula = sp.rich ~ latitude * continent, data = sp)
Residuals:
Min 1Q Median 3Q Max
-17.164 -7.021 2.748 7.249 16.211
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 241.837 211.695 1.142 0.274
latitude -3.461 5.455 -0.634 0.537
continentb 372.894 321.653 1.159 0.267
latitude:continentb -9.039 8.332 -1.085 0.298
Residual standard error: 10.94 on 13 degrees of freedom
Multiple R-squared: 0.6927, Adjusted R-squared: 0.6218
F-statistic: 9.768 on 3 and 13 DF, p-value: 0.001215
latitude y
continent se lograra descartar, entonces basarse en un
modelo aditivo para contestar la preguntamod <- lm( sp.rich ~ latitude + continent, data= sp )
summary(mod)
Call:
lm(formula = sp.rich ~ latitude + continent, data = sp)
Residuals:
Min 1Q Median 3Q Max
-16.7348 -8.1157 -0.4995 5.4416 16.8984
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 392.184 161.035 2.435 0.028842 *
latitude -7.336 4.149 -1.768 0.098845 .
continentb 23.997 5.546 4.327 0.000696 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 11.01 on 14 degrees of freedom
Multiple R-squared: 0.6649, Adjusted R-squared: 0.617
F-statistic: 13.89 on 2 and 14 DF, p-value: 0.0004746