Hello.
I'm a ecology grad student in brazil.
Well i'm trying to figure out how to use the function ode.
I read the manual on pack page and tryed to copy the example to solve de
logistc growth model to test if it work(work i mean i understood ^^) but i
cant make it right.
Then i got to this maillist by the pack page.

So first i solved with a  function:

logistico<- function(k,r,N0,t){
 N<-c(N0,numeric(t))
 for(i in 1:t) N[i+1]<-{
 N[i] + r * N[i] * (1 - N[i]/k)
 }
 return(N)
 }

then i get the results for a k=100 and r=1 in 20 times starting with a pop
of 2 individuals

Nts <- logistico(100,1,2,20)

to here its ok to me
now i tryed to make a function to use with desolve as following:

Logistic<-function(t, state, parameters) {
 with(as.list(c(state, parameters)),{
 dN <- r*n*(1-n/k)
 list(c(dN))
 })
 }

then tryed to solve

library(desolve)
parameters <- c(r = 1, k = 100)
state <- c(n = 2)
times <-seq(0,20,by=1)
out <- ode(y = state, times = times, func = Logistic, parms = parameters)

but the results are different

out<-cbind(out,Nts)
matplot(x=out[,1],y=out[,2:3],xlab=c("Times"),ylab=c("Pop. Density"),
type="l")
legend(x=15,y=90,legend=c("Desolve","Function"),pch =19, col=c(1, 2))


On the book Primer of ecology with R Stevens use desolve on levins
metapopulation model a little bit different, takeing out the state on
function like...

Logistic<-function(t, state, parameters) {
n<-state[1]   # <-------------------------------why this?
 with(as.list(parameters),{
 dn <- r*n*(1-n/k)
 return(list(dn))
 })
 }

but omg i dont understand whats the difference
I have a poor mathematical background but if anyone could help me understand
what i'm doing it would make me really happy :)


-- 
Grato
Augusto C. A. Ribas

	[[alternative HTML version deleted]]

