calcdens: Estimates the transition density.

Description Usage Arguments Value Note Author(s) See Also Examples

Description

The system of ODEs is solved subject to initial conditions and the estimates of the mean, the variance, the macroscopic equations and the transition density are returned.

Usage

1
2
3
4
 calcdens(initdata, edata=NA, tstart=0, tend,
   initode=NA,initmean=rep(0,length(initdata)),
   initvar=rep(0,length(initdata)*(length(initdata)+1)/2),
   thetas,relerr=1e-8, abserr=1e-8, syssize,dfunction)

Arguments

initdata

A numerical vector indicating the initial point. It is unscaled, e.g. expressed as number of molecules.

edata

Optional, a numerical vector indicating the ending point. It also is unscaled, e.g. expressed as number of molecules.

tstart

The starting time, defaults to 0.

tend

Either a vector or a scalar with the time-points to be estimated.

initode

Optional, the initial values of the macroscopic ODEs, defaults to the scaled initdata, e.g. the concentration of the species.

initmean

A numerical vector indicating the initial values for the means. Defaults to a vector of zeroes, otherwise it is expected to be scaled by the inverse of the square root of the system size.

initvar

Either a matrix indicating the initial Variance-Covariance matrix or a vector representing the upper diagonal (including the main diagonal) following a row orientation. Defaults to a matrix of zeroes and is expected to be on the scale of macroscopic ODEs.

thetas

A numerical vector with the parameter values.

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.

logprob

Boolean, indicate if the log of the probability should be returned.

syssize

Numerical, indicating the system size.

dfunction

The compiled function, given as a loaded dynamic library in R or as a character string of the symbol's name (similar to the is.loaded argument).

Value

A list of the following components, estimated at each tend time-point:

Time

The time instance of the estimates.

ODE

The value of the ODE equation (the macroscopic model), expressed in concentration.

MEAN

The mean of the SDE process, expressed in mesoscopic units (multiply by sqrt(system size) to convert to original units).

VAR

The covariance of the SDE process (multiply by system size to convert to original units).

prob

Optional, expresses the estimated transition probability density, available only ifedata is defined.

Note

All densities are conditioned on the initial time-point tstart. The MEAN and VAR elements are not at the same scale but they depend on the scale of the initial values. We assume that the initial values are given as number of molecules.

Author(s)

Vasileios Giagos

See Also

The model parsing is described in parsemod.

Examples

 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
33
34
35
36
37
## Not run: 
require(lnar)
##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
initdata<-c(50.0, 30)
data2<-c(51, 28)

compmod(cout,"derivs") #Compile the model

##Test that derivs is working.
derivs(1,c(initdata[1],initdata[2],c(0,0,0,0,0)),
       rep(0,7),c(.1,.0001,.1)) 

syssize=sum(initdata)
thetas <- c(0.25,0.20,0.125) #scaled kinetic constants
##Calculate Transition Density
(calc1<-calcdens(initdata,data2,tstar=0,tend=.1,
                thetas=thetas,
                syssize=syssize,
                dfunction=derivs))
##Test:
log(calc1[[1]]$prob) # -4.835931

##Calculate the trans. dens. parameters in some time points

(calc2<-calcdens(initdata,tstar=0,tend=c(.1,.5,3),
                thetas=thetas,
                syssize=syssize,
                dfunction=derivs))

## End(Not run)

lnar documentation built on May 2, 2019, 4:51 p.m.