ellipsoidfit: Function fit an ellipsoid model

View source: R/ellipsoidfit.R

ellipsoidfitR Documentation

Function fit an ellipsoid model

Description

Function fit an ellipsoid model using the shape matrix (covariance matrix) of the niche variables.

Usage

ellipsoidfit(
  envlayers,
  centroid,
  covar,
  level = 0.95,
  plot = T,
  size,
  xlab1 = "niche var 1",
  ylab1 = "niche var 2",
  zlab1 = "S",
  ...
)

Arguments

envlayers

A RasterStack or RasterBrick object of the niche variables.

centroid

A vector with the values of the centers of the ellipsoid (see cov_center).

covar

The shape matrix (covariance) of the ellipoid (see cov_center).

level

The proportion of points to be included inside the ellipsoid

plot

Logical If True a plot of the niche will be shown.

size

The size of the points of the niche plot.

xlab1

For x label for 2-dimensional histogram

ylab1

For y label for 2-dimensional histogram

zlab1

For z label for 2-dimensional histogram

...

Arguments passed to plot3d function from rgl

Value

Returns a list containing a data.frame with the suitability values; a suitability raster; a data.frame with the mahalanobis and euclidean distances to the centroid.

Examples

## Load niche data
## Not run: 
d_cardon <-  read.csv(system.file("extdata", "cardon_virtual.csv", package = "ntbox"))
## Compute the centroid and shape (covariance matrix) of the ellipsoid model.
covar_centroid <- cov_center(d_cardon,mve=TRUE,level=0.99,vars=c(3,4,5))
## RasterStack with the niche variables
nicheStack <- raster::stack(list.files(system.file("extdata",
                                       package = "ntbox"),
                                       pattern = ".asc$",
                                       full.names = TRUE))
# Fitting the ellipsoid model
 ellipsoidMod <- ellipsoidfit(nicheStack,
                          covar_centroid$centroid,
                          covar_centroid$covariance,
                          level=0.99,plot=TRUE,size=3)
 plot(ellipsoidMod$suitRaster)

## End(Not run)

luismurao/ntbox documentation built on April 3, 2024, 5:47 a.m.