Magnetic anisotropy of rare-earth—transition-metal compounds