getConfusionMat: Extract confusion matrix for binary spatial model...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/getConfusionMat.R

Description

This function extracts the binary confusion matrix from 'influenceSSN' objects. The matrix values are based on a leave-one-out cross-validation of the observed dataset.

Usage

1
getConfusionMat(x, threshold = 0.5)

Arguments

x

an object of class influenceSSN-class

threshold

a numeric value used to classify binary spatial model predictions into 1's and 0's. The default is 0.5.

Value

getConfusionMat returns a 2x2 matrix containing information about the classification accuracy of the binary spatial model, based on the observations and the leave-one-out cross-validation predictions.

Author(s)

Erin E. Peterson support@SpatialStreamNetworks.com

See Also

predict, influenceSSN-class

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
library(SSN)
#for examples, copy MiddleFork04.ssn directory to R's temporary directory
copyLSN2temp()
# NOT RUN
# Create a SpatialStreamNetork object that also contains prediction sites
#mf04 <- importSSN(paste0(tempdir(),'/MiddleFork04.ssn', o.write = TRUE))
#use mf04 SpatialStreamNetwork object, already created
data(mf04)
#for examples only, make sure mf04p has the correct path
#if you use importSSN(), path will be correct
mf04 <- updatePath(mf04, paste0(tempdir(),'/MiddleFork04.ssn'))

# get some model fits stored as data objects
data(modelFits)

## NOT RUN
## Fit a model to binary data
## binSp <- glmssn(MaxOver20 ~ ELEV_DEM + SLOPE, mf04p,
##   CorModels = c("Mariah.tailup", "Spherical.taildown"),
##   family = "binomial", addfunccol = "afvArea")

#for examples only, make sure binSp has the correct path
#if you use importSSN(), path will be correct
binSp$ssn.object <- updatePath(binSp$ssn.object, 
	paste0(tempdir(),'/MiddleFork04.ssn'))
summary(binSp)

## Generate the leave-one-out cross-validation prediction residuals
## for the observed sites.
binResids <- residuals(binSp, cross.validation = TRUE)

## Generate the confusion matrix for the binary spatial
## model, based on the observations and leave-one-out
## cross-validation predictions
getConfusionMat(binResids, threshold = 0.5)

SSN documentation built on March 13, 2020, 1:49 a.m.