Electronic structure of divalent-, trivalent- and mixed valence rare earth compounds