Description Usage Arguments Value Author(s) Examples
Calculates the minus loglikelihood of an (bivariate) MRHawkes model with
given immigration hazard functions μ, offspring density functions
h and bracnhing ratios η for the event times and types
data
on the interval [0,cens].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | mllMRH(data, cens, par,
h1.fn = function(x, p) 1 / p * exp( - x / p),
h2.fn = function(x, p) 1 / p * exp( - x / p),
mu1.fn = function(x, p){
exp(dweibull(x, shape = p[1], scale = p[2], log = TRUE) -
pweibull(x, shape = p[1], scale = p[2], lower.tail = FALSE,
log.p = TRUE))
},
mu2.fn = function(x, p){
exp(dweibull(x, shape = p[1], scale = p[2], log = TRUE) -
pweibull(x, shape = p[1], scale = p[2], lower.tail = FALSE,
log.p = TRUE))
},
H1.fn = function(x, p) pexp(x, rate = 1 / p),
H2.fn = function(x, p) pexp(x, rate = 1 / p),
Mu1.fn = function(x, p){
- pweibull(x, shape = p[1], scale = p[2], lower.tail = FALSE,
log.p = TRUE)
},
Mu2.fn = function(x, p){
- pweibull(x, shape = p[1], scale = p[2], lower.tail = FALSE,
log.p = TRUE)
})
|
data |
A two column matrix. The first column contains the event times sorted in ascending order. The second column contains the corresponding event type with the label one or two. |
cens |
A scalar. The censoring time. |
par |
A numeric vector. Contains the ten parameters of the model, in order of the immigration parameters μ(.) for the two renewal distributions, the two offspring parameters h(.) and lastly the four branching ratios η. |
h1.fn |
A (vectorized) function. The offspring density function for type one events. |
h2.fn |
A (vectorized) function. The offspring density function for type two events. |
mu1.fn |
A (vectorized) function. The immigration hazard function for events of type one. |
mu2.fn |
A (vectorized) function. The immigration hazard function for events of type two. |
H1.fn |
A (vectorized) function. Its value at |
H2.fn |
A (vectorized) function. Its value at |
Mu1.fn |
A (vectorized) function. Its value at |
Mu2.fn |
A (vectorized) function. Its value at |
Value of the negative log-liklihood.
Tom Stindl <t.stindl@unsw.edu.au> Feng Chen <feng.chen@unsw.edu.au>
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 | ## Magnitude 5.5 or greater earthquakes over the 25 year period from
## 01/01/1991 to 31/12/2015.
data(fivaqks);
near.fiji <- grep("Fiji", fivaqks$place)
near.vanuatu <- grep("Vanuatu", fivaqks$place)
t.beg <- strptime("1991-01-01 00:00:00", "%Y-%m-%d %H:%M:%S", tz = "UTC")
t.end <- strptime("2015-12-31 23:59:59", "%Y-%m-%d %H:%M:%S", tz = "UTC")
t0 <- 0
t1 <- as.numeric(t.end - t.beg)
tms <- strptime(fivaqks$time, "%Y-%m-%dT%H:%M:%OSZ", tz = "UTC")
ts <- as.numeric(tms[-1] - t.beg)
ts <- c(as.numeric(tms[1] - t.beg)/24, ts)
ts.fi <- ts[near.fiji]; ts.fi <- ts.fi[ts.fi >= 0 & ts.fi <= t1]
ts.va <- ts[near.vanuatu]; ts.va <- ts.va[ts.va >=0 & ts.va <= t1]
ts.c <- c(ts.fi, ts.va)
z.c <- c(rep(1, times = length(ts.fi)), rep(2, times = length(ts.va)))
o <- order(ts.c)
data <- cbind(ts.c[o], z.c[o])
## calculate the minus loglikelihood of an (bivariate) MRHawkes with some
## parameters the default hazard functions and density functions are Weibull
## and exponential respectivley
mllMRH(data, cens = t1, par = c(0.488, 20.10, 0.347, 9.53, 461, 720,
0.472, 0.293, 0.399, -0.0774))
## calculate the MLE for the parameter assuming known parametric forms
## of the immigrant hazard function and offspring density functions.
system.time(est <- optim(c(0.488, 20.10, 0.347, 9.53, 461, 720,
0.472, 0.293, 0.399, -0.0774),
mllMRH, data = data, cens = t1,
control = list(maxit = 5000, trace = TRUE),
hessian = TRUE)
)
## point estimate by MLE
est$par
## standard error estimates:
diag(solve(est$hessian))^0.5
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.