Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

niche.par.plot

Plot for niche parameters


Description

For one or more species, plots some or all of the niche parameters μ and Σ.

Usage

niche.par.plot(niche.par, plot.mu = TRUE, plot.Sigma = TRUE, plot.index,
  col, ndens = 512, ylab)

Arguments

niche.par

list with nspecies = length(niche.par), each element of which is a list with parameters mu and Sigma. See Details.

plot.mu

logical. If TRUE, plot the distribution of μ for each niche indicator (e.g., stable isotope). See Details.

plot.Sigma

logical. If TRUE, plot the distribution of Σ for each niche indicator. See Details.

plot.index

either a scalar of a numeric vector of length 2. If plot.index = i then plot the distribution of μ_i. If plot.index = c(i,j) then plot the distribution of Σ_{ij}.

col

vector of colors in which to plot each species.

ndens

number of points at which to evaluate density estimates.

ylab

optional label for y-axis. If missing, defaults to p(μ_i | X) and p(Σ_{ij} | X).

Details

niche.par is a list, each element of which is a distribution of niche parameters. That is, names(niche.par[[1]]) = c("mu", "Sigma"), and if niso is the number of niche indicators (e.g., stable isotopes), then dim(niche.par[[1]]$mu) = c(nsamples, niso) and dim(niche.par[[1]]$Sigma) = c(niso, niso, nsamples).

Value

Returns a plot of the distribution of some or all niche parameters.

See Also

niw.post, niiw.post for niche parameter output, density in the R base package for density estimation from sample data.

Examples

# fish data
data(fish)

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

# various parameter plots
clrs <- c("black", "red", "blue", "orange") # colors for each species

# mu1, mu2, and Sigma12
par(mar = c(4, 4, .5, .1)+.1, mfrow = c(1,3))
niche.par.plot(fish.par, col = clrs, plot.index = 1)
niche.par.plot(fish.par, col = clrs, plot.index = 2)
niche.par.plot(fish.par, col = clrs, plot.index = 1:2)
legend("topright", legend = names(fish.par), fill = clrs)

# all mu
niche.par.plot(fish.par, col = clrs, plot.mu = TRUE, plot.Sigma = FALSE)
legend("topright", legend = names(fish.par), fill = clrs)

# all mu and Sigma
par(mar = c(4.2, 4.2, 2, 1)+.1)
niche.par.plot(fish.par, col = clrs, plot.mu = TRUE, plot.Sigma = TRUE)
legend("topright", legend = names(fish.par), fill = clrs)

nicheROVER

(Niche) (R)egion and Niche (Over)lap Metrics for Multidimensional Ecological Niches

v1.0
GPL-2
Authors
Martin Lysy [aut, cre], Ashley D. Stasko [aut, ctb], Heidi K. Swanson [aut, ctb]
Initial release
2014-07-21

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.