You need to treat the functions as expressions. You cannot mix data
types in a matrix (or vector) so you cannot have elements of which some
are numbers and some are functions. But if you treat all elements as
expressions, it is possible to work with that. A long time ago I wrote
some code showing how to do this for elasticity and sensitivity analysis
of vital rates. See this thread:
https://stat.ethz.ch/pipermail/r-help/2007-October/143848.html
and in particular,
https://stat.ethz.ch/pipermail/r-help/attachments/20071027/423b83ac/attachment.pl
The code is implemented in popbio::vitalsens (thanks to Chris Stubben),
which you should study. See ?popbio::vitalsens for examples.
Good luck!
Simon.
PS Isn't this question more appropriate for r-sig-ecology?
On 05/01/16 08:08, Alexandre F. Souza wrote:
Dear friends,
I am creating a population ecology course for undergraduate students in
Brazil. I have already showed how to proceed with basic population matrix
models in R using basic functions as well as the popbio package and its
functions that simulate stochastic dynamics of deterministic matrices.
However, I have not been successful in finding resources to implement
accessible density dependent matrix dynamics. I find quite complex IPM
models, which are out of the scope of the course, or too simplistic
approaches like simple ceiling.
I need to use a matrix of transitions in which at least one of the
transitions would be replaced by a density dependent function related to
the density of a given stage. Something like
C = matrix(c(0, 0, 5.905, 0.368, 0.639, 0.025, 0.001, 0.152,
0.051), nrow = 3, byrow = TRUE, dimnames = list(fases, fases))
seedlings vegetative reproductive
seedlings 0.000 0.000 5.905
vegetative 0.368 0.639 0.025
reproductive 0.001 0.152 0.051
This matrix would be repeatedly multiplied by a vector of population
densities like
fases = c(1,2,3,4,5,6,7,8)
However, I need to replace for instance C(2,1) by a function related to the
density of seedlings in the previous year, like Value = 0.568/(1+0.584*N),
in which N is the number of seedlings in the previous year.
Do anyone have an idea on how to implement that? I implemented that in
Excel, but since I have been showing all course contents in R I would not
like to restrict this theme to Excel.
Thank you very much in advance,
Alexandre
--
Simon Blomberg, BSc (Hons), PhD, MAppStat, AStat.
Senior Lecturer and Consultant Statistician
School of Biological Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
T: +61 7 3365 2506
email: S.Blomberg1_at_uq.edu.au
http://www.evolutionarystatistics.org
Policies:
1. I will NOT analyse your data for you.
2. Your deadline is your problem.
Basically, I'm not interested in doing research
and I never have been. I'm interested in
understanding, which is quite a different thing.
- David Blackwell
_______________________________________________
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/