Learn R Programming

TestDimorph (version 0.3.0)

AccuModel: Evaluation Of Sex-prediction Accuracy

Description

Testing and visualization of the accuracy of different sex prediction models using the confusionMatrix and roc curves

Usage

AccuModel(
  f,
  x,
  y,
  Sex = 1,
  Pop = 2,
  byPop = TRUE,
  method = "lda",
  plot = FALSE,
  cutoff = 0.5,
  ref. = "F",
  post. = "M",
  ...
)

Arguments

f

Formula in the form groups ~ x1 + x2 + .... The grouping factor is placed to the left hand side while the numerical measurements are placed to the right hand side

x

Data frame to be fitted to the model

y

New data frame to be tested

Sex

Number of the column containing sex 'M' for male and 'F' for female, Default: 1

Pop

Number of the column containing populations' names, Default: 2

byPop

Logical; if TRUE returns the accuracy in different populations of the new data frame, Default: TRUE.

method

Different methods of modeling see details , Default:'lda'

plot

Logical; if TRUE returns an roc curve for model accuracy, Default: FALSE

cutoff

cutoff value when using logistic regression, Default: 0.5

ref.

reference category in the grouping factor, Default: 'F'

post.

positive category in the grouping factor, Default: 'M'

...

additional arguments that can passed to modeling, confusionMatrix function and roc curve generated by geom_roc

Value

Visual and numerical accuracy parameters for the tested model

Details

Tibble/data frames to be entered as input need to be arranged in a similar manner to Howells dataset. Methods used for modeling are:

lda

linear discriminant analysis

qda

quadratic discriminant analysis

mda

mixture discriminant analysis

fda

flexible discriminant analysis

rda

regularized discriminant analysis

glm

binomial logistic regression

raf

random forest

See Also

lda,qda mda,fda rda randomForest GeomRoc confusionMatrix

Examples

Run this code
# NOT RUN {
#Splitting Howells dataset into training and test datasets
smp_size <- floor(0.5 * nrow(Howells))
set.seed(123)
train_ind <- sample(seq_len(nrow(Howells)), size = smp_size)
train <- Howells[train_ind, ]
test <- Howells[-train_ind, ]
library(TestDimorph)
AccuModel(
Sex ~ GOL + NOL + BNL,
x = train,
y = test,
byPop = FALSE,
method = "lda",
plot = FALSE
)
# }

Run the code above in your browser using DataLab