Spectral Methods for Nonparametric Models