euler                  package:pomp                  R Documentation

_P_l_u_g-_i_n_s _f_o_r _d_y_n_a_m_i_c_a_l _m_o_d_e_l_s _b_a_s_e_d _o_n _s_t_o_c_h_a_s_t_i_c _E_u_l_e_r _a_l_g_o_r_i_t_h_m_s

_D_e_s_c_r_i_p_t_i_o_n:

     Plug-in facilities for implementing discrete-time Markov processes
     and continuous-time Markov processes using the Euler algorithm.
     These can be used in the 'rprocess' and 'dprocess' slots of
     'pomp'.

_U_s_a_g_e:

     euler.simulate(xstart, times, params, step.fun, delta.t, ...,
                    statenames = character(0), paramnames = character(0),
                    covarnames = character(0), zeronames = character(0),
                    tcovar, covar, PACKAGE)
     onestep.simulate(xstart, times, params, step.fun, ...,
                      statenames = character(0), paramnames = character(0),
                      covarnames = character(0), zeronames = character(0),
                      tcovar, covar, PACKAGE)
     onestep.density(x, times, params, dens.fun, ...,
                     statenames = character(0), paramnames = character(0),
                     covarnames = character(0), tcovar, covar, log = FALSE,
                     PACKAGE)

_A_r_g_u_m_e_n_t_s:

  xstart: Matrix (dimensions 'nvar' x 'nrep') of states at initial time
          'times[1]'. 

       x: Matrix (dimensions 'nvar' x 'nrep' x 'ntimes') of states at
          times 'times'. 

   times: Vector of times (length 'ntimes') at which states are
          required or given. 

  params: Matrix containing parameters of the model. The 'nrep' columns
          of 'params' correspond to those of 'xstart'. 

step.fun: This can be either an R function or the name of a compiled,
          dynamically loaded native function containing the model
          simulator. It should be written to take a single Euler step
          from a single point in state space. If it is a native
          function, it must be of type pomp_onestep_sim as defined in
          the header pomp.h, which is included with the package. For
          details on how to write such codes, see Details. 

dens.fun: This can be either an R function or a compiled, dynamically
          loaded native function containing the model transition log
          probability density function. This function will be called to
          compute the log likelihood of the actual Euler steps. It must
          be of type pomp_onestep_pdf as defined in the header
          pomp.h, which is included with the package. For details on
          how to write such codes, see Details. 

 delta.t: Time interval of Euler steps. 

statenames, paramnames, covarnames: Names of state variables,
          parameters, covariates, in the order they will be expected by
          the routine named in 'step.fun' and 'dens.fun'. This
          information is only used when the latter are implemented as
          compiled native functions. 

zeronames: Names of additional variables which will be zeroed before
          each time in 'times'. These are useful, e.g., for storing
          accumulations of state variables. 

covar, tcovar: Matrix of covariates and times at which covariates are
          measured. 

     log: logical; if TRUE, log probabilities are given. 

     ...: if 'step.fun' (or 'dens.fun') is an R function, then
          additional arguments will be passed to it. If 'step.fun' (or
          'dens.fun') is a native routine, then additional arguments
          are ignored. 

 PACKAGE: an optional argument that specifies to which dynamically
          loaded library we restrict the search for the native
          routines. If this is base, we search in the R executable
          itself. 

_D_e_t_a_i_l_s:

     'onestep.simulate' assumes that a single call to 'step.fun' will
     advance the state process from one time to the next.
     'euler.simulate' will take multiple Euler steps, each of size at
     most 'delta.t' (see below for information on how the actual Euler
     step size is chosen) to get from one time to the next.

     'onestep.density' assumes that no state transitions occure between
     consecutive times.

     If 'step.fun' is written as an R function, it must have at least
     the arguments 'x', 't', 'params', 'delta.t', and '...'. On a call
     to this function, 'x' will be a named vector of state variables,
     't' a scalar time, and 'params' a named vector of parameters. The
     length of the Euler step will be 'delta.t'. If the argument
     'covars' is included and a covariate table has been included in
     the 'pomp' object, then on a call to this function, 'covars' will
     be filled with the values, at time 't', of the covariates. This is
     accomplished via interpolation of the covariate table. Additional
     arguments may be given: these will be filled by the
     correspondingly-named elements in the 'userdata' slot of the
     'pomp' object (see 'pomp').

     If 'step.fun' is written in a native language, it must be a
     function of type "pomp_onestep_sim" as specified in the header
     "pomp.h" included with the package (see the directory "include" in
     the installed package directory).

     If 'dens.fun' is written as an R function, it must have at least
     the arguments 'x1', 'x2', 't1', 't2', 'params', and '...'. On a
     call to this function, 'x1' and 'x2' will be named vectors of
     state variables at times 't1' and 't2', respectively. The named
     vector 'params' contains the parameters. If the argument 'covars'
     is included and a covariate table has been included in the 'pomp'
     object, then on a call to this function, 'covars' will be filled
     with the values, at time 't1', of the covariates. This is
     accomplished via interpolation of the covariate table. As above,
     any additional arguments will be filled by the
     correspondingly-named elements in the 'userdata' slot of the
     'pomp' object (see 'pomp').

     If 'dens.fun' is written in a native language, it must be a
     function of type "pomp_onestep_pdf" as defined in the header
     "pomp.h" included with the package (see the directory "include" in
     the installed package directory).

_V_a_l_u_e:

     'euler.simulate' and 'onestep.simulate' each return a 'nvar' x
     'nrep' x 'ntimes' array, where 'nvar' is the number of state
     variables, 'nrep' is the number of replicate simulations (= number
     of columns of 'xstart' and 'params'), and 'ntimes' is the length
     of 'times'. If 'x' is this array, 'x[,,1]' will be identical to
     'xstart'; the rownames of 'x' and 'xstart' will also coincide.

     'onestep.density' returns a 'nrep' x 'ntimes-1' array. If 'f' is
     this array, 'f[i,j]' is the likelihood of a transition from
     'x[,i,j]' to 'x[,i,j+1]' in exactly one Euler step of duration
     'times[j+1]-times[j]'.

_A_u_t_h_o_r(_s):

     Aaron A. King kingaa at umich dot edu

_S_e_e _A_l_s_o:

     'eulermultinom', 'pomp'

_E_x_a_m_p_l_e_s:

     ## an example showing how to use these functions to implement a seasonal SIR model is contained
     ## in the 'examples' directory
     ## Not run: 
     edit(file=system.file("examples/euler_sir.R",package="pomp"))
     ## End(Not run)

