Learn R Programming

PresenceAbsence (version 1.1.9)

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)

Arguments

DATA

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

DATA[,1] plot ID text
DATA[,2] observed values zero-one values
DATA[,3] predicted probabilities from first model numeric (between 0 and 1)
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

Value

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

[,1] model model name (column name from DATA)
[,2] threshold thresholds used for each row in the table
[,3] PCC percent correctly classified
[,4] sensitivity
[,5] specificity
[,6] Kappa

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

[,1] model model name (column name from DATA)
[,2] threshold thresholds used for each row in the table
[,3] PCC percent correctly classified
[,4] sensitivity
[,5] specificity
[,6] Kappa
[,7] AUC area under the curve
[,8] PCC.sd standard deviation of PCC
[,9] sensitivity.sd standard deviation of sensitivity
[,10] specificity.sd standard deviation of specificity
[,11] Kappa.sd standard deviation of Kappa

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

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
# NOT RUN {
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