simulate: Simulate Spread of Gene for Altruism

Description Usage Arguments Value Note Examples

View source: R/simulate.R

Description

Simulate Spread of Gene for Altruism

Usage

1
2
3
4
5
6
7
simulate(initial_pop = list(m0 = 90, m1 = 0, m2 = 10, f0 = 90, f1 = 0, f2 =
  10), average_litter_size = 5, birth_rate_natural = 0.05,
  death_rate_natural = 0, prob_attack = 0.2, warner_death_prob = 0.4,
  nonwarner_death_prob = 0.2, hider_death_prob = 0, sim_gens = 2,
  capacity = 2000, mating_behavior = NULL, culling_behavior = NULL,
  attack_behavior = NULL, relationship_method = c("matrix", "graph",
  "none"), graph = TRUE)

Arguments

initial_pop

List comprised of six named elements:

m0

initial number of males with 0 altruist alleles;

m1

initial number of males with 1 altruist allele;

m2

initial number of males with 2 altruist alleles;

f0

initial number of females with 0 altruist alleles;

f1

initial number of females with 1 altruist allele;

f2

initial number of females with 2 altruist alleles.

average_litter_size

Mean size of a litter.

birth_rate_natural

Birth rate for the population.

death_rate_natural

Death rate for a size-zero population. Rises linearly to birth_rate_natrual as populaiion approaches capacity.

prob_attack

The probability of a predator attack in any given generation.

warner_death_prob

Probability that an individual who warns others during an attack will be killed.

nonwarner_death_prob

Probability of death for an individual who does not warn others but who was not forewarned by a warner.

hider_death_prob

Probability of death during an attack for an individual who accepts a warning.

sim_gens

Number of generations to simulate.

capacity

Carrying capacity of the population.

mating_behavior

Custom function to govern how eligible partners form couples.

culling_behavior

Custom function to determine death probabilities of individuals at the culling stage..

attack_behavior

Custom function to govern behavior of warners when population is under attack.

relationship_method

One of "matrix", "graph" and "none". Defaults to "matrix". Use "none" only if no relationships (other than mother and father id) need to be tracked.

graph

If TRUE, provides a graph of the total per-capita warner alleles in population over the generations.

Value

A data frame with information on the population at each generation. Each row describes the population at the end of a single birth-death-attack cycle. Variables are:

populationSize

total population

males

total number of males

males0

number of males with no alleles for altruism

males1

number of males with one allele for altruism

males2

number of males with two alleles for altruism

females

total number of females

females0

number of females with no alleles for altruism

females1

number of females with one allele for altruism

females2

number of females with two alleles for altruism

Note

For details on mating_behavior, mating_behavior and attack_behavior consult the package documentation.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
# use defaults, get a graph:
pop <- simulate(sim_gens = 400)
# attacks are infrequent, and it's dangerous to warn:
pop <- simulate(sim_gens = 200,
                warner_death_prob = 0.8,
                attack_prob = 0.05)
# use an alternative mating function exported by package:
pop <- simulate(sim_gens = 200,
                warner_death_prob = 0.8,
                mating_behavior = list(
                  fn = sexualSelection,
                  args = list(
                    matrix(
                      c(1, 5, 10, 1, 1, 1, 10, 5, 1),
                      nrow = 3,
                      ncol = 3))))

## End(Not run)

homerhanumat/simaltruist documentation built on May 25, 2019, 5:26 p.m.