The function sim_stratmean() [in sim_stratmean_fn.R] is being passed an argument that is the survey area. This is independent of the strata that are used in the survey data frame, and that get joined to the data from strata_wts.
Thus, the calculations are based on the area of the total survey footprint, not the area of the strata used (so effective weights over strata won't sum to 1).
Can be fixed by having both the survey area to be used in the calculations, as well as the relative weights of each strata, be calculated within the function rather than being passed as arguments.
NB: I would also adjust this function so it only does one calculation, and have the looping (currently over simulations and years) occur outside of the function. But this seems like a lower priority than ensuring the calculations are being done correctly.
@AngeliaMiller & @CataRoman,
The function
sim_stratmean()
[insim_stratmean_fn.R
] is being passed an argument that is the survey area. This is independent of the strata that are used in the survey data frame, and that get joined to the data fromstrata_wts
. Thus, the calculations are based on the area of the total survey footprint, not the area of the strata used (so effective weights over strata won't sum to 1). Can be fixed by having both the survey area to be used in the calculations, as well as the relative weights of each strata, be calculated within the function rather than being passed as arguments.NB: I would also adjust this function so it only does one calculation, and have the looping (currently over simulations and years) occur outside of the function. But this seems like a lower priority than ensuring the calculations are being done correctly.