sde.prior {msde} | R Documentation |
Evaluates the SDE prior given data, parameter, and hyperparameter values.
sde.prior(model, theta, x, hyper)
model |
An |
theta |
A vector or matrix of parameters with |
x |
A vector or matrix of data with |
hyper |
The hyperparameters of the SDE prior. See 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")
.
A vector of log-prior densities evaluated at the inputs.
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)