lr_sex: Likelihood Ratio for Biological Sex

View source: R/lr_sex.R

lr_sexR Documentation

Likelihood Ratio for Biological Sex

Description

Simulates observations of biological sex and optionally computes likelihood ratios (LRs) under either H1 (unidentified person is the missing person) or H2 (unidentified person is not the missing person).

Usage

lr_sex(
  MPs = "F",
  eps = 0.05,
  erRs = eps,
  numsims = 1000,
  Ps = c(0.5, 0.5),
  H = 1,
  LR = FALSE,
  seed = 1234,
  nsims = NULL
)

Arguments

MPs

Character. Missing person's biological sex: "F" for female, "M" for male. Default: "F".

eps

Numeric (0-1). Error rate (epsilon) for sex observation. Probability of misclassifying sex when recording. Default: 0.05.

erRs

Numeric (0-1). Error rate in the database/reference. Defaults to eps if not specified.

numsims

Integer. Number of simulations to perform. Default: 1000.

Ps

Numeric vector of length 2. Sex proportions in the population, c(proportion_female, proportion_male). Must sum to 1. Default: c(0.5, 0.5).

H

Integer (1 or 2). Hypothesis to simulate under:

  • 1: H1 (Related) - Unidentified person IS the missing person

  • 2: H2 (Unrelated) - Unidentified person is NOT the missing person

Default: 1.

LR

Logical. If TRUE, compute and return LR values for each simulated observation. Default: FALSE.

seed

Integer. Random seed for reproducibility. Default: 1234.

nsims

Deprecated. Use numsims instead.

Details

Under H1 (Related): The observed sex matches the MP's true sex with probability (1 - erRs), and is incorrectly recorded with probability erRs.

Under H2 (Unrelated): Sex is sampled from the population proportions Ps.

LR Calculation: For a matching observation: LR = (1 - eps) / Ps_MP For a non-matching observation: LR = eps / Ps_other

Value

A data.frame with column Sexo containing simulated sex observations ("F" or "M"). If LR = TRUE, also includes column LRs with the likelihood ratio for each observation.

Deprecation

Soft-deprecated in mispitools 2.0. This feature is generalised by nongenetic_feature (a categorical feature); the deterministic LR it produces is reproduced exactly by the unified per-feature engine. The legacy function still works for the 2.0 release-candidate cycle and will be removed afterwards.

References

Marsico FL, et al. (2023). "Likelihood ratios for non-genetic evidence in missing person cases." Forensic Science International: Genetics, 66, 102891. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.fsigen.2023.102891")}

See Also

nongenetic_feature for the unified replacement, sim_lr_prelim for unified preliminary LR simulations, lr_age, lr_hair_color for other variables.

Examples

# Simulate under H1 (related)
sim_h1 <- lr_sex(MPs = "F", H = 1, numsims = 100)
table(sim_h1$Sexo)

# Simulate under H2 (unrelated) with LR values
sim_h2 <- lr_sex(MPs = "F", H = 2, numsims = 100, LR = TRUE)
head(sim_h2)

# Different population proportions
sim_custom <- lr_sex(
  MPs = "M",
  Ps = c(0.52, 0.48),  # 52% female population
  numsims = 500,
  LR = TRUE
)
summary(sim_custom$LRs)

mispitools documentation built on Aug. 26, 2026, 1:08 a.m.