Learn R Programming

PresenceAbsence (version 1.1.11)

presence.absence.accuracy: Accuracy Table for Presence/Absence Data

Description

Calculates five accuracy measures (pcc, sensitivity, specificity, Kappa, and AUC) for Presence/Absence data, and (optionally) their associated standard deviations.

Usage

presence.absence.accuracy(DATA, threshold = 0.5, find.auc = TRUE, st.dev = TRUE, 
which.model = (1:(ncol(DATA) - 2)), na.rm = FALSE)

Value

if st.dev = FALSE, returns a dataframe where:

[,1]modelmodel name (column name from DATA)
[,2]thresholdthresholds used for each row in the table
[,3]PCCpercent correctly classified
[,4]sensitivity
[,5]specificity
[,6]Kappa
[,7]AUCarea under the curve

if st.dev = TRUE, returns a dataframe where:

[,1]modelmodel name (column name from DATA)
[,2]thresholdthresholds used for each row in the table
[,3]PCCpercent correctly classified
[,4]sensitivity
[,5]specificity
[,6]Kappa
[,7]AUCarea under the curve
[,8]PCC.sdstandard deviation of PCC
[,9]sensitivity.sdstandard deviation of sensitivity
[,10]specificity.sdstandard deviation of specificity
[,11]Kappa.sdstandard deviation of Kappa
[,12]AUC.sdstandard deviation of AUC

if find.auc = FALSE, then columns for AUC and AUC.sd are not returned.

Arguments

DATA

a matrix or dataframe of observed and predicted values where each row represents one plot and where columns are:

DATA[,1]plot IDtext
DATA[,2]observed valueszero-one values
DATA[,3]predicted probabilities from first modelnumeric (between 0 and 1)
DATA[,4]predicted probabilities from second model, etc...

threshold

a cutoff values between zero and one used for translating predicted probabilities into 0 /1 values, defaults to 0.5. If calculations are to be performed on a single model prediction threshold can be a single value between zero and one, a vector of values between zero and one, or a positive integer representing the number of evenly spaced thresholds to calculate. If calculations are to be performed on multiple model predictions, then threshold must be either a single value between zero and one, or a vector of the same length as the number of models.

find.auc

a logical indicating if area under the curve should be calculated

st.dev

a logical indicating if standard deviations should be calculated

which.model

a number indicating which models from DATA should be used

na.rm

a logical indicating whether missing values should be removed

Author

Elizabeth Freeman eafreeman@fs.fed.us

Details

presence.absence.accuracy calculates five standard accuracy measures for presence absence data, and (optionally) their associated standard deviations.

Function will work for one model and multiple thresholds, or one threshold and multiple models, or multiple models each with their own threshold.

Depending on the size of the dataset and the speed of the computer this function may take a couple of minutes to run. Finding the AUC is the slowest part of this function. The AUC can be suppressed by setting find.auc = FALSE.

which.model can be used to specify which of the prediction models from DATA should be used.

See Also

cmx, pcc, sensitivity, specificity, Kappa, auc

Examples

Run this code

data(SIM3DATA)

### EXAMPLE 1 - multiple model predictions at one threshold###

presence.absence.accuracy(SIM3DATA)
presence.absence.accuracy(SIM3DATA,threshold=.4,st.dev=FALSE)
presence.absence.accuracy(SIM3DATA, which.model=c(1,3),st.dev=FALSE)

### EXAMPLE 2 - one model prediction at multiple thresholds ###

presence.absence.accuracy(SIM3DATA, threshold=c(.25,.5,.75), which.model=3)
presence.absence.accuracy(SIM3DATA, threshold=11, which.model=2)

### EXAMPLE 3 - multiple model predictions, each at it's own treshold ###

presence.absence.accuracy(SIM3DATA, threshold=c(.5,.5,.2), which.model=c(1,2,2))


Run the code above in your browser using DataLab