Rare-earth (RE) elements present in the growth melt of the LPE process are known to have a purifying effect on the grown layers of III-V compounds. The RE atoms exhibit high chemical affinity preferentially to shallow donors, forming insoluble aggregates that remain in the melt and do not, ordinarily, enter the solid phase. The aim of the paper is to simulate the situation, sometimes observed experimentally, where the gradual gettering of donor impurity, consequent upon increasing the RE content in the melt, leads to an inversion of the electrical conductivity type of the grown layer from n to p. Usefulness of the approach is demonstrated by interpreting results of an experimental work.