climpred.classes.HindcastEnsemble.bootstrap#
- HindcastEnsemble.bootstrap(*, alignment: str, metric: str | Metric, comparison: str | Comparison, dim: str | List[str] | None = None, reference: str | List[str] | None = None, groupby: DataArray | str | None = None, iterations: int | None = None, sig: int = 95, resample_dim: str = 'member', **metric_kwargs: Any | None) Dataset [source]#
Bootstrap with replacement according to Goddard et al. [2013].
- Parameters:
metric – Metric to apply for verification, see metrics
comparison – How to compare to the observations/verification data. See comparisons.
dim – Dimension(s) to apply metric over.
dim
is passed on to xskillscore.{metric} and includes xskillscore’smember_dim
.dim
should containmember
whencomparison
is probabilistic but should not containmember
whencomparison="e2o"
. Defaults toNone
meaning that all dimensions other thanlead
are reduced.reference – Type of reference forecasts with which to verify against. One or more of
["uninitialized", "persistence", "climatology"]
. Defaults toNone
meaning no reference. IfNone
or[]
, returns no p value.alignment – which inits or verification times should be aligned?
“”maximize: maximize the degrees of freedom by slicing
init
andverif
to a common time frame at each lead."same_inits"
: slice to a commoninit
frame prior to computing metric. This philosophy follows the thought that each lead should be based on the same set of initializations."same_verif"
: slice to a common/consistent verification time frame prior to computing metric. This philosophy follows the thought that each lead should be based on the same set of verification dates.
iterations – Number of resampling iterations for bootstrapping with replacement. Recommended >= 500.
sig – Significance level in percent for deciding whether uninitialized and persistence beat initialized skill.
resample_dim – dimension to resample from. Default:
"member"
."member"
: select a different set of members from hind"init"
: select a different set of initializations from hind
groupby – group
init
before passinginitialized
tobootstrap
.**metric_kwargs – arguments passed to
metric
.
- Returns:
xarray.Dataset
with dimensionsresults
(holdingskill
,p
,low_ci
andhigh_ci
) andskill
(holdinginitialized
,persistence
and/oruninitialized
):- results=”verify skill”, skill=”initialized”:
mean initialized skill
- results=”high_ci”, skill=”initialized”:
high confidence interval boundary for initialized skill
- results=”p”, skill=”uninitialized”:
p value of the hypothesis that the difference of skill between the initialized and uninitialized simulations is smaller or equal to zero based on bootstrapping with replacement.
- results=”p”, skill=”persistence”:
p value of the hypothesis that the difference of skill between the initialized and persistence simulations is smaller or equal to zero based on bootstrapping with replacement.
References
Goddard et al. [2013]
Example
Continuous Ranked Probability Score (
"crps"
) comparing every member forecast to the verification ("m2o"
) over the same initializations ("same_inits"
) for all leads reducing dimensionmember
50 times after resamplingmember
dimension with replacement. Note that dimensioninit
remains. Also calculate reference skill for the"persistence"
,"climatology"
and"uninitialized"
forecast and compare whether initialized skill is better than reference skill: Returns verify skill, probability that reference forecast performs better than initialized and the lower and upper bound of the resample.>>> HindcastEnsemble.bootstrap( ... metric="crps", ... comparison="m2o", ... dim="member", ... iterations=50, ... resample_dim="member", ... alignment="same_inits", ... reference=["persistence", "climatology", "uninitialized"], ... ) <xarray.Dataset> Dimensions: (skill: 4, results: 4, lead: 10, init: 51) Coordinates: * lead (lead) int32 1 2 3 4 5 6 7 8 9 10 valid_time (lead, init) object 1956-01-01 00:00:00 ... 2015-01-01 00:00:00 * init (init) object 1955-01-01 00:00:00 ... 2005-01-01 00:00:00 * skill (skill) <U13 'initialized' 'persistence' ... 'uninitialized' * results (results) <U12 'verify skill' 'p' 'low_ci' 'high_ci' Data variables: SST (skill, results, lead, init) float64 0.1202 0.01764 ... 0.07578 Attributes: prediction_skill_software: climpred https://climpred.readthedocs.io/ skill_calculated_by_function: HindcastEnsemble.bootstrap() number_of_members: 10 alignment: same_inits metric: crps comparison: m2o dim: member reference: ['persistence', 'climatology', 'uninitiali... resample_dim: member sig: 95 iterations: 50 confidence_interval_levels: 0.975-0.025