PPC#
Name#
PPC
Purpose#
Computes a Posterior Predictive Check (PPC) on a MCMC Lightning output. Uses the methods described in Rubin (1984) and Gelman et al. (1996).
Calling Sequence#
pvalue = ppc(Nrep, Lobs, Lunc, Lpredict, lnprob_chain [, $
counts_obs = , counts_unc = , counts_predict = , $
chisqr_obs=chisqr_obs, chisqr_rep=chisqr_rep])
Inputs#
Nrepint, float or double scalarThe number of times to replicate the predicted data.
Lobsint, float or double array(Nfilters)The observed luminosities [arbitrary units].
Luncint, float or double array(Nfilters)The uncertainties on the observed luminosities in the same units as
Lobs.Lpredictint, float, or double array(Nfilters, Nchain)The model luminosities predicted by the model given a set of parameters in same units as
Lobs.lnprob_chainint, float, or double array(Nchain)The log posterior probability values of each SED predicted by the model given a set of parameters. Used to select the replicated data.
Optional Inputs#
counts_obsint, float, or double array(Nxray)The observed X-ray counts. If specified,
counts_uncandcounts_predictmust also be given.counts_uncint, float, or double array(Nxray)The uncertainties on the observed X-ray counts. If specified,
counts_obsandcounts_predictmust also be given.counts_predict: int, float, or double array(Nxray, Nchain)The X-ray counts predicted by the model. If specified,
counts_obsandcounts_uncmust also be given.model_uncint, float, or double scalarThe fractional model uncertainty to use in all bands. (Default =
0.d0)
Output#
pvaluedouble scalarThe p-value associated with the PPC. Determined as the fraction of
chisqr_repthat is greater thanchisqr_obs.
Optional Outputs#
chisqr_obsdouble array(Nrep)The resulting \(\chi^2\) values by comparing the predicted data with the observational data.
chisqr_repdouble array(Nrep)The resulting \(\chi^2\) values by comparing the predicted data with the replicated data.
Notes#
If the X-ray model was fit using fluxes rather than counts, the X-ray luminosities can simply be appended to
Lobs,Lunc, andLpredict.
References#
Modification History#
2022/03/15: Created (Keith Doore)
2022/04/18: Added documentation (Keith Doore)
2022/04/18: Added error handling (Keith Doore)
2022/07/21: Added ability to handle
NaNsinlnprob_chain(Keith Doore)2022/07/27: Fixed bug with missing keyword
nrandinmrandomn(Keith Doore)2022/07/27: Fixed bug where
value_locatemaybe selecting-1when we want0, force-1to be0(Keith Doore)2022/09/01: Added X-ray emission (Erik B. Monson)
2022/09/15: Changed from
chi2_chaininput tolnprob_chain(Keith Doore)2022/09/30: Added
model_uncinput to include in uncertainties (Keith Doore)