Description Usage Arguments Details Value Note Author(s) References See Also Examples
Fits the compiled model to a given datased using a numerical Maximul Likelihood Estimation procedure.
1 2 3 4 |
cout |
The parsed model containing the C code and the name relations. |
nthetas |
A numerical vector with the initial values for the parameters to be optimized. |
mydata |
A |
maxiter |
Numerical, indicated the maximum number of iterations for the optimization algorithm. |
syssize |
Numerical, the system size defaults to the initial population. |
tcrit |
Numerical, the convergence criterion for the optimization algorithm. |
relerr |
Numerical, the relative error for the numerical ordinary differential equations (ODEs) solver. |
abserr |
Numerical, the absolute error for the numerical ordinary differential equations (ODEs) solver. |
hessianh |
Numerical, indicates the approximation step for the central differences calculations of the Hessian matrix. |
method |
Numerical which takes the following integer values:
a discussion on the Restarting and the Non Restarting method can be found in Giagos (2010). |
usebfgs |
Specify whether to use the BFGS algorithm (1), or the default Nelder-Mead simplex algorithm (0) |
hess |
Specify whether to calculate the Hessian matrix (1), or not (0) |
dfunction |
The compiled function, given as a loaded dynamic library in R. |
By default the L-BFGS-B
optimization procedure is employed
(see optim
for more details).
A list with the following elements:
UP |
The upper confidence bound. |
ES |
The MLEs |
LO |
The lower confidence bound. |
Note that the tcrit
has a different interpretation for the
Nelder-Mead algorithm and different for BFGS
Vasileios Giagos
Giagos, V.: 2010, Inference for auto-regulatory genetic networks using diffusion process approximations, Thesis, Lancaster University, 2010.
The model parsing is described in parsemod
.
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 26 27 28 29 30 31 32 | ## Not run:
##We consider the Lotka-Volterra Model
tt <- matrix(c(1,-1,0,0,1,-1),nrow=2,ncol=3,byrow=TRUE)
rfun <- c("con1 * Prey","con2 * Prey * Predator","con3 * Predator")
thetas <- paste("con",1:3,sep="")
species <- c("Prey","Predator")
cout <- parsemod(tt,rfun,thetas,species) #Parse the model
##Inputs a dataset
mydata<-c(0.0, 5000.0, 3000, 1, 5989, 2992, 2, 7165, 3107, 3, 8534, 3306,
4, 10041, 3709, 5, 11624, 4265, 6, 13306, 5181, 7, 14741, 6492,
8, 15867, 8337, 9, 16025, 10981)
mydata2<-t(matrix(mydata,3,10)) # Put the data into a matrix
compmod(cout,"derivs") #Compile the model
##Test that derivs is working.
derivs(mydata[1],c(mydata[2],mydata[3],c(0,0,0,0,0)),
rep(0,7),c(.1,.0001,.1))
##Run model
run1<-optmod(cout,nthetas=c(.5,.1,.2), mydata=mydata2,
maxiter=300, simplexsize=1e-5, relerr=1e-9,
abserr=1e-9, hessianh=1e-4,dfunction=derivs)
##Try a random starting value. WARNING! May crash!
(nthetas<-exp(runif(3,-3,1)))
run2<-optmod(cout,nthetas=nthetas, mydata=mydata2,
maxiter=500, simplexsize=1e-6, relerr=1e-9,
abserr=1e-9, hessianh=1e-4,dfunction=derivs)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.