Skip to contents

Based on a fitted model, plot the density of observations over the estimated variable and environmental space. Opposed to the partial and spartial functions, which are rather low-level interfaces, this function provides more detail in the light of the data. It is also able to contrast different variables against each other and show the used data.


partial_density(mod, x.var, df = FALSE, ...)

# S4 method for ANY,character
partial_density(mod, x.var, df = FALSE, ...)



A trained DistributionModel object. Requires a fitted model and inferred prediction.


A character indicating the variable to be investigated. Can be a vector of length 1 or 2.


logical if plotting data should be returned instead (Default: FALSE).


Other engine specific parameters.


A ggplot2 object showing the marginal response in light of the data.


This functions calculates the observed density of presence and absence points over the whole surface of a specific variable. It can be used to visually inspect the fit of the model to data.


By default all variables that are not x.var are hold constant at the mean.


  • Warren, D.L., Matzke, N.J., Cardillo, M., Baumgartner, J.B., Beaumont, L.J., Turelli, M., Glor, R.E., Huron, N.A., Simões, M., Iglesias, T.L. Piquet, J.C., and Dinnage, R. 2021. ENMTools 1.0: an R package for comparative ecological biogeography. Ecography, 44(4), pp.504-511.

See also


if (FALSE) {
 # Do a partial calculation of a trained model
 partial_density(fit, x.var = "Forest.cover")
 # Or with two variables
 partial_density(fit, x.var = c("Forest.cover", "bio01"))