% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/compare_sources.R
\name{compare_sources}
\alias{compare_sources}
\title{Compare dietary proportions between multiple sources}
\usage{
compare_sources(
  simmr_out,
  source_names = simmr_out$input$source_names,
  group = 1,
  plot = TRUE
)
}
\arguments{
\item{simmr_out}{An object of class \code{simmr_output} created from
\code{\link{simmr_mcmc}} or \code{\link{simmr_ffvb}}.}

\item{source_names}{The names of at least two sources. These should match
the names exactly given to \code{\link{simmr_load}}.}

\item{group}{The integer values of the group numbers to be compared. If not
specified assumes the first or only group}

\item{plot}{A logical value specifying whether plots should be produced or
not.}
}
\value{
If there are two sources, a vector containing the differences
between the two dietary proportion proportions for these two sources. If
there are multiple sources, a list containing the following fields:
\item{Ordering }{The different possible orderings of the dietary proportions
across sources} \item{out_all }{The dietary proportions for these sources
specified as columns in a matrix}
}
\description{
This function takes in an object of class \code{simmr_output} and creates
probabilistic comparisons between the supplied sources. The group number can
also be specified.
}
\details{
When two sources are specified, the function produces a direct calculation
of the probability that the dietary proportion for one source is bigger than
the other. When more than two sources are given, the function produces a set
of most likely probabilistic orderings for each combination of sources. The
function produces boxplots by default and also allows for the storage of the
output for further analysis if required.
}
\examples{
\donttest{
data(geese_data_day1)
simmr_1 <- with(
  geese_data_day1,
  simmr_load(
    mixtures = mixtures,
    source_names = source_names,
    source_means = source_means,
    source_sds = source_sds,
    correction_means = correction_means,
    correction_sds = correction_sds,
    concentration_means = concentration_means
  )
)

# Plot
plot(simmr_1)

# Print
simmr_1

# MCMC run
simmr_1_out <- simmr_mcmc(simmr_1)

# Print it
print(simmr_1_out)

# Summary
summary(simmr_1_out)
summary(simmr_1_out, type = "diagnostics")
summary(simmr_1_out, type = "correlations")
summary(simmr_1_out, type = "statistics")
ans <- summary(simmr_1_out, type = c("quantiles", "statistics"))

# Plot
plot(simmr_1_out, type = "boxplot")
plot(simmr_1_out, type = "histogram")
plot(simmr_1_out, type = "density")
plot(simmr_1_out, type = "matrix")

# Compare two sources
compare_sources(simmr_1_out, source_names = c("Zostera", "Grass"))

# Compare multiple sources
compare_sources(simmr_1_out)
}

}
\seealso{
See \code{\link{simmr_mcmc}} for complete examples.
}
\author{
Andrew Parnell <andrew.parnell@mu.ie>
}
