This attached procedure estimates the quantile factor model of Liang Chen, Juan J. Dolado, Jesús Gonzalo (2021), "Quantile Factor Models," Econometrica, p.875-910 (
https://doi.org/10.3982/ECTA15746). The computations follow the Matlab function IQR.m of Chen, et al. I have verified that a few tests of results match up for this procedure compared to Matlab. But coding and computational efficiency could probably be improved.