Generalized Kramers–Kronig relations in nonlinear optical- and THz-spectroscopy