Learn R Programming

PtProcess (version 3.3-7)

Change Log: Changes Made to the Package

Description

This page contains a listing of recent changes made to functions, and known general problems.

Arguments

Recent Changes

  1. Version 3 contains major changes, and code that worked in Version 2 will no longer work in Version 3. The models included in Version 2 are also contained in Version 3, but the framework has been extended so that the original models can now contain a variety of mark distributions. This has been achieved by giving a more general structure and utilising the object orientated aspects of theRlanguage.Examples are given below that show how models were defined in Version 2 and how the corresponding models are now defined in Version 3.(28 Apr 2008)
  2. Naming changes to the*.ciffunctions. In Version 2, these were referred to asconditional intensity functions, which is really a slightly more general class. In keeping with Daley & Vere-Jones (2003) we now call them ground intensity functions, with a suffix ofgif. Further, the dot has been replaced by an underscore, e.g.etas.ciftoetas_gif. This is to lessen the possibility of future conflicts with object orientated naming conventions in theRlanguage. (28 Apr 2008)
  3. Argumentseval.ptsandt.plusin the ground intensity functions have been renamed toevalptsandtplus, respectively. This is to lessen the possibility of future conflicts with object orientated naming conventions in theRlanguage. (28 Apr 2008)
  4. logLik: the log-likelihood calculated in package Versions before Version 3 did not have the sum over the mark density term (see topiclogLik, underDetails). This term can also be excluded in this Version of the package by placingNULLfor the mark density in themppobject, see example below. (28 Apr 2008)
  5. Version 2 had a framework to assign prior densities to the estimated parameters. This has not been retained in Version 3. However, some of the features like holding a parameter at a fixed value, and restricting it to an open or closed interval can be achieved in Version 3; seeneglogLikfor further details. (28 Apr 2008)
  6. neglogLik: the format of this function has been changed to be consistent with that in packageHiddenMarkov. Argumentupdateprenamed aspmap. (07 Aug 2008)
  7. simulate: manual page revised to include more information about controlling the length of the simulated series. (18 Nov 2008)
  8. mpp: example modified due to warning messages caused by negative$\lambda_g(t|{\cal H}_t)$. (18 Nov 2008)
  9. marks: manual page revised to include more information. (18 Nov 2008)
  10. mpp: fuller description to argumentmarkson manual page. (19 Nov 2008)
  11. Phuket: new dataset added. (4 Dec 2008)
  12. linksrm_gif,marks: remove some LaTeX specific formatting to be compatible withR2.9.0. (26 Jan 2009)
  13. Phuket: clarify magnitude scale used in the dataset. (11 Jul 2009)
  14. Attributetypeis no longer required on thegiffunctions, removed. (7 Oct 2009)
  15. logLik,neglogLik: Parallel processing support, using packagesnow, has been added. (8 Oct 2009)
  16. plot: Correct hyperlink to generic plot function. (10 Oct 2009)
  17. etas_normal0: New function. Test version of a spatial ETAS conditional intensity function. (12 Oct 2009)
  18. logLik: Fixed bug when using parallel processing on only two nodes. (22 Oct 2009)
  19. Tidied HTML representation of equations in manual pages. Removal ofsynopsison manual pages of functions with multiple forms of usage. (26 Jan 2010)
  20. logLik.mpp,summary.mpp: Changed toinheritsto determine class. (27 Jan 2010)
  21. Phuket: Additional data, until the beginning of 2009, have been added. The magnitude is now the maximum of the body wave and surface wave magnitudes,$m_b$and$M_s$, respectively. Earlier it was simply$m_b$. (01 Feb 2010)
  22. simulate.linksrm,simulate.mpp,logLik.mpp: Inconsistency in nomenclature betweenmarkandmarks, will standardise on the plural. (07 May 2010)
  23. simulate.mpp: Two bugs:use <- (data[, "time"] < TT[1])changed touse <- (data[, "time"] <= tt[1])<="" code="">, andelse data <- data[use, c("time", "magnitude")]changed toelse data <- data[use, ]. (18 Jun 2010)
  24. etas_normal0: Errors in some terms involvingbeta. (18 Jun 2010)
  25. Minor citation and reference inclusion changes to manual pages. (19 Jul 2010)
  26. simulate.mpp: Bug fix on 18 June 2010 induced another bug;data <- rbind(data, newevent)changed todata <- rbind(data[, names(newevent)], newevent). (11 Dec 2010)
  27. Implement very basic NAMESPACE. (5 Nov 2011)
  28. List functions explicitly in NAMESPACE; ``LazyData: no'' and ``ZipData: no'' in DESCRIPTION file. (9 Dec 2011)
  29. logLik.mpp: Enable one to specify the relative CPU speeds of the nodes when parallel processing. (9 Dec 2011)
  30. mppandetas_normal0: Restrict the number of iterations in examples on manual pages to minimise time during package checks. (13 Dec 2011)
  31. residualsandlinksrm: Include example using cusum of residuals on manual page. (15 Dec 2011)
  32. dpareto,dtappareto,ltappareto(etc): Include parameter consistency checks. (6 Jan 2014)
  33. etas_gif: Documentation example error:marks=list(rmagn_mark, rmagn_mark)should bemarks=list(dmagn_mark, NULL). (23 Jan 2014)
  34. linksrm1_gif: Function deleted, alternative discussed on manual page oflinksrm_gif. (19 Mar 2014)
  35. Correct html problem ininst/doc/index.html. (14 Aug 2014)
  36. logLik.mpp: Call toclusterApplychanged tosnow::clusterApply. (20 Aug 2014)
  37. logLik.mpp: The packagesnowhas been superseded byparallel. Changesnowtoparallel, also in fileDESCRIPTION. (15 Oct 2014)
  38. makeSOCKcluster: This function is insnowbut not inparallel. This function points to the closest eqivalent inparallel,makePSOCKcluster.makeSOCKclusterwill eventually become deprecated. Was added to the export list in fileNAMESPACEtoo. (15 Oct 2014)
  39. logLik.mpp,neglogLik: Update consistent with changes fromsnowtoparallel.(17 Oct 2014)

