R2MCDS allows to run some basic distance analysis on the dataset via the MCDS engine of Distance 7.2. The analyzes are currently restricted to line transect, to point transect, and to binned data. Models based on line and point transect data are run via the mcds.wrap() function by setting Type and Distance arguments. Strips transect models are analyzed with the function strip.wrap(). The distance models support 3 different key functions (Uniform, Half-normal and Hazard rate) and 3 different adjustment terms (Cosine, Simple polynomial, Hermite polynomial).

Basic model with mcds.wrap()

If the user does not input any models via the estimator argument the function mcds.wrap() will fit by default the 6 possible detection functions available in Distance 7.2:

library(R2MCDS)
### Import and filter data
data(alcidae)
alcids <- mcds.filter(alcidae,
                      transect.id = "WatchID",
                      distance.field = "Distance",
                      distance.labels = c("A", "B", "C", "D"),
                      distance.midpoints = c(25, 75, 150, 250),
                      effort.field = "WatchLenKm",
                      lat.field = "LatStart",
                      long.field = "LongStart",
                      sp.field = "Alpha",
                      date.field = "Date")

### Run analysis with the MCDS engine based on line transect data. Here, the WatchID is used as the sample.
x <- mcds.wrap(alcids,
               SMP_EFFORT="WatchLenKm",
               DISTANCE="Distance",
               SIZE="Count",
               Type="Line",
               units=list(Distance="Perp",
                          Length_units="Kilometers",
                          Distance_units="Meters",
                          Area_units="Square kilometers"),
               breaks=c(0,50,100,200,300),
               STR_LABEL="STR_LABEL", 
               STR_AREA="STR_AREA",
               SMP_LABEL="WatchID", 
               path="C:/temp/distance",
               pathMCDS="C:/Program Files (x86)/Distance 7",
               verbose=FALSE)

The mcds.wrap() function will return a warning after fitting each model (not shown in the example above). These warning will include a "status" number that is associated with the status of the model by the MCDS engine. The numbers should be intrepreted as:

The function mcds.wrap() will not return an output for any model which had a status above 2. A detailed description of each error message can be found in the Distance user guide (pages 365-375).

Since we ran more than one model for a set of observations the model are stored into a distanceList object which consist of a list of distanceFit objects. The output of each detection model can therefore be accessed by subsetting the list.

x
####summary of one model
summary(x[[2]])
plot.distanceFit(x[[2]])

The summary of a distanceFit object emulate the output of Distance 7.2 and present 3 tables. The first table contains all the information related to the encounter rate, the second table presents the parameters related to the detection probability, and the third table present the information related to the density/abundance in the survey area. A detailed description of the output can be found in the Distance user guide (Chapter 9 and page 360).

If the user is interested in keeping only the best model in the distanceList, the function keep.best.model() will keep only the model with the lowest AICc value. If more than one model have the best AIC score the keep.best.model() function will select one model randomly.

##### Keep the 'best' model in the list
x.best <- keep.best.model(x)
summary(x.best)
plot.distanceFit(x.best)

Selecting the key function and adjustement with mcds.wrap()

It is possible for the user to select the key function and adjustment. For example, instead of running the 6 models by default the user may want to restrict his analysis to the half-normal key function with a cosine adjustment and the hazard rate key function with a polynomial adjustment. He can do so via the estimator argument. The estimator argument consists of a list of elements where each element is a vector containing the first two letters of the key function and the first two letters of the adjustment term. It is important to remember, however, that the list of detection key is restricted to the 6 key that have been presented above.

library(R2MCDS)
### Import and filter data
data(alcidae)
alcids <- mcds.filter(alcidae,
                      transect.id = "WatchID",
                      distance.field = "Distance", 
                      distance.labels = c("A", "B", "C", "D"), 
                      distance.midpoints = c(25, 75, 150, 250),
                      effort.field = "WatchLenKm", 
                      lat.field = "LatStart",
                      long.field = "LongStart", 
                      sp.field = "Alpha",
                      date.field = "Date")

### Run analysis with the MCDS engine based on line transect data. Here, the WatchID is used as the sample.
x <- mcds.wrap(alcids,
               SMP_EFFORT="WatchLenKm",
               DISTANCE="Distance",
               SIZE="Count",
               Type="Line",
               units=list(Distance="Perp",
                          Length_units="Kilometers",
                          Distance_units="Meters",
                          Area_units="Square kilometers"),
               breaks=c(0,50,100,200,300),
               SMP_LABEL="WatchID",
               STR_LABEL="STR_LABEL",
               STR_AREA="STR_AREA",
               estimator=list(c("HN","CO"),c("HA","PO")),
               path="C:/temp/distance",
               pathMCDS="C:/Program Files (x86)/Distance 7",
               verbose=FALSE)
x
summary(x[[2]])

Once again, it is possible to select the model with the lowest AIC value via the keep.best.model() function.

##### Keep the 'best' model in the list
x.best <- keep.best.model(x)
summary(x.best)
plot.distanceFit(x.best)


RoyChristian/GeoAviR documentation built on Jan. 13, 2020, 8:16 p.m.