combine_sources: Combine the dietary proportions from two food sources after...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/combine_sources.R

Description

This function takes in an object of class simmr_output and combines two of the food sources. It works for single and multiple group data.

Usage

1
2
3
4
5
combine_sources(
  simmr_out,
  to_combine = simmr_out$input$source_names[1:2],
  new_source_name = "combined_source"
)

Arguments

simmr_out

An object of class simmr_output created from simmr_mcmc.

to_combine

The names of exactly two sources. These should match the names given to simmr_load.

new_source_name

A name to give to the new combined source.

Details

Often two sources either (1) lie in similar location on the iso-space plot, or (2) are very similar in phylogenetic terms. In case (1) it is common to experience high (negative) posterior correlations between the sources. Combining them can reduce this correlation and improve precision of the estimates. In case (2) we might wish to determine the joint amount eaten of the two sources when combined. This function thus combines two sources after a run of simmr_mcmc (known as a posteriori combination). The new object can then be called with plot.simmr_input or plot.simmr_output to produce iso-space plots of summaries of the output after combination.

Value

A new simmr_output object

Author(s)

Andrew Parnell <andrew.parnell@mu.ie>

See Also

See simmr_mcmc and the associated vignette for examples.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
## Not run: 
# The data
data(geese_data)

# Load into simmr
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)
plot(simmr_1_out, type = "boxplot")
plot(simmr_1_out, type = "histogram")
plot(simmr_1_out, type = "density")
plot(simmr_1_out, type = "matrix")

simmr_out_combine <- combine_sources(simmr_1_out,
  to_combine = c("U.lactuca", "Enteromorpha"),
  new_source_name = "U.lac+Ent"
)
plot(simmr_out_combine$input)
plot(simmr_out_combine, type = "boxplot", title = "simmr output: combined sources")

## End(Not run)

simmr documentation built on Feb. 27, 2021, 5:05 p.m.