overlap.plot: Plot the overlap metric.

View source: R/overlap.plot.R

overlap.plotR Documentation

Plot the overlap metric.

Description

Plots the posterior distribution of the niche region overlap metric calculated for each pairwise combination of species.

Usage

overlap.plot(
  over.stat,
  nbreaks = 50,
  equal.axis = FALSE,
  species.names,
  col,
  mean.cred = TRUE,
  mean.cred.col = "green",
  xlab
)

Arguments

over.stat

An array with dim(over.stat) = c(nspecies, nspecies, nreps) containing nreps calculations of the overlap metric for each pair of species. See 'Details'.

nbreaks

Number of breaks in the histogram. Defaults to 50.

equal.axis

Logical. If TRUE, all histograms in a given column of the output (corresponding to different Species A for the same Species B) are plotted on the same range.

species.names

A vector of species names. Defaults to dimnames(over.stat)[[1]].

col

A vector of the colours in which each species will be drawn.

mean.cred

Logical. If TRUE, vertical lines for mean and 95% credible intervals will be included in the historgram of each overlap metric.

mean.cred.col

Colour of the mean and credible interval lines in the histogram.

xlab

Optional plot title, located on the bottom. Default is no title.

Details

This function uses the overlap metric information in over.stat calculated by overlap() to create 2-dimensional plots of interspecific niche region overlap.

Value

Returns a series of histograms illustrating the probability of pairwise species overlap.

See Also

overlap(), niw.post(), niiw.post().

Examples

# fish data
data(fish)

# parameter draws from the "default" posteriors of each fish
nsamples <- 500
system.time({
  fish.par <- tapply(1:nrow(fish), fish$species,
                     function(ii) niw.post(nsamples = nsamples,
                                           X = fish[ii,2:4]))
})

# overlap calculation
system.time({
  over <- overlap(fish.par, nreps = nsamples, nprob = nsamples,
                  alpha = c(.95, .99))
})

# overlap plot
clrs <- c("black", "red", "blue", "orange") # color for each species
ii <- 1 # which niche region alpha level to use
overlap.plot(over[,,,ii], col = clrs, mean.cred.col = "turquoise",
             xlab = paste0("Overlap Probability (%) -- Niche Region Size: ",
                           dimnames(over)[[4]][ii]))

mlysy/nicheROVER documentation built on Oct. 17, 2023, 2:21 p.m.