Skip to content

Commit

Permalink
Predict IPHC index on HBLL grid; #15
Browse files Browse the repository at this point in the history
  • Loading branch information
quang-huynh committed Apr 2, 2024
1 parent 83fbe7b commit 642a62c
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions analysis/01-iphc-index.R
Original file line number Diff line number Diff line change
Expand Up @@ -640,3 +640,37 @@ gg <- plot(marginal_depth, gg = TRUE,
coord_cartesian(xlim = c(0, 500), expand = FALSE) +
labs(x = "Depth (m)", y = "log(CPUE)")
ggsave("figs/iphc/depth_marginal.png", gg, height = 3, width = 4)


# Generate IPHC index on HBLL grid - is decline in HBLL a function of habitat?
hbll <- sdmTMB::replicate_df(gfplot::hbll_grid$grid, "year", unique(fit_iphc_nb2$data$year)) %>%
mutate(depth_m_log = log(depth), area = 4) %>%
bind_rows() %>%
sdmTMB::add_utm_columns(ll_names = c("X", "Y"), utm_names = c("UTM_lon", "UTM_lat"), utm_crs = 32609)

g <- rbind(
gfplot::hbll_grid$grid %>% rename(longitude = X, latitude = Y) %>%
select(longitude, latitude) %>%
mutate(name = "HBLL grid"),
d %>%
select(longitude, latitude) %>%
mutate(name = "IPHC sets")
) %>%
ggplot(aes(longitude, latitude, colour = name)) +
geom_sf(data = coast, inherit.aes = FALSE) +
coord_sf(expand = FALSE) +
geom_point(shape = 1) +
labs(x = "Longitude", y = "Latitude", colour = NULL) +
theme(legend.position = "bottom") +
scale_colour_manual(values = c(1, 2))
ggsave("figs/iphc/iphc_hbll_grid.png", g, width = 5, height = 5)

p <- predict(fit_iphc_nb2, newdata = hbll, return_tmb_object = TRUE)
ind <- get_index(p, bias_correct = TRUE)
g <- ggplot(ind, aes(year, est)) +
geom_linerange(aes(ymin = lwr, ymax = upr)) +
geom_point() +
expand_limits(y = 0) +
labs(x = "Year", y = "IPHC index on HBLL grid")
ggsave("figs/iphc/iphc_index_on_hbll.png", g, height = 3, width = 4)
g

0 comments on commit 642a62c

Please sign in to comment.