Substrate effect on the optical response of silver nanoparticles