Description Usage Arguments Details Value Author(s) References See Also Examples
frunge provides a sampled numeric solution for an ODE for a given set of values of the independent variable (t). Returns a series of values corresponding to each values of t
1 |
t |
The independent variable. Must be sorted in increasing order |
param |
Numeric vector : under the form of |
y0 |
The initial condition. May appear as a parameter for nls. See details |
Dfdt |
A function giving the right side of the ODE. Default is |
dt |
Time increment for Runge-Kutta algorithm. Must be lower than the smaller difference between two consecutive t values |
graph |
If true, plots the graph of the function over the range of t. (For standalone usage) |
The vector t must be sorted in increasing order. Any badly placed t will result
in an error and program exit. dt must be lower than min(diff(t)). If not, an error will occur. The shorter dt, the more accurate the solution but the longer the calculation will be.
A numeric vector of length equal to the length of t. y[1] is set to y0
Jean-Sebastien Pierre
Jean-sebastien.pierre@univ-rennes1.fr
Numerical recipes http://www.nr.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | v<-frunge(t=seq(0,50,0.5), param=c(r=0.1,k=100), y0=3, Dfdt = dfdt, dt = 0.01, graph = TRUE)
plot(seq(0,50,0.5),v)
##
## Example of model fitting with frunge. a : determined initial condition
##
data(logis)
attach(logis)
nls(y~frunge(time,c(r,k),y0=3,dfdt,graph=FALSE),data=logis,start=list(r=0.05,k=100),trace=TRUE)->m1
plot(time,y)
lines(time,fitted(m1))
summary(m1)
detach(logis)
##
## Example of model fitting with frunge. b : unknown initial condition ;
## y0 is fitted as a parameter
## Not run: data(logis)
attach(logis)
nls(y~frunge(time,c(r,k,y0),y0,dfdt,graph=FALSE),data=logis,start=list(r=0.05,k=100,y0=y[1]),
trace=TRUE)->m2
plot(time,y)
lines(time,fitted(m2))
summary(m1)
detach(logis)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.