Description Usage Arguments Value Syntactical jargon Warning Author(s) References See Also Examples
BiGQD.mle()
uses parametrised coefficients (provided by the user as R-functions) to construct a C++ program in real time that allows the user to perform maximum likelihood inference on the resulting diffusion model.
BiGQD.density
generates approximate transitional densities for a class of bivariate diffusion processes with SDE:
where
and
1 2 3 |
X |
A matrix containing rows of data points to be modelled. Though observations are allowed to be non-equidistant, observations in both dimensions are assumed to occur at the same time epochs. |
time |
A vector containing the time epochs at which observations were made. |
mesh |
The number of mesh points in the time discretisation. |
theta |
The parameter vector starting values. |
control |
List of control variables to be used by |
method |
Method to be used by |
exclude |
Vector indicating which transitions to exclude from the analysis. Default = |
RK.order |
The order of the Runge-Kutta solver used to approximate the trajectories of cumulants. Must be 4 (default) or 10. |
Tag |
|
Dtype |
The density approximant to use. Valid types are |
rtf |
Starting vector for internal use. |
wrt |
If |
print.output |
If |
opt |
The output from optim. |
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 |
Synt. [1]: The coefficients of the 2D GQD may be parameterized using the reserved variable theta
. For example:
a00 <- 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:
a00 <- 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:
a00 <- function(t){0.1*(10+0.2*pow(sin(2*pi*t),3))}
.
Warning [1]: The parameter mesh
is used to discretize the transition horizons between successive observations. It is thus important to ensure that mesh
is not too small when large time differences are present in time
. Check output for max(dt) and divide by mesh
.
Warning [2]: Note that minus the likelihood is minimized, as such the optim
output (hessian) needs to be adjusted accordingly if used for calculating confidence intervals. Furthermore, GQD.mle
may be temperamental under certain conditions
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
, BiGQD.mcmc
, GQD.mcmc
, GQD.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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #===============================================================================
# This example simulates a bivariate time homogeneous diffusion and shows how
# to conduct inference using BiGQD.mle(). We fit two competing models and then
# use the output to select a winner.
#-------------------------------------------------------------------------------
data(SDEsim2)
data(SDEsim2)
attach(SDEsim2)
# Have a look at the time series:
plot(Xt~time,type='l',col='blue',ylim=c(2,10),main='Simulated Data',xlab='Time (t)',ylab='State',
axes=FALSE)
lines(Yt~time,col='red')
expr1=expression(dX[t]==2(Y[t]-X[t])*dt+0.3*sqrt(X[t]*Y[t])*dW[t])
expr2=expression(dY[t]==(5-Y[t])*dt+0.5*sqrt(Y[t])*dB[t])
text(50,9,expr1)
text(50,8.5,expr2)
axis(1,seq(0,100,5))
axis(1,seq(0,100,5/10),tcl=-0.2,labels=NA)
axis(2,seq(0,20,2))
axis(2,seq(0,20,2/10),tcl=-0.2,labels=NA)
#------------------------------------------------------------------------------
# Define the coefficients of a proposed model
#------------------------------------------------------------------------------
GQD.remove()
a00 <- function(t){theta[1]*theta[2]}
a10 <- function(t){-theta[1]}
c00 <- function(t){theta[3]*theta[3]}
b00 <- function(t){theta[4]}
b01 <- function(t){-theta[5]}
f00 <- function(t){theta[6]*theta[6]}
theta.start <- c(3,3,3,3,3,3)
X <- cbind(Xt,Yt)
# Calculate MLEs
m1=BiGQD.mle(X,time,10,theta.start)
#------------------------------------------------------------------------------
# Remove old coefficients and define the coefficients of a new model
#------------------------------------------------------------------------------
GQD.remove()
a10 <- function(t){-theta[1]}
a01 <- function(t){theta[1]*theta[2]}
c11 <- function(t){theta[3]*theta[3]}
b00 <- function(t){theta[4]*theta[5]}
b01 <- function(t){-theta[4]}
f01 <- function(t){theta[6]*theta[6]}
theta.start <- c(3,3,3,3,3,3)
# Calculate MLEs
m2=BiGQD.mle(X,time,10,theta.start)
# Compare estimates:
GQD.estimates(m1)
GQD.estimates(m2)
#------------------------------------------------------------------------------
# Compare the two models
#------------------------------------------------------------------------------
GQD.aic(list(m1,m2))
#===============================================================================
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.