The magnetic properties (magnetic ordering temperature, magnetization) of the ferrimagnetic compounds R2Fe17 and RFe11Ti, as well as of their hydrides and nitrides, were studied. The hydrogenation-and nitrogenation-induced variation of the exchange fields acting on the rare-earth (RE) ions from both the Fe sublattice and other RE ions was determined, and the dependence of the Curie temperatures of the starting compounds, their hydrides, and nitrides on the de Gennes factor was revealed. It was found that incorporation of light atoms (H, N) into the crystal lattices of RFe11Ti and R2Fe17 increases the Curie temperature TC substantially, increases the Fe-Fe exchange coupling, and decreases the R-R exchange interactions, as well as increases the R-Fe intersublattice exchange under hydrogenation and decreases it under nitrogenation, an effect that can be understood as resulting from the attendant changes in the electronic structure of these compounds and in the indirect exchange interactions.