Description Usage Arguments Details Value Syntactical jargon Note Author(s) References See Also Examples
GQD.mcmc()
uses parametrised coefficients (provided by the user as R-functions) to construct a C++ program in real time that allows the user to perform Bayesian inference on the resulting jump diffusion model. Given a set of starting parameters, a MCMC chain is returned for further analysis.
GQD.mcmc()
performs inference using the Metropolis-Hastings algorithm for jump diffusions of the form:
where
and
1 2 3 4 5 |
X |
Time series (vector) of discretely observed points of the process of interest. These may be non-equidistant observations (see |
time |
A vector of time-stamps associated with each observation in |
mesh |
The number mesh points between any two given data points. |
theta |
The parameter vector of the process. |
sds |
Proposal distribution standard deviations. That is, for the i-th parameter the proposal distribution is ~ Normal(..., |
updates |
The number of chain updates (including burned updates) to perform. |
burns |
The number of updates to burn. That is, the first |
exclude |
Vector indicating which transitions to exclude from the analysis. Default = |
plot.chain |
If |
RK.order |
The order of the Runge-Kutta solver used to approximate the trajectories of cumulants. Must be 4 or (default) 10. |
Dtype |
Character string indicating the type of density approximation (see details) to use. Types: |
Trunc |
Vector of length 2 containing the cumulant truncation order and the density truncation order respectively. May take on values 4, 6 and 8 with the constraint that |
P |
Normalization parameter indicating the number of points to use when normalizing members of the Pearson system (see details) |
alpha |
Normalization parameter controlig the mesh concentration when normalizing members of the Pearson system (see details). Increasing |
lower,upper |
Lower and upper bounds for the normalization range. |
Tag |
|
wrt |
If |
print.output |
If |
palette |
Colour palette for drawing trace plots. Default |
GQD.mcmc()
operates by searching the workspace for functions with names that match the coefficients of the predefined stochastic differential equation. Only the required coefficients need to be specified e.g. G0(t)
,G1(t)
and Q0(t)
for an Ornstein-Uhlenbeck model. Unspecified coefficients are ignored. When a new model is to be defined, the current model may be removed from the workspace by using the GQD.remove
function, after which the new coefficients may be supplied.
par.matrix |
A matrix containing the MCMC chain on |
acceptence.rate |
A vector containing the acceptance rate of the MCMC at every iteration. |
model.info |
A list of variables pertaining to inference calculations. |
model.info$elapsed.time |
The runtime, in h/m/s format,of the MCMC procedure (excluding compile time). |
model.info$time.homogeneous |
‘No’ if the model has time-homogeneous coefficients and ‘Yes’ otherwise. |
model.info$p |
The dimension of |
model.info$DIC |
Calculated Deviance Information Criterion. |
model.info$pd |
Effective number of parameters (see |
Synt. [1]: The coefficients of the GQD may be parameterized using the reserved variable theta
. For example:
G0 <- function(t){theta[1]*(theta[2]+sin(2*pi*(t-theta[3])))}
.
Synt. [2]: Due to syntactical differences between R and C++ special functions have to be used when terms that depend on t
. When the function cannot be separated in to terms that contain a single t
, the prod(a,b)
function must be used. For example:
G0 <- function(t){0.1*(10+0.2*sin(2*pi*t)+0.3*prod(sqrt(t),1+cos(3*pi*t)))}
.
Here sqrt(t)*cos(3*pi*t) constitutes the product of two terms that cannot be written i.t.o. a single t
. To circumvent this isue, one may use the prod(a,b)
function.
Synt. [3]: Similarly, the ^ - operator is not overloaded in C++. Instead the pow(x,p)
function may be used to calculate x^p. For example sin(2*pi*t)^3 in:
G0 <- function(t){0.1*(10+0.2*pow(sin(2*pi*t),3))}
.
Note [1]: When plot.chain
is TRUE
, a trace plot is created of the resulting MCMC along with the acceptance rate at each update. This may save time when scrutinizing initial MCMC runs.
Etienne A.D. Pienaar: etiennead@gmail.com
Updates available on GitHub at https://github.com/eta21.
Daniels, H.E. 1954 Saddlepoint approximations in statistics. Ann. Math. Stat., 25:631–650.
Eddelbuettel, D. and Romain, F. 2011 Rcpp: Seamless R and C++ integration. Journal of Statistical Software, 40(8):1–18,. URL http://www.jstatsoft.org/v40/i08/.
Eddelbuettel, D. 2013 Seamless R and C++ Integration with Rcpp. New York: Springer. ISBN 978-1-4614-6867-7.
Eddelbuettel, D. and Sanderson, C. 2014 Rcpparmadillo: Accelerating R with high-performance C++ linear algebra. Computational Statistics and Data Analysis, 71:1054–1063. URL http://dx.doi.org/10.1016/j.csda.2013.02.005.
Feagin, T. 2007 A tenth-order Runge-Kutta method with error estimate. In Proceedings of the IAENG Conf. on Scientifc Computing.
Varughese, M.M. 2013 Parameter estimation for multivariate diffusion systems. Comput. Stat. Data An., 57:417–428.
GQD.remove
, GQD.mle
, BiGQD.mcmc
, BiGQD.mle
, GQD.passage
and GQD.TIpassage
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #===============================================================================
# This example simulates a time inhomogeneous diffusion and shows how to conduct
# inference using GQD.mcmc
#-------------------------------------------------------------------------------
data(SDEsim1)
attach(SDEsim1)
par(mfrow=c(1,1))
expr1=expression(dX[t]==2*(5+3*sin(0.5*pi*t)-X[t])*dt+0.5*sqrt(X[t])*dW[t])
plot(Xt~time,type='l',col='blue',xlab='Time (t)',ylab=expression(X[t]),main=expr1)
#------------------------------------------------------------------------------
# Define parameterized coefficients of the process, and set up starting
# parameters.
# True model: dX_t = 2X_t(5+3sin(0.25 pi t)-X_t)dt+0.5X_tdW_t
#------------------------------------------------------------------------------
# Remove any existing coeffients. If none are pressent NAs will be returned, but
# this is a safeguard against overlapping.
GQD.remove()
# Define time dependant coefficients. Note that all functions have a single argument.
# This argument has to be `t' in order for the dependancy to be recognized.
# theta does not have to be defined as an argument.
G0 <- function(t){theta[1]*(theta[2]+theta[3]*sin(0.25*pi*t))}
G1 <- function(t){-theta[1]}
Q1 <- function(t){theta[4]*theta[4]}
theta.start <- c(1,1,1,1) # Starting values for the chain
proposal.sds <- c(0.4,0.3,0.2,0.1)*1/2 # Std devs for proposal distributions
mesh.points <- 10 # Number of mesh points
updates <- 50000 # Perform 50000 updates
#------------------------------------------------------------------------------
# Run the MCMC procedure for the model defined above
#------------------------------------------------------------------------------
m1 <- GQD.mcmc(Xt,time,mesh=mesh.points,theta=theta.start,sds=proposal.sds,
updates=updates)
# Calculate estimates:
GQD.estimates(m1,thin=200)
#===============================================================================
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.