View source: R/compare_groups.R
compare_groups | R Documentation |
This function takes in an object of class simmr_output
and creates
probabilistic comparisons for a given source and a set of at least two
groups.
compare_groups(
simmr_out,
source_name = simmr_out$input$source_names[1],
groups = 1:2,
plot = TRUE
)
simmr_out |
An object of class |
source_name |
The name of a source. This should match the names exactly
given to |
groups |
The integer values of the group numbers to be compared. At least two groups must be specified. |
plot |
A logical value specifying whether plots should be produced or not. |
When two groups are specified, the function produces a direct calculation of the probability that one group is bigger than the other. When more than two groups are given, the function produces a set of most likely probabilistic orderings for each combination of groups. The function produces boxplots by default and also allows for the storage of the output for further analysis if required.
If there are two groups, a vector containing the differences between the two groups proportions for that source. If there are multiple groups, a list containing the following fields:
Ordering |
The different possible orderings of the dietary proportions across groups |
out_all |
The dietary proportions for this source across the groups specified as columns in a matrix |
Andrew Parnell <andrew.parnell@mu.ie>
See simmr_mcmc
for complete examples.
## Not run:
data(geese_data)
simmr_in <- with(
geese_data,
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,
group = groups
)
)
# Print
simmr_in
# Plot
plot(simmr_in,
group = 1:8, xlab = expression(paste(delta^13, "C (per mille)", sep = "")),
ylab = expression(paste(delta^15, "N (per mille)", sep = "")),
title = "Isospace plot of Inger et al Geese data"
)
# Run MCMC for each group
simmr_out <- simmr_ffvb(simmr_in)
# Print output
simmr_out
# Summarise output
summary(simmr_out, type = "quantiles", group = 1)
summary(simmr_out, type = "quantiles", group = c(1, 3))
summary(simmr_out, type = c("quantiles", "statistics"), group = c(1, 3))
# Plot - only a single group allowed
plot(simmr_out, type = "boxplot", group = 2, title = "simmr output group 2")
plot(simmr_out, type = c("density", "matrix"), grp = 6, title = "simmr output group 6")
# Compare groups
compare_groups(simmr_out, source = "Zostera", groups = 1:2)
compare_groups(simmr_out, source = "Zostera", groups = 1:3)
compare_groups(simmr_out, source = "U.lactuca", groups = c(4:5, 7, 2))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.