dexp_mark(x, data, params)
rexp_mark(ti, data, params)
data.frame
of mark values at given times, often a subset of the history.data.frame
containing the history of the process, denoted below as ${\cal H}_t$.x
. Each element contains the logarithm of the joint density of the marks corresponding to each time (row) in x
.The random number generator simulates each mark for a single value of ti
. It must return a list
of simulated marks corresponding to the specified time ti
. Further, the list must have its elements named the same as those in the history. Note that each component in the list will be of length one. A list is used (rather than a vector) because it allows marks to be character as well as numeric.
etas_gif
), and in this case, the history of the process. The history is assumed to contain a variable named "magnitude"
. In this mark distribution, it is assumed that after large events, there is a deficit of smaller magnitude events with more larger magnitude events. It has seven parameters with parameters $p_1, \cdots, p_5$ relating to etas_gif
. It assumes that the magnitude distribution is gamma (GammaDist
), with a shape parameter given by
$$\mbox{shape} = 1 + \sqrt{\lambda_g(t|{\cal H}_t)} \ p_7 \,,$$
where $p_7$ ($p_7 > 0$) is a free estimable parameter, and parameter $p_6$ is the scale parameter. Hence when $\lambda_g(t|{\cal H}_t)$ is small, the magnitude distribution returns to an approximate exponential distribution with an approximate rate of $p_6$ (i.e. Gutenberg Richter law).
dexample1_mark <- function(x, data, params){
lambda <- etas_gif(data, x[,"time"], params=params[1:5])
y <- dgamma(x[,"magnitude"], rate=params[6],
shape=1+sqrt(lambda)*params[7], log=TRUE)
return(y)
}rexample1_mark <- function(ti, data, params){ # Gamma distribution # exponential density when params[7]=0 lambda <- etas_gif(data, ti, params=params[1:5]) y <- rgamma(1, shape=1+sqrt(lambda)*params[7], rate=params[6]) return(list(magnitude=y)) }
ti
and data
are not utilised in the functions. The history is assumed to contain the three variables "magnitude"
, "longitude"
and "latitude"
. The event magnitudes are assumed to have an exponential distribution with rate params[1]
, and the longitudes and latitudes to have normal distributions with means params[2]
and params[3]
, respectively.
dexample2_mark <- function(x, data, params)
return(dexp(x[,"magnitude"], rate=params[1], log=TRUE) +
dnorm(x[,"longitude"], mean=params[2], log=TRUE) +
dnorm(x[,"latitude"], mean=params[3], log=TRUE))rexample2_mark <- function(ti, data, params) return(list(magnitude=rexp(1, rate=params[1]), longitude=rnorm(1, mean=params[2]), latitude=rnorm(1, mean=params[3])))
"magnitude"
.All mark densities and random number generators must have the three arguments as shown in the examples above. Multi-parameter distributions have their parameters specified as a vector in the params
argument. Other ancillary data or information can be passed into the function non formally, though one needs to be careful about possible conflict with names of other objects.