climpred.classes.PerfectModelEnsemble.bootstrap
climpred.classes.PerfectModelEnsemble.bootstrap#
- PerfectModelEnsemble.bootstrap(metric: Optional[Union[str, climpred.metrics.Metric]] = None, comparison: Optional[Union[str, climpred.comparisons.Comparison]] = None, dim: Optional[Union[str, List[str]]] = None, reference: Optional[Union[str, List[str]]] = None, groupby: Optional[Union[xarray.DataArray, str]] = None, iterations: Optional[int] = None, sig: int = 95, resample_dim: str = 'member', **metric_kwargs: Optional[Any]) xarray.Dataset [source]#
Bootstrap with replacement according to Goddard et al. [2013].
- Parameters
metric – Metric to apply for verification, see metrics
comparison – How to compare the forecast against itself, see comparisons
dim – Dimension(s) over which to apply metric.
dim
is passed on to xskillscore.{metric} and includes xskillscore’smember_dim
.dim
should containmember
whencomparison
is probabilistic but should not containmember
whencomparison=e2c
. 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. Forpersistence
, choose betweenset_options(PerfectModel_persistence_from_initialized_lead_0)=False
(default) usingcompute_persistence()
orset_options(PerfectModel_persistence_from_initialized_lead_0)=True
usingcompute_persistence_from_first_lead()
.iterations – Number of resampling iterations for bootstrapping with replacement. Recommended >= 500.
resample_dim – dimension to resample from. Defaults to “member”`.
“member”: select a different set of members from forecast
“init’: select a different set of initializations from forecast
sig – Significance level in percent for deciding whether uninitialized and persistence beat initialized skill.
groupby – group
init
before passinginitialized
tobootstrap
.**metric_kwargs – arguments passed to
metric
.
- Returns
xarray.Dataset
with dimensionsresults
(holdingverify skill
,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 persistenceistence simulations is smaller or equal to zero based on bootstrapping with replacement.
- Reference:
Goddard et al. [2013]
Example
Continuous Ranked Probability Score (
"crps"
) comparing every member to every other member ("m2m"
) reducing dimensionsmember
andinit
50 times after resamplingmember
dimension with replacement. 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.>>> PerfectModelEnsemble.bootstrap( ... metric="crps", ... comparison="m2m", ... dim=["init", "member"], ... iterations=50, ... resample_dim="member", ... reference=["persistence", "climatology", "uninitialized"], ... ) <xarray.Dataset> Dimensions: (skill: 4, results: 4, lead: 20) Coordinates: * lead (lead) int64 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 * skill (skill) <U13 'initialized' 'persistence' ... 'uninitialized' * results (results) <U12 'verify skill' 'p' 'low_ci' 'high_ci' Data variables: tos (skill, results, lead) float64 0.0621 0.07352 ... 0.117 0.09826 Attributes: (12/13) prediction_skill_software: climpred https://climp... skill_calculated_by_function: PerfectModelEnsemble.b... number_of_initializations: 12 number_of_members: 10 metric: crps comparison: m2m ... ... reference: ['persistence', 'clima... PerfectModel_persistence_from_initialized_lead_0: False resample_dim: member sig: 95 iterations: 50 confidence_interval_levels: 0.975-0.025