[R] Differential Equations there use in R (population modeling)
stephen sefick
ssefick at gmail.com
Mon Aug 11 19:57:00 CEST 2008
error in isoda(y = 1, times = seq(0, 1, by = 0.02), func = e1B, parms
= c(b = 0.9)) :
Model function must return a list
this is the error message I get when I try and paste in the code.
Stephen Sefick
On Mon, Aug 11, 2008 at 1:36 PM, Ben Bolker <bolker at ufl.edu> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
>
> stephen sefick wrote:
> | population# = (initialvalue @ t) - (death rate) + (fecundtity per
> individual) dt
> | to be able to vary the values of the inputs death rate and fecundity
> | with time using initial value @ t from the previous time step to
> | evaluate the function at the present time step.
> |
> | On Mon, Aug 11, 2008 at 9:43 AM, Ben Bolker <bolker at ufl.edu> wrote:
> |> stephen sefick <ssefick <at> gmail.com> writes:
> |>
> |>> e1 <- function(x,b,t){
> |>> d<-(x)*(b^t)
> |>> plot(d)
> |>> }
> |>>
> |>> e1(2, 2,seq(from=0, to=6, by=1))
> |>>
> |>> Is there a way to do this with a change in time. I would like to use
> |>> differential equations.
> |> I'm not sure what you mean by "do this with a change in time",
> |> but in general for ODEs you should check out lsoda in the odesolve
> package.
> |> You can also look at the ecology/environment task view.
> |>
> |> Ben Bolker
> |>
>
> ~ Something like:
>
>
> library(odesolve)
>
> ## in general x, b are state and parameter VECTORS
> e1B <- function(t,x,b) {
> ~ list(x*b^t,NULL)
> }
>
> L1 = lsoda(y=1,times=seq(0,1,by=0.02),func=e1B,parms=c(b=0.9))
> plot(L1[,1],L1[,2])
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFIoHiVc5UpGjwzenMRAs+DAJ9kekwPnnlVE8mAMa61OmCkl0E2fACgiCy3
> L/oQ3zIonFXAcGmvugXjTdE=
> =GQFi
> -----END PGP SIGNATURE-----
>
--
Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods. We are mammals, and have not exhausted the
annoying little problems of being mammals.
-K. Mullis
More information about the R-help
mailing list