Hyperpolarizabilities of molecules with frequency dependence and electron correlation