lr_to_dataframe: Convert Genetic LR Simulations to Data Frame

View source: R/lr_to_dataframe.R

lr_to_dataframeR Documentation

Convert Genetic LR Simulations to Data Frame

Description

Converts the list output from sim_lr_genetic into a tidy data frame suitable for analysis and visualization. Extracts the total LR values from each simulation.

Usage

lr_to_dataframe(datasim)

Arguments

datasim

A list object returned by sim_lr_genetic, containing Unrelated and Related components with LR objects.

Details

The function extracts LRtotal[["H1:H2"]] from each LR object in the simulation lists. This represents the overall likelihood ratio across all genetic markers.

Value

A data.frame with two columns:

  • Unrelated: Numeric LR values from H2 simulations

  • Related: Numeric LR values from H1 simulations

The number of rows equals the number of simulations.

References

Marsico FL, Vigeland MD, Egeland T, Herrera Pinero F (2021). "Making decisions in missing person identification cases with low statistical power." Forensic Science International: Genetics, 52, 102519. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.fsigen.2021.102519")}

See Also

sim_lr_genetic for generating the input, plot_lr_distribution for visualization, lr_combine for combining with other LR sources.

Examples

library(forrel)

# Create pedigree and simulate
x <- linearPed(2)
x <- setMarkers(x, locusAttributes = NorwegianFrequencies[1:5])
x <- profileSim(x, N = 1, ids = 2)

# Simulate LRs
lr_sims <- sim_lr_genetic(x, missing = 5, numsims = 50, seed = 123)

# Convert to dataframe
lr_df <- lr_to_dataframe(lr_sims)
head(lr_df)

# Now can use with other functions
summary(log10(lr_df$Related))
plot_lr_distribution(lr_df)

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