Plot arrows
dat_phenophase_time_summ <- dat_phenophase_time_clean %>%
summ_phenophase_time(group_vars = c("site", "canopy", "heat", "heat_name", "water", "water_name", "species", "phenophase", "year")) # ignore block and plot
dat_climate_spring <- summ_climate_season(dat_climate_daily, date_start = "Mar 15", date_end = "May 15", rainfall = 1, group_vars = c("site", "canopy", "heat", "heat_name", "water", "water_name", "year"))
dat_climate_fall <- summ_climate_season(dat_climate_daily, date_start = "Jun 15", date_end = "Sep 15", rainfall = 0, group_vars = c("site", "canopy", "heat", "heat_name", "water", "water_name", "year"))
Note that some climatic data not available in 2009.
dat_climate_spring %>% filter(site == "cfc", canopy == "open", year == "2009")
## # A tibble: 2 × 10
## site canopy heat heat_name water water_name year temp mois prcp
## <chr> <fct> <fct> <fct> <fct> <fct> <dbl> <dbl> <dbl> <dbl>
## 1 cfc open + +1.7 °C _ ambient 2009 5.73 0.200 0
## 2 cfc open ++ +3.4 °C _ ambient 2009 6.30 0.200 0
plot_trend(
dat_phenophase = dat_phenophase_time_summ %>%
filter(phenophase == "budbreak") %>%
filter(species == "pinba"),
dat_climate = dat_climate_spring
)
plot_trend(
dat_phenophase = dat_phenophase_time_summ %>%
filter(phenophase == "mostleaf") %>%
filter(species == "poptr"),
dat_climate = dat_climate_spring,
var = "heat"
)
plot_trend(
dat_phenophase = dat_phenophase_time_summ %>%
filter(phenophase == "senescence") %>%
filter(species == "acesa"),
dat_climate = dat_climate_fall,
var = "heat"
)
plot_trend(
dat_phenophase = dat_phenophase_time_summ %>%
filter(phenophase == "leafdrop") %>%
filter(species == "pinst"),
dat_climate = dat_climate_fall,
var = "heat"
)
Interaction model
df_plot_ambient <- summ_treatment(dat_phenophase) %>%
filter(heat_name == "ambient", water_name == "ambient") %>%
distinct(site, canopy, block, plot)
dat_climate_spring <- summ_climate_season(dat_climate_daily, date_start = "Mar 15", date_end = "May 15", rainfall = 1)
dat_climate_spring_ambient <- dat_climate_spring %>%
inner_join(df_plot_ambient, by = c("site", "canopy", "block", "plot")) %>%
group_by(site, canopy, block, year) %>%
summarise(
temp = mean(temp),
mois = mean(mois)
) %>%
ungroup() %>%
mutate(
temp_std = scale(temp) %>% as.numeric(),
mois_std = scale(mois) %>% as.numeric()
)
temp_sd_spring <- dat_climate_spring_ambient %>%
pull(temp) %>%
sd()
dat_climate_fall <- summ_climate_season(dat_climate_daily, date_start = "Jun 15", date_end = "Sep 15", rainfall = 0)
dat_climate_fall_ambient <- dat_climate_fall %>%
inner_join(df_plot_ambient, by = c("site", "canopy", "block", "plot")) %>%
group_by(site, canopy, block, year) %>%
summarise(
temp = mean(temp),
mois = mean(mois)
) %>%
ungroup() %>%
mutate(
temp_std = scale(temp) %>% as.numeric(),
mois_std = scale(mois) %>% as.numeric()
)
temp_sd_fall <- dat_climate_fall_ambient %>%
pull(temp) %>%
sd()
dat_phenophase_time_cov <- dat_phenophase_time_clean %>%
tidy_treatment_code() %>%
left_join(dat_climate_spring_ambient, by = c("site", "canopy", "block", "year")) %>%
group_by(species) %>%
mutate(group = site %>% factor() %>% as.integer()) %>% # use site as random effects, not site-year
ungroup()
test_phenophase_lme(data = dat_phenophase_time_cov, path = "alldata/intermediate/phenophase/bg/", season = "spring", chains = 1, iter = 4000, version = 3, num_cores = 5) # v3 with interactions
tidy_stanfit_all(season = "spring", path = "alldata/intermediate/phenophase/bg/")
calc_bayes_derived(path = "alldata/intermediate/phenophase/bg/", season = "spring", type = "phenophase", random = F, num_cores = 20)
dat_phenophase_time_cov <- dat_phenophase_time_clean %>%
tidy_treatment_code() %>%
left_join(dat_climate_fall_ambient, by = c("site", "canopy", "block", "year")) %>%
group_by(species) %>%
mutate(group = site %>% factor() %>% as.integer()) %>% # use site as random effects, not site-year
ungroup()
test_phenophase_lme(data = dat_phenophase_time_cov, path = "alldata/intermediate/phenophase/bg/", season = "fall", chains = 1, iter = 4000, version = 3, num_cores = 5) # v3 with interactions
tidy_stanfit_all(season = "fall", path = "alldata/intermediate/phenophase/bg/")
calc_bayes_derived(path = "alldata/intermediate/phenophase/bg/", season = "fall", type = "phenophase", random = F, num_cores = 20)
Plot comparisons
df_lme_spring <- read_bayes_all(path = "alldata/intermediate/phenophase/bg/", season = "spring", full_factorial = T, derived = T, tidy_mcmc = T)
df_compare_trends_spring <- test_compare_trends(df_lme_spring, temp_sd = temp_sd_spring) %>%
mutate(season = "spring") %>%
tidy_phenophase_name(season = "spring")
df_lme_fall <- read_bayes_all(path = "alldata/intermediate/phenophase/bg/", season = "fall", full_factorial = T, derived = T, tidy_mcmc = T)
df_compare_trends_fall <- test_compare_trends(df_lme_fall, temp_sd = temp_sd_fall) %>%
mutate(season = "fall") %>%
tidy_phenophase_name(season = "fall")
df_compare_trends <- bind_rows(df_compare_trends_spring, df_compare_trends_fall) %>%
mutate(season = factor(season, levels = c("spring", "fall"))) %>%
tidy_species_name()
plot_trend_compare(df_compare_trends %>% filter(response == "start", season == "spring"), species_label = T)
plot_trend_compare(df_compare_trends %>% filter(response == "end", season == "spring"), species_label = T)
plot_trend_compare(df_compare_trends %>% filter(response == "start", season == "fall"), species_label = T)
plot_trend_compare(df_compare_trends %>% filter(response == "end", season == "fall"), species_label = T)