# devtools::load_all("~/gremes", export_all=FALSE)
library(gremes)
Load the data.
#load("~/gremes/data/SeineData.RData")
data("SeineData", package = "gremes")
head(Seine)
#> Paris Meaux Melun Nemours Sens
#> 1 2.124338 -1.736640 9.0907845 0.5187825 14.26062
#> 2 9.646991 2.632994 8.7440743 0.6394548 15.47040
#> 3 19.172176 21.584171 9.1692941 2.1770178 15.26537
#> 4 5.357301 -14.759895 -0.4941262 1.5233623 13.47500
#> 5 6.044298 -20.772417 1.0182723 2.1690976 13.39804
#> 6 3.805912 -40.779572 -7.3982814 1.2666607 14.60144
Generate the graph and name the nodes. Assigning names to nodes is crucial. The names of the nodes should correspond to the names of the columns in the dataset.
graph(c(1,2,
seg<-2,3,
2,4,
4,5,
5,6,
5,7), directed = FALSE)
c("Paris", "2", "Meaux", "Melun", "5", "Nemours", "Sens")
name_stat<- set.vertex.attribute(seg, "name", V(seg), name_stat) seg<-
Create a list of subsets on the node set. These sets should cover all the vertex set, but every two subsets are allowed to have at most one node in common.
list(c("Paris", "2", "Meaux", "Melun"), c("Melun", "5", "Nemours", "Sens")) subs<-
In addition to this we require that within the induced subgraph of a given subset all edge parameters are identifiable. This is key in this estimator. We can check this requirement with the function is_identifiable
. To use this function we need however to create an object of class RootDepSet
and an object of class Tree
. If it is clear that the criterion is satisfied there is no need from this step and the two additional objects created below.
RootDepSet()
rdsobj<- setRootDepSet(rdsobj, subs, c("Paris", "Melun"))
rdsobj<-#> From setRootDepSet.RootDepSet: The order of the subset must correspond to the
#> order of its corresponding root
Tree(seg, Seine)
tobj<-#> From validate.Network: Edges have been assigned names
#> From validate.Network: There are nodes with latent variables
#> From validate.Network: Edges have been assigned names
#> From validate.Network: There are nodes with latent variables
is_identifiable(rdsobj, tobj)
Since we get no messages from the function is_identifiable
the identifiability criterion is satisfied.
Estimate using the cliquewise likelihood method of Engelke and Hitz (2020).
EngHitz(seg)
ehobj<-#> From HRMnetwork: Edges have been assigned names
suppressMessages(estimate(ehobj, Seine, subs, k_ratio=0.2))
ehobj<-$depParams
ehobj#> e1 e2 e3 e4 e5 e6
#> 0.3653028 1.0398823 0.5751127 0.6949520 1.0905722 0.6667259
Messages are suppressed.
Engelke, Sebastian, and Adrien S. Hitz. 2020. “Graphical Models for Extremes.” J. R. Statist. Soc. B 82 (3): 1–38.