ova2nbc: Translate open verbal autopsy arguments to train a NBC model

View source: R/nbc4va_extra.R

ova2nbcR Documentation

Translate open verbal autopsy arguments to train a NBC model

Description

A wrapper function for creating an nbc object with the parameters specified by the openVA package.

Usage

ova2nbc(symps.train, symps.test, causes.train, causes.table = NULL, ...)

Arguments

symps.train

Dataframe of verbal autopsy train data.

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

  • ID (vectorof char): case identifiers

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

  • Symptom-n.. (vectorsof char): "Y" for presence, "" for absence, "." for missing

Example:

ID Cause S1 S2 S3
"a1" "HIV" "Y" "" "."
"b2" "Stroke" "." "" "Y"
"c3" "HIV" "Y" "Y" "."
symps.test

Dataframe of verbal autopsy test data in the same format as symps.train.

  • If (causes.train is (vectorof char)): symps.test is assumed to not have a cause column

causes.train

The train vector or column for the causes of death to use.

  • If (vectorof char): cause of death values with number of values equal to nrow(symps.train); it is assumed that symps.test has no causes of death column

  • If (char): name of cause of death column from symps.train

causes.table

Character list of unique causes to learn.

  • If (NULL): set to unique causes of death in symps.train

...

Additional arguments to be passed to avoid errors if necessary.

Value

nbc An nbc object with the following modifications:

  • $id (vectorof char): set to test data ids

  • $prob (matrixof numeric): set to a matrix of likelihood for each cause of death for the test cases

  • $CSMF (vectorof char): set to the predicted CSMFs with names for the corresponding causes

References

Examples

## Not run: 
library(openVA)  # install.packages("openVA")
library(nbc4va)

# Obtain some openVA formatted data
data(RandomVA3) # cols: deathId, cause, symptoms..
train <- RandomVA3[1:100, ]
test <- RandomVA3[101:200, ]

# Run naive bayes classifier on openVA data
results <- ova2nbc(train, test, "cause")

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

## End(Not run)


nbc4va documentation built on May 10, 2022, 5:07 p.m.