Quantifies a peak (or trough) in an index as the value in year divided by
the mean of the neighbours. A ratio is unaffected by the level of the
index, so it compares scenarios with different prediction grids.
Usage
peak_ratio(x, year, neighbours = c(year - 1, year + 1), group = NULL)Arguments
- x
An object from
sdmTMB_data_scenarios()orsdmTMB_leave_out(), or a data frame with columnsyear,estand optionally a grouping column.- year
The year of the peak.
- neighbours
The years to compare with. Default the years before and after
year.- group
Name of the grouping column for a data frame. Default
"scenario"for scenario objects and"id"for leave-out objects.
Value
A tibble with the group, peak (the index in year),
neighbours (mean of the neighbouring years) and peak_ratio.
Examples
idx <- data.frame(year = 2000:2004, est = c(10, 11, 20, 12, 10))
peak_ratio(idx, year = 2002)
#> .group peak neighbours peak_ratio
#> 1 Index 20 11.5 1.73913