sde.prior: SDE prior function.

Description Usage Arguments Details Value Examples

Description

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

Usage

1
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.

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").

Value

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
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)

msde documentation built on May 2, 2019, 2:05 a.m.