unmix: Unmixing a distribution by decomposing it in two normal ones...

View source: R/unmix.r

unmixR Documentation

Unmixing a distribution by decomposing it in two normal ones with unequal means and variances.

Description

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 argument x. This function is used internally in the predict.gendis function.

Usage

unmix(x, verbose = FALSE)

Arguments

x

a numeric vector of discriminant scores with optional attribute "classnames", e.g. c("female","male")

verbose

logical (default = FALSE)

Details

unmix is an EM algorithm following example 4.3.2 of Titterington et al. (1985). Alternatively, library flexmix could have been used.

Value

A list consisting of

  • cutpoint point of equal density of the normal distributions

  • p1 estimated probability of class 0 ("female"), informally: fraction of individuals in class 0

  • p2 estimated probability of class 1 ("female"), informally: fraction of individuals in class 0

  • m1 estimated mean of the normal distribution of class 0

  • m2 estimated mean of the normal distribution of class 1

  • v1 estimated variance of the normal distribution of class 0

  • v2 estimated variance of the normal distribution of class 1

References

Titterington, D.M., Smith, A.F.M. & Makov, U.E. (1985). Statistical analysis of finite mixture distributions, Wiley, 1985. pages 86/87, example 4.3.2

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

Examples

data("fulmarin")
result <- gendis(population = "population", sex = "sex",
                 measurements = c("HB","BD2","TL","CL"), verbose = FALSE ,  data=fulmarin )
data("JanMayenBirds")
#get the measurements in the generalized discriminant function (GFD) from the new data
newdata <- as.matrix(JanMayenBirds[,  c("HB","BD2","TL","CL")])
# combine the measurements using the coefficients of the GDF
GDFscores <- newdata%*% result$GDF[,2]
attr(GDFscores,which = "classnames") <- result$classnames
# note the attribute classnames with the names to be used in the printout
# for first and second level of the factor sex
# Calculate the cutpoint using unmix instead of predict.gendis
unmix(GDFscores,verbose = TRUE)




CajoterBraak/Gendis2unmix documentation built on Aug. 5, 2023, 1:36 p.m.