Redshift inference from the combination of galaxy colors and clustering
  in a hierarchical Bayesian model $-$ Application to realistic $N$-body
  simulations
  Photometric galaxy surveys constitute a powerful cosmological probe but rely
on the accurate characterization of their redshift distributions using only
broadband imaging, and can be very sensitive to incomplete or biased priors
used for redshift calibration. S\'anchez & Bernstein (2019) presented a
hierarchical Bayesian model which estimates those from the robust combination
of prior information, photometry of single galaxies and the information
contained in the galaxy clustering against a well-characterized tracer
population. In this work, we extend the method so that it can be applied to
real data, developing some necessary new extensions to it, especially in the
treatment of galaxy clustering information, and we test it on realistic
simulations. After marginalizing over the mapping between the clustering
estimator and the actual density distribution of the sample galaxies, and using
prior information from a small patch of the survey, we find the incorporation
of clustering information with photo-$z$'s to tighten the redshift posteriors,
and to overcome biases in the prior that mimic those happening in spectroscopic
samples. The method presented here uses all the information at hand to reduce
prior biases and incompleteness. Even in cases where we artificially bias the
spectroscopic sample to induce a shift in mean redshift of $\Delta \bar z
\approx 0.05,$ the final biases in the posterior are $\Delta \bar z
\lesssim0.003.$ This robustness to flaws in the redshift prior or training
samples would constitute a milestone for the control of redshift systematic
uncertainties in future weak lensing analyses.
