View source: R/niche.par.plot.R
niche.par.plot | R Documentation |
For one or more species, plots some or all of the niche parameters \mu
and \Sigma
.
niche.par.plot(
niche.par,
plot.mu = TRUE,
plot.Sigma = TRUE,
plot.index,
col,
ndens = 512,
ylab
)
niche.par |
List with |
plot.mu |
Logical. If |
plot.Sigma |
Logical. If |
plot.index |
Either a scalar of a numeric vector of length 2. If |
col |
Vector of colors in which to plot each species. |
ndens |
Number of points at which to evaluate density estimates. |
ylab |
Optional label for |
Each element of the list niche.par
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)
.
Returns a plot of the distribution of some or all niche parameters.
niw.post()
, niiw.post()
for niche parameter output, stats::density()
for density estimation from sample data.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.