Future Development

  1. Currently spatial versions of the ETAS model are being written and tested.
  2. In the model object, allow one to alternatively specify thenameof the gif function.
  3. Functionlinksrm_gif: Use ofSt1andSt2. Is there a tidier way? Also utilise this feature insrm_gif.
  4. Want a generic function, possibly calledforecast, to produce probability forecasts. This would be based on simulating empirical probability distributions.
  5. Want a function likelinksrm_convertto map between the two main parametrisations of the ETAS model.
  6. Add general forms of the truncated exponential and gamma distributions as marks for the magnitude of the event.
  7. A tidy way to pass the values of thegiffunction into the mark distributions, if required.

References

Cited references are listed on the PtProcess manual page.

Examples

Run this code
#    SRM: magnitude is iid exponential with bvalue=1
#    simulate and calculate the log-likelihood

TT <- c(0, 1000)
bvalue <- 1
params <- c(-1.5, 0.01, 0.8, bvalue*log(10))

#   --- Old Method ---
# x <- pp.sim(NULL, params[1:3], srm.cif, TT, seed=5, magn.sim=1)
# print(pp.LL(x, srm.cif, params[1:3], TT))
# [1] -601.3941

#   --- New Method, no mark density ---
x1 <- mpp(data=NULL,
          gif=srm_gif,
          marks=list(NULL, rexp_mark),
          params=params,
          gmap=expression(params[1:3]),
          mmap=expression(params[4]),
          TT=TT)
x1 <- simulate(x1, seed=5)
print(logLik(x1))

#  An advantage of the object orientated format is that it
#  simplifies further analysis, e.g. plot intensity function:
plot(x1)
#  plot the residual process:
plot(residuals(x1))

#---------------------------------------------------
#    SRM: magnitude is iid exponential with bvalue=1
#    simulate then estimate parameters from data

#   --- Old Method ---
# TT <- c(0, 1000)
# bvalue <- 1
# params <- c(-2.5, 0.01, 0.8)
#
# x <- pp.sim(NULL, params, srm.cif, TT, seed=5, magn.sim=1)
#
# posterior <- make.posterior(x, srm.cif, TT)
#
# neg.posterior <- function(params){
#     x <- -posterior(params)
#     if (is.infinite(x) | is.na(x)) return(1e15)
#     else return(x)
# }
#
# z <- nlm(neg.posterior, params, typsize=abs(params),
#          iterlim=1000, print.level=2)
#
# print(z$estimate)
# [1] -2.83900091  0.01242595  0.78880647

#   --- New Method, no mark density ---
#   maximise only SRM parameters (like old method)

TT <- c(0, 1000)
bvalue <- 1
params <- c(-2.5, 0.01, 0.8, bvalue*log(10))

x1 <- mpp(data=NULL,
          gif=srm_gif,
          marks=list(dexp_mark, rexp_mark),
          params=params,
          gmap=expression(params[1:3]),
          mmap=expression(params[4]),
          TT=TT)
#  note that dexp_mark above is not used below
#  and could alternatively be replaced by NULL

x1 <- simulate(x1, seed=5)

#  maximise only SRM parameters
onlysrm <- function(y, p){
    #  maps srm parameters into model object
    #  the exp rate for magnitudes is unchanged
    y$params[1:3] <- p
    return(y)
}

params <- c(-2.5, 0.01, 0.8)

z1 <- nlm(neglogLik, params, object=x1, pmap=onlysrm,
          print.level=2, iterlim=500, typsize=abs(params))
print(z1$estimate)

Run the code above in your browser using DataLab