Evaluates the SDE prior given data, parameter, and hyperparameter values.

sde.prior(model, theta, x, hyper)

Arguments

model

An sde.model object.

theta

A vector or matrix of parameters with nparams columns.

x

A vector or matrix of data with ndims columns.

hyper

The hyperparameters of the SDE prior. See Details.

Value

A vector of log-prior densities evaluated at the inputs.

Details

The prior is constructed at the C++ level by defining a function (i.e., public member)

double logPrior(double *theta, double *x)

within the sdePrior class. At the R level, the hyper.check argument of sde.make.model() is a function with arguments hyper, param.names, data.names used to convert hyper into a list of NULL or double-vectors which get passed on to the C++ code. This function can also be used to throw R-level errors to protect the C++ code from invalid inputs, as is done for the default prior in mvn.hyper.check(). For a full example see the "Custom Prior" section in vignette("msde-quicktut").

Examples

hmod <- sde.examples("hest") # load Heston's model # setting prior for 3 parameters rv.names <- c("alpha","gamma","rho") mu <- rnorm(3) Sigma <- crossprod(matrix(rnorm(9),3,3)) names(mu) <- rv.names colnames(Sigma) <- rv.names rownames(Sigma) <- rv.names hyper <- list(mu = mu, Sigma = Sigma) # Simulate data nreps <- 10 theta <- c(alpha = 0.1, gamma = 1, beta = 0.8, sigma = 0.6, rho = -0.8) x0 <- c(X = log(1000), Z = 0.1) Theta <- apply(t(replicate(nreps,theta)),2,jitter) X0 <- apply(t(replicate(nreps,x0)),2,jitter) sde.prior(model = hmod, x = X0, theta = Theta, hyper = hyper)
#> [1] -10.79169 -10.68661 -10.74280 -10.86942 -10.84613 -10.91164 -10.95858 #> [8] -10.67671 -10.85017 -10.65771