    Return the data calculated by the last plot_pvalue call.

get_pvalue_results()

The `get_pvalue_results` function returns the likelihood ratio test results computed by the `plot_pvalue` command, which compares fits of the null model to fits of the alternative model using faked data with Poisson noise. The likelihood ratio based on the observed data is returned, along with the p-value, used to reject or accept the null model.

Return the results of the last pvalue analysis and display the results - first using the `format` method, which provides a summary of the data, and then a look at the individual fields in the returned object. The last call displays the contents of one of the fields ( `ppp` ).

>>> res = get_pvalue_results() >>> print(res.format()) >>> print(res) >>> print(res.ppp)

Display the ratio values to check they look sensible (such as not dropping to a long range of 0's, although this can also suggest the alternate model is not preferred to the null model):

>>> plot_trace(res.ratios, name="ratios")

Look at the cumulative distribution of the ratios:

>>> plot_cdf(res.ratios, name="ratios")

The parvals field shows the fitted parameter values for the alternate model at each iteration:

>>> plot_trace(res.parvals[:, 0], name=res.parnames[0]) >>> plot_trace(res.parvals[:, 1], name=res.parnames[1])

PARAMETERS

This function has no parameters

The return value from this function is:

plot -- If `plot_pvalue` or `get_pvalue_plot` have been called then the return value is a `sherpa.sim.simulate.LikelihoodRatioResults`

instance, otherwise `None` is returned.

Notes

The fields of the returned ( `LikelihoodRatioResults` ) object are:

Item
Definition
ratios
The calculated likelihood ratio for each iteration.
stats
The calculated fit statistics for each iteration, stored as the null model and then the alt model in a nsim by 2 array.
samples
The parameter samples array for each simulation, stored in a nsim by npar array.
lr
The likelihood ratio of the observed data for the null and alternate models.
ppp
The p value of the observed data for the null and alternate models.
null
The fit statistic of the null model on the observed data.
alt
The fit statistic of the alternate model on the observed data.
parnames
The names of the fitted parameters in the alternate model. This will be larger than the number of parameters returned in the samples field.
parvals
The best-fit parameter values to the alternate model for each simulation, stored as a nsim by len(parnames) array.

Changes in CIAO

The parnames and parvals attributes have been added. They are intended to debug problem cases and so are not displayed by default.

See the bugs pages on the Sherpa website for an up-to-date listing of known bugs.

December 2023