Methods and systems for providing neuromodulation to a patient are disclosed. The disclosed methods and systems use sensed neural responses to construct and optimize models of the neural elements recruited during the neuromodulation. The models are used to estimate neural recruitment associated with a therapeutic effect and/or with side-effects to stimulation. The models can be used to adjust neuromodulation in a closed-loop fashion.