OU.aux <- function( drift.expr = expression(kappa*(theta - X)), diffuse.expr = expression(sigma), rho.names = c("kappa", "theta", "sigma"), N = 1, M = 1, t.per.sim = 1, ndt = 100, z = NULL, seed = 0, X0 = rep(0.1, length = N), returnc = rep(T, length = N), lbound = -100, ubound = 100) { # aux components: # drift.expr splus drift fn. # diffuse.expr splus diffusion fn. # rho.names character vector naming elements of rho vector # N dimension of the problem; size of X # M dimension of the Wiener process for the problem # t.per.sim is the time length of each simulation step # ndt is the number of discretization steps per simulation step # z random normals, optional, of length M*ndt*(n.burn+n.sim) # (will otherwise be generated internally) # seed seed used if z is not given. # X0 is the initial condition (of length N) # returnc logical vector of length N indicating which elements to return # lbound, simulation will be truncated to lie in [lbound, ubound] # ubound aux <- list(drift.expr = drift.expr, diffuse.expr = diffuse.expr, rho.names = rho.names, N = N, M = M, t.per.sim = t.per.sim, ndt = ndt, z = z, seed = seed, X0 = X0, returnc = returnc, lbound = lbound, ubound = ubound) aux$drift.pcode <- gensim.pcode(drift.expr, aux) aux$diffuse.pcode <- gensim.pcode(diffuse.expr, aux) aux } OU.gensim <- function(rho,n.sim,n.var=1,n.burn=0,aux=OU.aux()) { euler1d.pcode.gensim(rho=rho, n.sim = n.sim, n.burn = n.burn, aux = aux) } CIR.aux <- function( drift.expr = expression(kappa*(theta-X)), diffuse.expr = expression(sigma*sqrt(X)), rho.names = c("kappa", "theta", "sigma"), N = 1, M = 1, t.per.sim = 1, ndt = 100, z = NULL, seed = 0, X0 = rep(0.1, length = N), returnc = rep(T, length = N), lbound = 0, ubound = 100) { # aux components: # drift.expr splus drift fn. # diffuse.expr splus diffusion fn. # rho.names character vector naming elements of rho vector # N dimension of the problem; size of X # M dimension of the Wiener process for the problem # t.per.sim is the time length of each simulation step # ndt is the number of discretization steps per simulation step # z random normals, optional, of length M*ndt*(n.burn+n.sim) # (will otherwise be generated internally) # seed seed used if z is not given. # X0 is the initial condition (of length N) # returnc logical vector of length N indicating which elements to return # lbound, simulation will be truncated to lie in [lbound, ubound] # ubound aux <- list(drift.expr = drift.expr, diffuse.expr = diffuse.expr, rho.names = rho.names, N = N, M = M, t.per.sim = t.per.sim, ndt = ndt, z = z, seed = seed, X0 = X0, returnc = returnc, lbound = lbound, ubound = ubound) aux$drift.pcode <- gensim.pcode(drift.expr, aux) aux$diffuse.pcode <- gensim.pcode(diffuse.expr, aux) aux } CIR.gensim <- function(rho,n.sim,n.var=1,n.burn=0,aux=CIR.aux()) { euler1d.pcode.gensim(rho=rho, n.sim = n.sim, n.burn = n.burn, aux = aux) }