overlap: Calculate the percent overlap between two habitual intake...

View source: R/overlap.R

overlapR Documentation

Calculate the percent overlap between two habitual intake distributions

Description

This function calculates the percent overlap between two habitual intake distributions. It handles combinations of gamma and log-normal distributions. The percent overlap is calculated as the Bhattacharyya coefficient.

Usage

overlap(dist1, dist2, plot = F)

Arguments

dist1

List containing the named distribution parameters for distribution A

dist2

List containing the named distribution parameters for distribution B

plot

Boolean (TRUE/FALSE) indicating whether to plot the distributions and overlap

Value

The percent overlap in the two distributions

Examples

overlap(dist1=list(shape=2, rate=2), dist2=list(shape=2, rate=2), plot=T) # same distribution
overlap(dist1=list(shape=2, rate=2), dist2=list(shape=3, rate=2), plot=T) # slighly different
overlap(dist1=list(shape=2, rate=2), dist2=list(meanlog=0.5, sdlog=0.4), plot=T) # slightly different
overlap(dist1=list(meanlog=0.5, sdlog=0.4), dist2=list(shape=2, rate=2), plot=T) # slightly different
overlap(dist1=list(shape=2, rate=2), dist2=list(shape=15, rate=4), plot=T) # more different
overlap(dist1=list(shape=2, rate=2), dist2=list(shape=30, rate=4), plot=T) # very different

cfree14/nutriR documentation built on Oct. 31, 2024, 6:27 p.m.