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#
Nrep
int, float or double scalarThe number of times to replicate the predicted data.
Lobs
int, float or double array(Nfilters)The observed luminosities [arbitrary units].
Lunc
int, float or double array(Nfilters)The uncertainties on the observed luminosities in the same units as
Lobs
.Lpredict
int, float, or double array(Nfilters, Nchain)The model luminosities predicted by the model given a set of parameters in same units as
Lobs
.lnprob_chain
int, 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_obs
int, float, or double array(Nxray)The observed X-ray counts. If specified,
counts_unc
andcounts_predict
must also be given.counts_unc
int, float, or double array(Nxray)The uncertainties on the observed X-ray counts. If specified,
counts_obs
andcounts_predict
must also be given.counts_predict
: int, float, or double array(Nxray, Nchain)The X-ray counts predicted by the model. If specified,
counts_obs
andcounts_unc
must also be given.model_unc
int, float, or double scalarThe fractional model uncertainty to use in all bands. (Default =
0.d0
)
Output#
pvalue
double scalarThe p-value associated with the PPC. Determined as the fraction of
chisqr_rep
that is greater thanchisqr_obs
.
Optional Outputs#
chisqr_obs
double array(Nrep)The resulting \(\chi^2\) values by comparing the predicted data with the observational data.
chisqr_rep
double 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
NaNs
inlnprob_chain
(Keith Doore)2022/07/27: Fixed bug with missing keyword
nrand
inmrandomn
(Keith Doore)2022/07/27: Fixed bug where
value_locate
maybe selecting-1
when we want0
, force-1
to be0
(Keith Doore)2022/09/01: Added X-ray emission (Erik B. Monson)
2022/09/15: Changed from
chi2_chain
input tolnprob_chain
(Keith Doore)2022/09/30: Added
model_unc
input to include in uncertainties (Keith Doore)