[R] An applied math question with solve()

Ben Bolker ben at eno.princeton.edu
Sun Aug 12 23:14:19 CEST 2001


  I believe your problem is that you left out the source term (b must be
>0 to get a nontrivial answer).  If you think about the logistic equation,
you get b = r and a=-r/K.  The equation you want to solve is
sum(aijXj)=-bi, so add

b <- -runif(3)
solve(a,b)

below to get a positive set of answers.

  cheers,
    Ben Bolker

On Fri, 10 Aug 2001, Martin Henry H. Stevens wrote:

> I have a math (and maybe an R) question.
> I want to find equilibrium population density values for a system of linear
> population growth equations (e.g., Pimm and Lawton 1977). The eventual goal
> is to
> perform stability analysis. I can find the partial differential equations
> for the Jacobian matrix, but I get stuck trying finding the equilibriuym pop
> densities (X*). Here is the (incorrect?) R code for for the X*:
>
> # An attempt at stabiltiy analysis.
> # Each pop growth equation -  (Not code)  is dXi/dt = Xi ( bi +
> Sum(a[i,j]Xj) )
> # Set dX/dt = 0, divide both sides by Xi and you get bi + sum(aijXj) = 0
> # For three species this is represented by:
>
> a[1,1] + a[1,2] + a[1,3] = 0
> a[2,2] + a[2,1] + a[2,3] = 0
> a[3,3] + a[3,1] + a[3,2] = 0
>
> #select random coefficients that should result in positive X*'s
> a <- matrix(-runif(9), nrow=3,ncol=3); diag(a) <- 1
> a
> solve(a,rep(0,3))
> # This returns the trivial answer. How do I get the meaningful one???
>
> Thanks for any help,
> Henry
>
>
> *****************************
> Martin Henry H. Stevens
> HStevens at muohio.edu
> tel: (513) 529 - 4206
> FAX: (513) 529 - 4243
>
> 338 Pearson Hall
> Botany Department
> Miami University
> Oxford, OH 45056
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

Permanent address:
Zoology Department, University of Florida
bolker at zoo.ufl.edu
(352) 392-5697

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list