  Current analysis of astronomical data are confronted with the daunting task
of modeling the awkward features of astronomical data, among which
heteroscedastic (point-dependent) errors, intrinsic scatter, non-ignorable data
collection (selection effects), data structure, non-uniform populations (often
called Malmquist bias), non-Gaussian data, and upper/lower limits. This chapter
shows, by examples, how modeling all these features using Bayesian methods. In
short, one just need to formalize, using maths, the logical link between the
involved quantities, how the data arise and what we already known on the
quantities we want to study. The posterior probability distribution summarizes
what we known on the studied quantities after the data, and we should not be
afraid about their actual numerical computation, because it is left to
(special) Monte Carlo programs such as JAGS. As examples, we show how to
predict the mass of a new object disposing of a calibrating sample, how to
constraint cosmological parameters from supernovae data and how to check if the
fitted data are in tension with the adopted fitting model. Examples are given
with their coding. These examples can be easily used as template for completely
different analysis, on totally unrelated astronomical objects, requiring to
model the same awkward data features.
