Computes the SDE model's diffusion function given data and parameter values.

sde.diff(model, x, theta)

Arguments

model

An sde.model object.

x

A vector or matrix of data with ndims columns.

theta

A vector or matrix of parameters with nparams columns.

Value

A matrix with ndims^2 columns containing the diffusion function evaluated at x and theta. Each row corresponds to the upper triangular Cholesky factor of the diffusion matrix. If either input contains invalid SDE data or parameters an error is thrown.

Examples

# load Heston's model hmod <- sde.examples("hest") #' # single input theta <- c(alpha = 0.1, gamma = 1, beta = 0.8, sigma = 0.6, rho = -0.8) x0 <- c(X = log(1000), Z = 0.1) sde.diff(model = hmod, x = x0, theta = theta)
#> [,1] [,2] [,3] [,4] #> [1,] 0.05 0 -0.48 0.36
#' # multiple inputs nreps <- 10 Theta <- apply(t(replicate(nreps, theta)), 2, jitter) X0 <- apply(t(replicate(nreps, x0)), 2, jitter) sde.diff(model = hmod, x = X0, theta = Theta)
#> [,1] [,2] [,3] [,4] #> [1,] 0.05009042 0 -0.4767387 0.3602690 #> [2,] 0.05071864 0 -0.4717288 0.3588100 #> [3,] 0.04974241 0 -0.4835216 0.3636576 #> [4,] 0.04973613 0 -0.4682086 0.3678106 #> [5,] 0.04987476 0 -0.4846615 0.3594774 #> [6,] 0.05076841 0 -0.4817823 0.3736990 #> [7,] 0.05021558 0 -0.4783600 0.3542517 #> [8,] 0.05034751 0 -0.4708220 0.3591319 #> [9,] 0.05045197 0 -0.4963152 0.3525183 #> [10,] 0.05037065 0 -0.4674276 0.3575796
#' # mixed inputs sde.diff(model = hmod, x = x0, theta = Theta)
#> [,1] [,2] [,3] [,4] #> [1,] 0.05 0 -0.4767387 0.3602690 #> [2,] 0.05 0 -0.4717288 0.3588100 #> [3,] 0.05 0 -0.4835216 0.3636576 #> [4,] 0.05 0 -0.4682086 0.3678106 #> [5,] 0.05 0 -0.4846615 0.3594774 #> [6,] 0.05 0 -0.4817823 0.3736990 #> [7,] 0.05 0 -0.4783600 0.3542517 #> [8,] 0.05 0 -0.4708220 0.3591319 #> [9,] 0.05 0 -0.4963152 0.3525183 #> [10,] 0.05 0 -0.4674276 0.3575796