internalNBC: NBC algorithm source code

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/nbc4va_internal.R

Description

Performs Naive Bayes Classification given train and test (validation) datasets, as well as additional information for the train and test data.

Usage

1
internalNBC(train, test, known = TRUE)

Arguments

train

Dataframe of verbal autopsy train data (See Data documentation).

  • Columns (in order): ID, Cause, Symptom-1 to Symptom-n..

  • ID (vectorof char): unique case identifiers

  • Cause (vectorof char): observed causes for each case

  • Symptom-n.. (vectorsof (1 OR 0)): 1 for presence, 0 for absence, other values are treated as unknown

  • Unknown symptoms are imputed randomly from distributions of 1s and 0s per symptom column; if no 1s or 0s exist then the column is removed

Example:

ID Cause S1 S2 S3
"a1" "HIV" 1 0 0
"b2" "Stroke" 0 0 1
"c3" "HIV" 1 1 0
test

Dataframe of verbal autopsy test data in the same format as train except if causes are not known:

  • The 2nd column (Cause) can be omitted if known is FALSE

known

TRUE to indicate that the test causes are available in the 2nd column and FALSE to indicate that they are not known

Details

This function was built on code provided by Miasnikof et al (2015). Edits to the code included the following improvements:

Value

out The result list object containing:

Author(s)

Pierre Miasnikof (Original), Vasily Giannakeas (Original), Richard Wen (Edits) <wenr@smh.ca>

References

See Also

Other internal functions: internalGetCSMFAcc, internalGetCSMFMaxError, internalGetCauseMetrics, internalGetMetrics

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
library(nbc4va)
data(nbc4vaData)

# Create naive bayes classifier on random train and test data
# Set "known" to indicate whether or not "test" causes are known
train <- nbc4vaData[1:50, ]
test <- nbc4vaData[51:100, ]
results <- nbc4va:::internalNBC(train, test, known=TRUE)

# Obtain the probabilities and predictions
prob <- results$prob.causes
pred <- results$pred.causes

nbc4va documentation built on May 2, 2019, 1:42 p.m.