maxLikOverlap: Calculate the overlap between two ellipses based on the...

View source: R/maxLikOverlap.R

maxLikOverlapR Documentation

Calculate the overlap between two ellipses based on the maximum likelihood fitted ellipses.

Description

This function uses the ML estimated means and covariances matrices of two specified groups to calculate the area of overlap.

Usage

maxLikOverlap(
  ellipse1,
  ellipse2,
  siber.object,
  p.interval = 0.95,
  n = 100,
  do.plot = FALSE
)

Arguments

ellipse1

character code of the form "x.y" where x is an integer indexing the community, and y an integer indexing the group within that community. This specifies the first of two ellipses whose overlap will be compared.

ellipse2

same as ellipse1 specifying a second ellipse.

siber.object

an object created by createSiberObject() which contains the ML estimates for the means and covariance matrices for each group.

p.interval

the prediction interval used to scale the ellipse as per addEllipse().

n

the number of points on the edge of the ellipse used to define it. Defaults to 100 as per addEllipse().

do.plot

logical switch to determine whether the corresponding ellipses should be plotted or not. A use-case would be in conjunction with a low numbered draws so as to visualise a relatively small number of the posterior ellipses. Defaults to FALSE.

Value

A vector comprising three columns: the area of overlap, the area of the first ellipse and the area of the second ellipse and as many rows as specified by draws.

Examples

# load in the included demonstration dataset data("demo.siber.data")
siber.example <- createSiberObject(demo.siber.data) 

# The first ellipse is referenced using a character string representation 
# where in "x.y", "x" is the community, and "y" is the group within that 
# community.
ellipse1 <- "1.2" 

# Ellipse two is similarly defined: community 1, group3 
ellipse2 <- "1.3"

# the overlap betweeen the corresponding 95% prediction ellipses is given by: 
ellipse95.overlap <- maxLikOverlap(ellipse1, ellipse2, siber.example,
p.interval = 0.95, n = 100)


SIBER documentation built on Oct. 19, 2023, 5:09 p.m.