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<-
Extract the nodes for which we do not observe realizations.
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
getNoDataNodes(tobj) Uc<-
Alternatively just do it manually.
c("2", "5") Uc<-
Create the set of coordinates, in this case only vectors with two non-zero entries.
Tuples()
tup<- rep(1,5)
x<-names(x)<- getNodesWithData(tobj)
evalPoints(tup, tobj, x) tup<-
EKS(seg)
eks<-#> From HRMnetwork: Edges have been assigned names
estimate(eks, Seine, tup, k_ratio=0.2)
eks<-#> From validate.Network: There are nodes with latent variables
#> From validate.Network: There are nodes with latent variables
#> From setParams.HRMtree: Names have been attributed to the vector 'value' in the order corresponding to the order of the edges: The fist element has the name of the first edge, the second element the name of the second edge, etc.
#> From setParams.HRMtree: The parameters have been attached to the edges according to their names
To apply ECE Version 2 we need to create subsets for local estimation. Create the subsets.
Neighborhood()
subs<- subset(subs, 2, seg, Uc) # neighborhood of level two subs<-
Call the estimation method.
EKS_part(seg)
eks_part<-#> From HRMnetwork: Edges have been assigned names
suppressMessages(estimate(eks_part, Seine, subs, k_ratio=0.2, xx=x)) eks_part<-
Because the method gives many messages we suppress them. The messages are informative. They inform you about certain things but as long as they do not stop the estimation they are not errors.
Compare estimates from the two versions.
$depParams
eks#> e1 e2 e3 e4 e5 e6
#> 0.6998687 1.2696199 0.2228986 0.5155293 1.1730987 0.9649355
$depParams
eks_part#> e1 e2 e3 e4 e5 e6
#> 0.6430240 1.2985508 0.4067386 0.6610828 1.1893985 0.9446311