View source: R/predict.gendis.r
predict.gendis | R Documentation |
predict.gendis
applies a generalized discriminant function created with gendis
to predict the sex (class) of each individual with measurements in newdata
. From the gendis
object, the coefficients that define the generalized discriminant function (GDF) are applied to the
newdata
to obtain the discriminant scores.
## S3 method for class 'gendis'
predict(object, newdata, type = object$sex, verbose = FALSE, ...)
object |
an object of class gendis, typically created with |
newdata |
a data frame with measurements on (new) individuals with variables used to create |
type |
what to predict: the sex or class of each individual (default),
the generalized discriminant scores with cutpoint ("GDF" or "GDFscore") or
the full output of the unmixing algorithm |
verbose |
logical (default = FALSE). If TRUE a plot of the density of the GDF is produced. |
... |
other optional arguments |
The discriminant score are a linear combination of the variables in newdata
that are shared with the variables used to create the object
. The linear combination is defined by
the GDF coefficients. The discriminant scores are subjected to an unmixing algorithm. This algorithm (unmix
) generates a cutpoint
below which individuals are predicted to be female (level 1 of factor(sex)
) and above which they are predicted to be
male (level 2 of factor(sex)
). The cutpoint is at the point of intersection of two normal densities with unequal
means and variances fitted to the discriminant scores (see unmix for details
).
See argument type
.
van Franeker, J A. ter Braak, C J F. 1993. A generalized discriminant for sexing fulmarine petrels from external measurements. The Auk 110: pp 492-502, https://doi.org/10.2307/4088413 https://edepot.wur.nl/249350
data("fulmarin")
str(fulmarin)
result <- gendis(population = "population", sex = "sex",
measurements = "other_variables", verbose = FALSE , data=fulmarin )
data("JanMayenBirds")
sex.predict <- predict(result, newdata = JanMayenBirds, verbose = TRUE)
# one false prediction: (number 32)
data.frame(sex = JanMayenBirds$DISSEX, sex.predict)[seq(from=2, to = 37, by =5),]
predict(result, JanMayenBirds )
# same as default above
predict(result, JanMayenBirds, type = result$sex, verbose = FALSE)
# GDF score with cutpoint
predict(result, JanMayenBirds, type = "GDF", verbose = FALSE)
# unmix results only
predict(result, JanMayenBirds, type = "cutpoint", verbose = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.