Description Usage Arguments Details Value Example 1 Example 2

Contains densities and random number generators for some example mark distributions. The mark distributions can be multi-dimensional. Users can write their own functions, and general rules are given under “Details”.

1 2 |

`ti` |
scalar, time of an event. |

`x` |
a |

`data` |
a |

`params` |
numeric vector of parameters. |

The example functions listed under “Usage” calculate the *logarithm* of the (mark) density and simulate earthquake magnitudes assuming an exponential distribution that is independent of the history of the process. This corresponds to the Gutenberg-Richter law. They assume that the history contains a variable named `"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.

Mark density functions must return a vector with length being equal to the number of rows in `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.

This is an example where the density of the magnitude distribution is dependent on the value of the ground intensity function (assumed to be `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, ..., p_5* relating to `etas_gif`

. It assumes that the magnitude distribution is gamma (`GammaDist`

), with a shape parameter given by

*
shape = 1 + sqrt{lambda_g(t|Ht)} * 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|Ht)* is small, the magnitude distribution returns to an approximate exponential distribution with an approximate rate of *p_6* (i.e. Gutenberg Richter law).

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ```
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))
}
``` |

This an example of a 3-D mark distribution. Each component is independent of each other and the history, hence the arguments `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.

1 2 3 4 5 6 7 8 9 | ```
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])))
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.