  Detection of millikelvin-level signals from the 'Cosmic Dawn' requires an
unprecedented level of sensitivity and systematic calibration. We report the
theory behind a novel calibration algorithm developed from the formalism
introduced by the EDGES collaboration for use in 21-cm experiments.
Improvements over previous approaches are provided through the incorporation of
a Bayesian framework and machine learning techniques such as the use of
Bayesian evidence to determine the level of frequency variation of calibration
parameters that is supported by the data, the consideration of correlation
between calibration parameters when determining their values and the use of a
conjugate-prior based approach that results in a fast algorithm for application
in the field. In self-consistency tests using empirical data models of varying
complexity, our methodology is used to calibrate a 50 $\Omega$
ambient-temperature load. The RMS error between the calibration solution and
the measured temperature of the load is 8 mK, well within the 1$\sigma$ noise
level. Whilst the methods described here are more applicable to global 21-cm
experiments, they can easily be adapted and applied to other applications,
including telescopes such as HERA and the SKA.
