Tuesday, February 26, 2013

New version of package for numerical analyses in evolutionary biology

I just added a new function to my little R package 'popgen' for numerical analyses and simulation in evolution and population genetics (see my previous post on this here). The function is called hawk.dove and does numerical analysis of a simple discrete-time hawk-dove model. It then shows the result in a two panel plot. The first panel gives the frequencies of each phenotype through time; whereas the second plot gives the mean fitness of the population and the mean fitness of each strategy. The idea is to play with the payoff matrix to see how the behavior of the model changes. Coexistence of both hawk and dove strategies, or extinction of one or the other, are all possible.

Here's a demo. First download the package source (popgen 0.2).

> install.packages("popgen_0.2.tar.gz",type="source", repos=NULL)
...
* DONE (popgen)
> payoff<-matrix(c(0.6,1.5,0.5,1.0),2,2,byrow=T)
> colnames(payoff)<-rownames(payoff)<-c("hawk","dove")
> payoff
    hawk dove
hawk  0.6  1.5
dove  0.5  1.0
> hawk.dove(M=payoff,time=50)
Pay-off matrix:
    hawk dove
hawk  0.6  1.5
dove  0.5  1.0

That's it.

2 comments:

  1. BTW - I should've mentioned that I did this for my 'Animal Behavior' class that I'm teaching this semester.

    ReplyDelete

Note: due to the very large amount of spam, all comments are now automatically submitted for moderation.