Learn R Programming

MIAmaxent (version 0.4.0)

plotFOP: Plot Frequency of Observed Presence (FOP).

Description

plotFOP produces a Frequency of Observed Presence (FOP) plot for a given explanatory variable. An FOP plot shows the rate of occurrence of the response variable across intervals or levels of the explanatory variable. For continuous variables, the exponentially weighted moving average of the FOP values is added to the plot as a line. plotFOP also returns a list containing the optimum EV value, and a data frame containing the plotted data (for customizable plotting).

Usage

plotFOP(data, EV, smoothwindow = 5, EVranging = FALSE, intervals = NULL,
  ...)

Arguments

data
Data frame containing the response variable in the first column and explanatory variables in subsequent columns. The response variable should represent presence or background, coded as: 1/NA. See Details for information regarding presence/absence data. See also readData.
EV
Name or column index of the explanatory variable in data for which to calculate FOP.
smoothwindow
Width of the smoothing window. Represents the number of intervals included in an exponentially weighted moving average. Should be odd, otherwise the window will be uncentered. Irrelevant for categorical EVs.
EVranging
Logical. If TRUE, will range the EV scale to [0,1]. This is equivalent to plotting FOP over the linear transformation produced by deriveVars. Irrelevant for categorical EVs.
intervals
Number of intervals into which the continuous EV is divided. Defaults to the minimum of N/50 and 100. Irrelevant for categorical EVs.
...
Arguments to be passed to plot to control the appearance of the plot. For example:
  • cex for size of points
  • col for color
  • xlim for range of the x-axis

Value

In addition to the graphical output, a list of 2:
  1. EVoptimum. The EV value (or level, for categorical EVs) at which FOP is highest
  2. FOPdata. A data frame containing the plotted data. Columns in this data frame represent the following: EV interval ("int"), number of points in the interval ("n"), mean EV value of the points in the interval ("intEV"), mean RV value of the points in the interval ("intRV"), and exponentially weighted moving average of intRV ("smoothRV"). For categorical variables, only the number of points in the level ("n"), the level name ("level"), and the mean RV value of the level ("levelRV") are used.

Details

If the response variable in data represents presence/absence data, the result is an empirical frequency of presence curve, rather than a observed frequency of presence curve (see Stoea et al. [in press], Sommerfeltia). The returned value of 'EVoptimum' is based on the smoothed FOP values, such that an outlying maximum in FOP may, in some cases, not be considered the optimal value of EV.

References

Stoea, B., Halvorsen, R., Mazzoni, S. & Gusarov, V. (2016) Sampling bias in presence-only data used for species distribution modelling: assessment and effects on models. Sommerfeltia, submitted manuscript.

Examples

Run this code
FOPev11 <- plotFOP(toydata_sp1po, 2, intervals = 5, smoothwindow = 3)
FOPev11 <- plotFOP(toydata_sp1po, 2, intervals = 8)
FOPev12 <- plotFOP(toydata_sp1po, "EV12", intervals = 8, ylim=c(0,1))
FOPev12$EVoptimum
FOPev12$FOPdata

## Not run: ------------------------------------
# # From vignette:
# teraspifFOP <- plotFOP(grasslandPO, "teraspif")
# terslpdgFOP <- plotFOP(grasslandPO, "terslpdg", intervals = 25,  pch=20, cex=1.1, col = "red")
# terslpdgFOP$EVoptimum
# terslpdgFOP$FOPdata
## ---------------------------------------------

Run the code above in your browser using DataLab