First principles calculation of the electronic and magnetic properties of some rare earth nitrides and transition metal nitrides