sample_diet: Sample total consumption to create diet composition data

View source: R/sample_diet.R

sample_dietR Documentation

Sample total consumption to create diet composition data

Description

Create sampled diet composition data from the total consumption in an Atlantis scenario. Observation error and bias are added.

Usage

sample_diet(dat, fgs, unidprey = 0, alphamult = 1e+07)

Arguments

dat

A data.frame containing species (predator), agecl, time.days, atoutput (diet proportion) and prey species

fgs

A data frame created by load_fgs that reads in the csv file containing functional group names, usually "functionalGroups.csv".

unidprey

default (0) returns correctly identified prey, while decimal values up to 1 allocate up to that proportion of prey to an unidentified category at random.

alphamult

default (10000000) returns true diet comps, while a lower number (~10) returns high variance diet comp

Details

The function takes diet composition data from an Atlantis scenario where the data was read in from Atlantis output using load_diet_comp or load_detailed_diet_comp. One does not need to use these functions to create dat, rather you must only ensure that the structure of dat is the same. The user supplies a parameter unidprey ranging from 0 to 1 that determines bias in sample diet composition. Bias is added by allocating a random portion of each group to an "unidentified prey" category. The default unidprey is 0 which results in no reallocation of prey to unidentified categories. The user supplies a parameter alphamult that detemines observation error for sample diet compostion strays using a dirichlet distribution. The default alphamult is 10000000 which results in minimal observation error in diet composition. Lower values of alphamult increase observation error. The function adjusts the remaining diet so each predator diet per agecl (if in the input data) and time.days sums to one.

Author(s)

Robert Wildermuth, Sarah Gaichas

Examples

## Not run: 
	d <- system.file("extdata", "SETAS_Example", package = "atlantisom")
	groups <- load_fgs(dir = directory, "Functional_groups.csv")
	groups <- groups[groups$IsTurnedOn > 0, "Name"]
	results <- run_truth(scenario = "outputs",
	dir = d,
	file_fgs = "Functional_groups.csv",
	file_bgm = "Geography.bgm",
	select_groups = groups,
	file_init = "Initial_condition.nc",
	file_biolprm = "Biology.prm",
	file_runprm = "Run_settings.xml",
   file_fish = "Fisheries.csv")

	# rows should each sum to one:
	rowSums(dat[,2:NCOL(dat)])
	dim(dat)

	obsDietComp <- sample_diet(dat)
	dim(obsDietComp)

## End(Not run)

r4atlantis/atlantisom documentation built on Nov. 12, 2023, 2:59 a.m.