Code - Note 3"

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(gremes)

Load the data.

#load("~/gremes/data/SeineData.RData")
data("SeineData", package = "gremes")

head(Seine)

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.

seg<- graph(c(1,2,
              2,3,
              2,4,
              4,5,
              5,6,
              5,7), directed = FALSE)
name_stat<- c("Paris", "2", "Meaux", "Melun", "5", "Nemours", "Sens")
seg<- set.vertex.attribute(seg, "name", V(seg), name_stat) # 

Extract the nodes for which we do not observe realizations.

tobj<- Tree(seg, Seine)
Uc<- getNoDataNodes(tobj)

Alternatively just do it manually.

Uc<- c("2", "5")

Create the set of coordinates, in this case only vectors with two non-zero entries.

tup<- Tuples()
x<- rep(1,5)
names(x)<- getNodesWithData(tobj)
tup<- evalPoints(tup, tobj, x)

Estimate ECE Version 1

eks<- EKS(seg)
eks<-estimate(eks, Seine, tup, k_ratio=0.2)

Estimate ECE Version 2

To apply ECE Version 2 we need to create subsets for local estimation. Create the subsets.

subs<- Neighborhood()
subs<- subset(subs, 2, seg, Uc) # neighborhood of level two

Call the estimation method.

eks_part<- EKS_part(seg)
eks_part<- suppressMessages(estimate(eks_part, Seine, subs, k_ratio=0.2, xx=x))

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.

eks$depParams
eks_part$depParams


Try the gremes package in your browser

Any scripts or data that you put into this service are public.

gremes documentation built on Feb. 16, 2023, 8:06 p.m.