Basking_plot <- visualize(lm_BaskYear, Bask_year~Elevation + Loc_type|Species, plot="model")+
scale_color_manual(values = c("firebrick", "gold", "navyblue"))+
scale_shape_manual(values =c(19, 19, 19))+
scale_linetype_manual(values =c(1, 1, 1))+
theme_classic()+
labs_pubr()+
labs(title = NULL, y=expression(paste("Mean yearly basking time \n (hours)")), x=NULL)+
theme(strip.background = element_blank(),
strip.text.x = element_blank(),
axis.text=element_text(size=11),
axis.title=element_text(size=12,face="bold"))+
facet_wrap(~Species)
Basking_plot
#Check model fit, residuals etc.
autoplot(lm_BaskYear)+
theme_classic()
shapiro.test(residuals(lm_BaskYear))
#Check comparisons
summary(glht(lm_BaskYear, linfct = mcp(Loc_type = 'Tukey')))
#check data
gghistogram(res_ecto_stats$Forage_year, bins = 8)
ggboxplot(res_ecto_stats$Forage_year)
#Check lm model first
lm_ForageYear <- lm(Forage_year ~ Elevation + Species + Loc_type, data = res_ecto_stats)
lm_ForageYear_int <- lm(Forage_year ~ Elevation*Species+Loc_type, data = res_ecto_stats)
lm_ForageYear_int2<- lm(Forage_year ~ Elevation*Loc_type+Species, data = res_ecto_stats)
lm_ForageYear_int3<- lm(Forage_year ~ Elevation+Loc_type*Species, data = res_ecto_stats)
compare.fits(Forage_year ~Elevation | Species+Loc_type,
data = res_ecto_stats, lm_ForageYear, lm_ForageYear_int)
compare.fits(Forage_year ~Elevation | Species+Loc_type,
data = res_ecto_stats, lm_ForageYear, lm_ForageYear_int2)
compare.fits(Forage_year ~Elevation | Species+Loc_type,
data = res_ecto_stats, lm_ForageYear, lm_ForageYear_int3)
AIC(lm_ForageYear, lm_ForageYear_int, lm_ForageYear_int2, lm_ForageYear_int3)
anova(lm_ForageYear, lm_ForageYear_int, lm_ForageYear_int2, lm_ForageYear_int3)
summary(lm_ForageYear) ## NO SIGNIFICANT INTERACTION
#summary(lm_ForageYear_int)
#summary(lm_ForageYear_int2)
#summary(lm_ForageYear_int3)
# Plot
visualize(lm_ForageYear)
Forage_plot <-  visualize(lm_ForageYear, Forage_year~Elevation + Loc_type|Species, plot="model")+
scale_color_manual(values = c("firebrick", "gold", "navyblue"))+
scale_shape_manual(values =c(19, 19, 19))+
scale_linetype_manual(values =c(1, 1, 1))+
theme_classic()+
labs_pubr()+
labs(title = NULL, y=expression(paste("Mean yearly foraging time \n (hours")), x="Elevation (m)")+
theme(strip.background = element_blank(),
strip.text.x = element_blank(),
axis.text=element_text(size=11),
axis.title=element_text(size=12,face="bold"))+
facet_wrap(~Species)
Forage_plot
#Check model fit, residuals etc.
autoplot(lm_ForageYear)+
theme_classic()
shapiro.test(residuals(lm_ForageYear))
#Check comparisons
summary(glht(lm_ForageYear, linfct = mcp(Loc_type = 'Tukey')))
#check data distribution
gghistogram(res_ecto_stats$Fecundity_year, bins = 15)
ggboxplot(res_ecto_stats$Fecundity_year)
#Check lm model first
lm_FecundityYear <- lm(Fecundity_year ~Elevation+ Species+Loc_type, data = res_ecto_stats)
lm_FecundityYear_int <- lm(Fecundity_year ~ Elevation*Species+Loc_type, data = res_ecto_stats)
lm_FecundityYear_int2<- lm(Fecundity_year ~Elevation*Loc_type+Species, data = res_ecto_stats)
lm_FecundityYear_int3<- lm(Fecundity_year ~Elevation+Loc_type*Species, data = res_ecto_stats)
compare.fits(Fecundity_year ~Elevation | Species+Loc_type,
data = res_ecto_stats, lm_FecundityYear, lm_FecundityYear_int)
compare.fits(Fecundity_year ~Elevation | Species+Loc_type,
data = res_ecto_stats, lm_FecundityYear, lm_FecundityYear_int2)
compare.fits(Fecundity_year ~Elevation | Species+Loc_type,
data = res_ecto_stats, lm_FecundityYear, lm_FecundityYear_int3)
AIC(lm_FecundityYear, lm_FecundityYear_int, lm_FecundityYear_int2, lm_FecundityYear_int3)
anova(lm_FecundityYear, lm_FecundityYear_int, lm_FecundityYear_int2, lm_FecundityYear_int3)
#summary(lm_FecundityYear)
summary(lm_FecundityYear_int) ## significant interaction
#summary(lm_FecundityYear_int2)
#summary(lm_FecundityYear_int3)
# Plot
visualize(lm_FecundityYear_int)
Fecundity_plot <-  visualize(lm_FecundityYear_int, Fecundity_year~Elevation + Loc_type|Species, plot="model")+
scale_color_manual(values = c("firebrick", "gold", "navyblue"))+
scale_shape_manual(values =c(19, 19, 19))+
scale_linetype_manual(values =c(1, 1, 1))+
theme_classic()+
labs_pubr()+
labs(title = NULL, y=expression(paste("Yearly fecundity \n (n. offspring)")), x="Elevation (m)")+
theme(strip.background = element_blank(),
strip.text.x = element_blank(),
axis.text=element_text(size=11),
axis.title=element_text(size=12,face="bold"))+
facet_wrap(~Species)
Fecundity_plot
#Check model fit, residuals etc.
autoplot(lm_FecundityYear_int)+
theme_classic()
shapiro.test(residuals(lm_FecundityYear_int))
#Check comparisons
summary(glht(lm_FecundityYear_int, linfct = mcp(Loc_type = 'Tukey')))
plot_ecto <- ggarrange(EggDev_plot, Lifespan_plot, YearsRepro_plot, Basking_plot, Forage_plot, Fecundity_plot, nrow = 3, ncol = 2, labels = "AUTO", common.legend = FALSE, legend = "none", hjust = -2.5, font.label = list(size = 13, color = "black", face = "bold"))
plot_ecto
ggsave("plot_ecto_final.pdf", plot=plot_ecto, path = "../../Figures/Ectotherm_plots/", units="cm", width=20, height=22, dpi=300)
ggsave("plot_ecto_final.svg", plot=plot_ecto, path = "../../Figures/Ectotherm_plots/", units="cm", width=20, height=22, dpi=300)
ggsave("plot_ecto_final.png", plot=plot_ecto, path = "../../Figures/Ectotherm_plots/", units="cm", width=20, height=22, dpi=300, bg="white")
plot_ecto <- ggarrange(EggDev_plot, Lifespan_plot, YearsRepro_plot, Basking_plot, Forage_plot, Fecundity_plot, nrow = 3, ncol = 2, labels = "AUTO", common.legend = FALSE, legend = "none", font.label = list(size = 13, color = "black", face = "bold"))
plot_ecto
ggsave("plot_ecto_final.pdf", plot=plot_ecto, path = "../../Figures/Ectotherm_plots/", units="cm", width=20, height=22, dpi=300)
ggsave("plot_ecto_final.svg", plot=plot_ecto, path = "../../Figures/Ectotherm_plots/", units="cm", width=20, height=22, dpi=300)
ggsave("plot_ecto_final.png", plot=plot_ecto, path = "../../Figures/Ectotherm_plots/", units="cm", width=20, height=22, dpi=300, bg="white")
#check data distribution
gghistogram(res_ecto_stats$Fecundity_year, bins = 15)
ggboxplot(res_ecto_stats$Fecundity_year)
#Check lm model first
lm_FecundityYear <- lm(Fecundity_year ~Elevation+ Species+Loc_type, data = res_ecto_stats)
lm_FecundityYear_int <- lm(Fecundity_year ~ Elevation*Species+Loc_type, data = res_ecto_stats)
lm_FecundityYear_int2<- lm(Fecundity_year ~Elevation*Loc_type+Species, data = res_ecto_stats)
lm_FecundityYear_int3<- lm(Fecundity_year ~Elevation+Loc_type*Species, data = res_ecto_stats)
compare.fits(Fecundity_year ~Elevation | Species+Loc_type,
data = res_ecto_stats, lm_FecundityYear, lm_FecundityYear_int)
compare.fits(Fecundity_year ~Elevation | Species+Loc_type,
data = res_ecto_stats, lm_FecundityYear, lm_FecundityYear_int2)
compare.fits(Fecundity_year ~Elevation | Species+Loc_type,
data = res_ecto_stats, lm_FecundityYear, lm_FecundityYear_int3)
AIC(lm_FecundityYear, lm_FecundityYear_int, lm_FecundityYear_int2, lm_FecundityYear_int3)
anova(lm_FecundityYear, lm_FecundityYear_int, lm_FecundityYear_int2, lm_FecundityYear_int3)
#summary(lm_FecundityYear)
summary(lm_FecundityYear_int) ## significant interaction
#summary(lm_FecundityYear_int2)
#summary(lm_FecundityYear_int3)
# Plot
visualize(lm_FecundityYear_int)
Fecundity_plot <-  visualize(lm_FecundityYear_int, Fecundity_year~Elevation + Loc_type|Species, plot="model")+
scale_color_manual(values = c("firebrick", "gold", "navyblue"))+
scale_shape_manual(values =c(19, 19, 19))+
scale_linetype_manual(values =c(1, 1, 1))+
theme_classic()+
labs_pubr()+
labs(title = NULL, y=expression(paste("Yearly fecundity (n. offspring)")), x="Elevation (m)")+
theme(strip.background = element_blank(),
strip.text.x = element_blank(),
axis.text=element_text(size=11),
axis.title=element_text(size=12,face="bold"))+
facet_wrap(~Species)
Fecundity_plot
#Check model fit, residuals etc.
autoplot(lm_FecundityYear_int)+
theme_classic()
shapiro.test(residuals(lm_FecundityYear_int))
#Check comparisons
summary(glht(lm_FecundityYear_int, linfct = mcp(Loc_type = 'Tukey')))
plot_ecto <- ggarrange(EggDev_plot, Lifespan_plot, YearsRepro_plot, Basking_plot, Forage_plot, Fecundity_plot, nrow = 3, ncol = 2, labels = "AUTO", common.legend = FALSE, legend = "none", font.label = list(size = 13, color = "black", face = "bold"))
plot_ecto
ggsave("plot_ecto_final.pdf", plot=plot_ecto, path = "../../Figures/Ectotherm_plots/", units="cm", width=20, height=22, dpi=300)
ggsave("plot_ecto_final.svg", plot=plot_ecto, path = "../../Figures/Ectotherm_plots/", units="cm", width=20, height=22, dpi=300)
ggsave("plot_ecto_final.png", plot=plot_ecto, path = "../../Figures/Ectotherm_plots/", units="cm", width=20, height=22, dpi=300, bg="white")
plot_ecto <- ggarrange(EggDev_plot, Lifespan_plot, YearsRepro_plot, Basking_plot, Forage_plot, Fecundity_plot, nrow = 3, ncol = 2, labels = "AUTO", common.legend = FALSE, legend = "none", font.label = list(size = 13, color = "black", face = "bold"))
plot_ecto
ggsave("plot_ecto_final.pdf", plot=plot_ecto, path = "../../Figures/Ectotherm_plots/", units="cm", width=10, height=10, dpi=300)
ggsave("plot_ecto_final.svg", plot=plot_ecto, path = "../../Figures/Ectotherm_plots/", units="cm", width=20, height=22, dpi=300)
ggsave("plot_ecto_final.png", plot=plot_ecto, path = "../../Figures/Ectotherm_plots/", units="cm", width=20, height=22, dpi=300, bg="white")
plot_ecto <- ggarrange(EggDev_plot, Lifespan_plot, YearsRepro_plot, Basking_plot, Forage_plot, Fecundity_plot, nrow = 3, ncol = 2, labels = "AUTO", common.legend = FALSE, legend = "none", font.label = list(size = 13, color = "black", face = "bold"))
plot_ecto
ggsave("plot_ecto_final.pdf", plot=plot_ecto, path = "../../Figures/Ectotherm_plots/", units="cm", width=20, height=20, dpi=300)
ggsave("plot_ecto_final.svg", plot=plot_ecto, path = "../../Figures/Ectotherm_plots/", units="cm", width=20, height=20, dpi=300)
ggsave("plot_ecto_final.png", plot=plot_ecto, path = "../../Figures/Ectotherm_plots/", units="cm", width=20, height=20, dpi=300, bg="white")
#check data distribution
gghistogram(res_ecto_stats$egg_dev, bins = 15)+
theme_pubclean()
ggboxplot(res_ecto_stats$egg_dev)+
theme_pubclean()+
labs(y=NULL, x=NULL)
#Check lm model first
lm_eggDev <- lm(egg_dev ~ Elevation+Species+Loc_type, data = res_ecto_stats)
lm_eggDev_int <- lm(egg_dev ~ Elevation*Species+Loc_type, data = res_ecto_stats)
lm_eggDev_int2<- lm(egg_dev ~ Elevation*Loc_type+Species, data = res_ecto_stats)
lm_eggDev_int3<- lm(egg_dev ~ Elevation+Loc_type*Species, data = res_ecto_stats)
compare.fits(egg_dev ~Elevation | Species+
Loc_type, data = res_ecto_stats, lm_eggDev, lm_eggDev_int)
compare.fits(egg_dev ~Elevation | Species+
Loc_type, data = res_ecto_stats, lm_eggDev, lm_eggDev_int2)
compare.fits(egg_dev ~Elevation | Species+
Loc_type, data = res_ecto_stats, lm_eggDev, lm_eggDev_int3)
AIC(lm_eggDev, lm_eggDev_int, lm_eggDev_int2, lm_eggDev_int3)
anova(lm_eggDev, lm_eggDev_int, lm_eggDev_int2, lm_eggDev_int3)
summary(lm_eggDev) ## NO SIGNIFICANT INTERACTIONS
#summary(lm_eggDev_int)
#summary(lm_eggDev_int2)
#summary(lm_eggDev_int3)
# Get summary and p values
visualize(lm_eggDev)
EggDev_plot <- visualize(lm_eggDev, egg_dev~Elevation+Loc_type |Species, plot="model")+
scale_color_manual(values = c("firebrick", "gold", "navyblue"))+
scale_shape_manual(values =c(19, 19, 19))+
scale_linetype_manual(values =c(1, 1, 1))+
theme_classic()+
labs_pubr()+
labs(title = NULL, y=expression(paste("Egg development time (days)")), x=NULL)+
theme(
strip.text = element_text(face = "italic"),
axis.text=element_text(size=11),
axis.title=element_text(size=12,face="bold"))+
facet_wrap(~Species)
EggDev_plot
#Check model fit, residuals etc.
autoplot(lm_eggDev)+
theme_classic()
shapiro.test(residuals(lm_eggDev))
#Check comparisons
summary(glht(lm_eggDev, linfct = mcp(Loc_type = 'Tukey')))
#check data
gghistogram(res_ecto_stats$LifeSpan, bins = 4)
ggboxplot(res_ecto_stats$LifeSpan)
#Check lm model first
lm_Lifespan <- lm(LifeSpan ~ Elevation + Species+ Loc_type, data = res_ecto_stats)
lm_Lifespan_int <- lm(LifeSpan ~ Elevation*Species+Loc_type, data = res_ecto_stats)
lm_Lifespan_int2<- lm(LifeSpan ~ Elevation*Loc_type+Species, data = res_ecto_stats)
lm_Lifespan_int3<- lm(LifeSpan ~ Elevation+Loc_type*Species, data = res_ecto_stats)
compare.fits(LifeSpan ~Elevation | Species+Loc_type,
data = res_ecto_stats, lm_Lifespan, lm_Lifespan_int)
compare.fits(LifeSpan ~Elevation | Species+Loc_type,
data = res_ecto_stats, lm_Lifespan, lm_Lifespan_int2)
compare.fits(LifeSpan ~Elevation | Species+Loc_type,
data = res_ecto_stats, lm_Lifespan, lm_Lifespan_int3)
AIC(lm_Lifespan, lm_Lifespan_int, lm_Lifespan_int2, lm_Lifespan_int3)
anova(lm_Lifespan, lm_Lifespan_int, lm_Lifespan_int2, lm_Lifespan_int3)
summary(lm_Lifespan) ## NO SIGNIFICANT INTERACTIONS, CHECKED MODELS BY AIC AND COMPARED FITS
#summary(lm_Lifespan_int)
#summary(lm_Lifespan_int2)
#summary(lm_Lifespan_int3)
# Get summary and p values
visualize(lm_Lifespan_int2)
Lifespan_plot <-   visualize(lm_Lifespan, LifeSpan~Elevation + Loc_type|Species, plot="model")+
scale_color_manual(values = c("firebrick", "gold", "navyblue"))+
scale_shape_manual(values =c(19, 19, 19))+
scale_linetype_manual(values =c(1, 1, 1))+
theme_classic()+
labs_pubr()+
labs(title = NULL, y=expression(paste("Lifespan (years)")), x=NULL)+
theme(
strip.text = element_text(face = "italic"),
axis.text=element_text(size=11),
axis.title=element_text(size=12,face="bold"))+
facet_wrap(~Species)
Lifespan_plot
#Check model fit, residuals etc.
autoplot(lm_Lifespan_int2)+
theme_classic()
shapiro.test(residuals(lm_Lifespan_int2))
#Check comparisons
summary(glht(lm_Lifespan, linfct = mcp(Loc_type = 'Tukey')))
#check data
gghistogram(res_ecto_stats$Years_repro, bins = 8)
ggboxplot(res_ecto_stats$Years_repro)
#Check lm model first
lm_YearsRepro_noLoc <- lm(Years_repro ~ Elevation + Species, data = res_ecto_stats)
lm_YearsRepro <- lm(Years_repro ~ Elevation + Species + Loc_type, data = res_ecto_stats)
lm_YearsRepro_int <- lm(Years_repro ~ Elevation*Species+Loc_type, data = res_ecto_stats)
lm_YearsRepro_int2<- lm(Years_repro ~ Elevation*Loc_type+Species, data = res_ecto_stats)
lm_YearsRepro_int3<- lm(Years_repro ~ Elevation+Loc_type*Species, data = res_ecto_stats)
compare.fits(Years_repro ~Elevation | Species+Loc_type,
data = res_ecto_stats, lm_YearsRepro, lm_YearsRepro_int)
compare.fits(Years_repro ~Elevation | Species+Loc_type,
data = res_ecto_stats, lm_YearsRepro, lm_YearsRepro_int2)
compare.fits(Years_repro ~Elevation | Species+Loc_type,
data = res_ecto_stats, lm_YearsRepro, lm_YearsRepro_int3)
AIC(lm_YearsRepro, lm_YearsRepro_int, lm_YearsRepro_int2, lm_YearsRepro_int3, lm_YearsRepro_noLoc)
anova(lm_YearsRepro_noLoc, lm_YearsRepro, lm_YearsRepro_int, lm_YearsRepro_int2, lm_YearsRepro_int3)
summary(lm_YearsRepro_noLoc) ## OPT FOR SIMPLER MODEL
#summary(lm_YearsRepro_int)
#summary(lm_YearsRepro_int2)
#summary(lm_YearsRepro_int3)
# Get summary and p values
visualize(lm_YearsRepro_noLoc)
YearsRepro_plot <-  visualize(lm_YearsRepro_noLoc, Years_repro~Elevation | Species, plot="model")+
scale_color_manual(values = c("black"))+
theme_classic()+
labs_pubr()+
labs(title = NULL, y=expression(paste("Years reproducing (years)")), x=NULL)+
theme(strip.background = element_blank(),
strip.text.x = element_blank(),
axis.text=element_text(size=11),
axis.title=element_text(size=12,face="bold"))+
facet_wrap(~Species)
YearsRepro_plot
#Check model fit, residuals etc.
autoplot(lm_YearsRepro)+
theme_classic()
shapiro.test(residuals(lm_YearsRepro))
#check data
gghistogram(res_ecto_stats$Bask_year, bins = 8)
ggboxplot(res_ecto_stats$Bask_year)
#Check lm model first
lm_BaskYear <- lm(Bask_year ~ Elevation + Species + Loc_type, data = res_ecto_stats)
lm_BaskYear_int <- lm(Bask_year ~ Elevation*Species+Loc_type, data = res_ecto_stats)
lm_BaskYear_int2<- lm(Bask_year ~ Elevation*Loc_type+Species, data = res_ecto_stats)
lm_BaskYear_int3<- lm(Bask_year ~ Elevation+Loc_type*Species, data = res_ecto_stats)
compare.fits(Bask_year ~Elevation | Species+Loc_type,
data = res_ecto_stats, lm_BaskYear, lm_BaskYear_int)
compare.fits(Bask_year ~Elevation | Species+Loc_type,
data = res_ecto_stats, lm_BaskYear, lm_BaskYear_int2)
compare.fits(Bask_year ~Elevation | Species+Loc_type,
data = res_ecto_stats, lm_BaskYear, lm_BaskYear_int3)
AIC(lm_BaskYear, lm_BaskYear_int, lm_BaskYear_int2, lm_BaskYear_int3)
anova(lm_BaskYear, lm_BaskYear_int, lm_BaskYear_int2, lm_BaskYear_int3)
summary(lm_BaskYear) ## NO SIGNIFICANT INTERACTIONS
#summary(lm_BaskYear_int)
#summary(lm_BaskYear_int2)
#summary(lm_BaskYear_int3)
# Get summary and p values
visualize(lm_BaskYear)
Basking_plot <- visualize(lm_BaskYear, Bask_year~Elevation + Loc_type|Species, plot="model")+
scale_color_manual(values = c("firebrick", "gold", "navyblue"))+
scale_shape_manual(values =c(19, 19, 19))+
scale_linetype_manual(values =c(1, 1, 1))+
theme_classic()+
labs_pubr()+
labs(title = NULL, y=expression(paste("Mean yearly basking time (hours)")), x=NULL)+
theme(strip.background = element_blank(),
strip.text.x = element_blank(),
axis.text=element_text(size=11),
axis.title=element_text(size=12,face="bold"))+
facet_wrap(~Species)
Basking_plot
#Check model fit, residuals etc.
autoplot(lm_BaskYear)+
theme_classic()
shapiro.test(residuals(lm_BaskYear))
#Check comparisons
summary(glht(lm_BaskYear, linfct = mcp(Loc_type = 'Tukey')))
#check data
gghistogram(res_ecto_stats$Forage_year, bins = 8)
ggboxplot(res_ecto_stats$Forage_year)
#Check lm model first
lm_ForageYear <- lm(Forage_year ~ Elevation + Species + Loc_type, data = res_ecto_stats)
lm_ForageYear_int <- lm(Forage_year ~ Elevation*Species+Loc_type, data = res_ecto_stats)
lm_ForageYear_int2<- lm(Forage_year ~ Elevation*Loc_type+Species, data = res_ecto_stats)
lm_ForageYear_int3<- lm(Forage_year ~ Elevation+Loc_type*Species, data = res_ecto_stats)
compare.fits(Forage_year ~Elevation | Species+Loc_type,
data = res_ecto_stats, lm_ForageYear, lm_ForageYear_int)
compare.fits(Forage_year ~Elevation | Species+Loc_type,
data = res_ecto_stats, lm_ForageYear, lm_ForageYear_int2)
compare.fits(Forage_year ~Elevation | Species+Loc_type,
data = res_ecto_stats, lm_ForageYear, lm_ForageYear_int3)
AIC(lm_ForageYear, lm_ForageYear_int, lm_ForageYear_int2, lm_ForageYear_int3)
anova(lm_ForageYear, lm_ForageYear_int, lm_ForageYear_int2, lm_ForageYear_int3)
summary(lm_ForageYear) ## NO SIGNIFICANT INTERACTION
#summary(lm_ForageYear_int)
#summary(lm_ForageYear_int2)
#summary(lm_ForageYear_int3)
# Plot
visualize(lm_ForageYear)
Forage_plot <-  visualize(lm_ForageYear, Forage_year~Elevation + Loc_type|Species, plot="model")+
scale_color_manual(values = c("firebrick", "gold", "navyblue"))+
scale_shape_manual(values =c(19, 19, 19))+
scale_linetype_manual(values =c(1, 1, 1))+
theme_classic()+
labs_pubr()+
labs(title = NULL, y=expression(paste("Mean yearly foraging time (hours")), x="Elevation (m)")+
theme(strip.background = element_blank(),
strip.text.x = element_blank(),
axis.text=element_text(size=11),
axis.title=element_text(size=12,face="bold"))+
facet_wrap(~Species)
Forage_plot
#Check model fit, residuals etc.
autoplot(lm_ForageYear)+
theme_classic()
shapiro.test(residuals(lm_ForageYear))
#Check comparisons
summary(glht(lm_ForageYear, linfct = mcp(Loc_type = 'Tukey')))
#check data distribution
gghistogram(res_ecto_stats$Fecundity_year, bins = 15)
ggboxplot(res_ecto_stats$Fecundity_year)
#Check lm model first
lm_FecundityYear <- lm(Fecundity_year ~Elevation+ Species+Loc_type, data = res_ecto_stats)
lm_FecundityYear_int <- lm(Fecundity_year ~ Elevation*Species+Loc_type, data = res_ecto_stats)
lm_FecundityYear_int2<- lm(Fecundity_year ~Elevation*Loc_type+Species, data = res_ecto_stats)
lm_FecundityYear_int3<- lm(Fecundity_year ~Elevation+Loc_type*Species, data = res_ecto_stats)
compare.fits(Fecundity_year ~Elevation | Species+Loc_type,
data = res_ecto_stats, lm_FecundityYear, lm_FecundityYear_int)
compare.fits(Fecundity_year ~Elevation | Species+Loc_type,
data = res_ecto_stats, lm_FecundityYear, lm_FecundityYear_int2)
compare.fits(Fecundity_year ~Elevation | Species+Loc_type,
data = res_ecto_stats, lm_FecundityYear, lm_FecundityYear_int3)
AIC(lm_FecundityYear, lm_FecundityYear_int, lm_FecundityYear_int2, lm_FecundityYear_int3)
anova(lm_FecundityYear, lm_FecundityYear_int, lm_FecundityYear_int2, lm_FecundityYear_int3)
#summary(lm_FecundityYear)
summary(lm_FecundityYear_int) ## significant interaction
#summary(lm_FecundityYear_int2)
#summary(lm_FecundityYear_int3)
# Plot
visualize(lm_FecundityYear_int)
Fecundity_plot <-  visualize(lm_FecundityYear_int, Fecundity_year~Elevation + Loc_type|Species, plot="model")+
scale_color_manual(values = c("firebrick", "gold", "navyblue"))+
scale_shape_manual(values =c(19, 19, 19))+
scale_linetype_manual(values =c(1, 1, 1))+
theme_classic()+
labs_pubr()+
labs(title = NULL, y=expression(paste("Yearly fecundity (n. offspring)")), x="Elevation (m)")+
theme(strip.background = element_blank(),
strip.text.x = element_blank(),
axis.text=element_text(size=11),
axis.title=element_text(size=12,face="bold"))+
facet_wrap(~Species)
Fecundity_plot
#Check model fit, residuals etc.
autoplot(lm_FecundityYear_int)+
theme_classic()
shapiro.test(residuals(lm_FecundityYear_int))
#Check comparisons
summary(glht(lm_FecundityYear_int, linfct = mcp(Loc_type = 'Tukey')))
plot_ecto <- ggarrange(EggDev_plot, Lifespan_plot, YearsRepro_plot, Basking_plot, Forage_plot, Fecundity_plot, nrow = 3, ncol = 2, labels = "AUTO", common.legend = FALSE, legend = "none", font.label = list(size = 13, color = "black", face = "bold"))
plot_ecto
ggsave("plot_ecto_final.pdf", plot=plot_ecto, path = "../../Figures/Ectotherm_plots/", units="cm", width=20, height=20, dpi=300)
ggsave("plot_ecto_final.svg", plot=plot_ecto, path = "../../Figures/Ectotherm_plots/", units="cm", width=20, height=20, dpi=300)
ggsave("plot_ecto_final.png", plot=plot_ecto, path = "../../Figures/Ectotherm_plots/", units="cm", width=20, height=20, dpi=300, bg="white")
YearsRepro_plot <-  visualize(lm_YearsRepro_noLoc, Years_repro~Elevation | Species, plot="model")+
scale_color_manual(values = c("black"))+
theme_classic()+
labs_pubr()+
labs(title = NULL, y=expression(paste("Years reproducing (years)")), x=NULL)+
scale_y_continuous(breaks = c(0, 1, 2, 3, 4, 5, 6),
labels = c(0, 1, 2, 3, 4, 5, " ",))+
theme(strip.background = element_blank(),
strip.text.x = element_blank(),
axis.text=element_text(size=11),
axis.title=element_text(size=12,face="bold"))+
facet_wrap(~Species)
YearsRepro_plot <-  visualize(lm_YearsRepro_noLoc, Years_repro~Elevation | Species, plot="model")+
scale_color_manual(values = c("black"))+
theme_classic()+
labs_pubr()+
labs(title = NULL, y=expression(paste("Years reproducing (years)")), x=NULL)+
scale_y_continuous(breaks = c(0, 1, 2, 3, 4, 5, 6),
labels = c(0, 1, 2, 3, 4, 5, ,))+
theme(strip.background = element_blank(),
strip.text.x = element_blank(),
axis.text=element_text(size=11),
axis.title=element_text(size=12,face="bold"))+
facet_wrap(~Species)
YearsRepro_plot
YearsRepro_plot <-  visualize(lm_YearsRepro_noLoc, Years_repro~Elevation | Species, plot="model")+
scale_color_manual(values = c("black"))+
theme_classic()+
labs_pubr()+
labs(title = NULL, y=expression(paste("Years reproducing (years)")), x=NULL)+
scale_y_continuous(breaks = c(0, 1, 2, 3, 4, 5, 6),
labels = c(0, 1, 2, 3, 4, 5,))+
theme(strip.background = element_blank(),
strip.text.x = element_blank(),
axis.text=element_text(size=11),
axis.title=element_text(size=12,face="bold"))+
facet_wrap(~Species)
YearsRepro_plot
YearsRepro_plot <-  visualize(lm_YearsRepro_noLoc, Years_repro~Elevation | Species, plot="model")+
scale_color_manual(values = c("black"))+
theme_classic()+
labs_pubr()+
labs(title = NULL, y=expression(paste("Years reproducing (years)")), x=NULL)+
scale_y_continuous(breaks = c(0, 1, 2, 3, 4, 5, 6),
labels = c(0, 1, 2, 3, 4, 5))+
theme(strip.background = element_blank(),
strip.text.x = element_blank(),
axis.text=element_text(size=11),
axis.title=element_text(size=12,face="bold"))+
facet_wrap(~Species)
YearsRepro_plot
YearsRepro_plot <-  visualize(lm_YearsRepro_noLoc, Years_repro~Elevation | Species, plot="model")+
scale_color_manual(values = c("black"))+
theme_classic()+
labs_pubr()+
labs(title = NULL, y=expression(paste("Years reproducing (years)")), x=NULL)+
scale_y_continuous(breaks = c(0, 1, 2, 3, 4, 5),
labels = c(0, 1, 2, 3, 4, 5))+
theme(strip.background = element_blank(),
strip.text.x = element_blank(),
axis.text=element_text(size=11),
axis.title=element_text(size=12,face="bold"))+
facet_wrap(~Species)
YearsRepro_plot
YearsRepro_plot <-  visualize(lm_YearsRepro_noLoc, Years_repro~Elevation | Species, plot="model")+
scale_color_manual(values = c("black"))+
theme_classic()+
labs_pubr()+
labs(title = NULL, y=expression(paste("Years reproducing (years)")), x=NULL)+
scale_y_continuous(breaks = c(0, 1, 2, 3, 4, 5, 6),
labels = c(0, 1, 2, 3, 4, 5, 6))+
theme(strip.background = element_blank(),
strip.text.x = element_blank(),
axis.text=element_text(size=11),
axis.title=element_text(size=12,face="bold"))+
facet_wrap(~Species)
YearsRepro_plot
YearsRepro_plot
YearsRepro_plot <-  visualize(lm_YearsRepro_noLoc, Years_repro~Elevation | Species, plot="model")+
scale_color_manual(values = c("black"))+
theme_classic()+
labs_pubr()+
labs(title = NULL, y=expression(paste("Years reproducing (years)")), x=NULL)+
theme(strip.background = element_blank(),
strip.text.x = element_blank(),
axis.text=element_text(size=11),
axis.title=element_text(size=12,face="bold"))+
facet_wrap(~Species)
YearsRepro_plot
plot_ecto <- ggarrange(EggDev_plot, Lifespan_plot, YearsRepro_plot, Basking_plot, Forage_plot, Fecundity_plot, nrow = 3, ncol = 2, labels = "AUTO", common.legend = FALSE, legend = "none", font.label = list(size = 13, color = "black", face = "bold"))
plot_ecto
ggsave("plot_ecto_final.pdf", plot=plot_ecto, path = "../../Figures/Ectotherm_plots/", units="cm", width=20, height=20, dpi=300)
ggsave("plot_ecto_final.svg", plot=plot_ecto, path = "../../Figures/Ectotherm_plots/", units="cm", width=20, height=20, dpi=300)
ggsave("plot_ecto_final.png", plot=plot_ecto, path = "../../Figures/Ectotherm_plots/", units="cm", width=20, height=20, dpi=300, bg="white")
