Reconstructed State Space
Below is an example of how to create a recurrence network based on a reconstructed state space. We’ll examine the variables restless
and procrast
.
#----------------------
# Adjacency matrix
#----------------------
library(casnet)
<- est_parameters(y = out.cart$restless) p1
<- est_parameters(y = out.cart$procrast) p2
# By passing emRad = NA, a radius will be calculated based on 5% recurrence
<- casnet::rn(y1 = out.cart$restless, emDim = p1$optimDim, emLag = p1$optimLag, emRad = NA)
RN1 ::rn_plot(RN1) casnet
# Get RQA measures
<- casnet::rp_measures(RN1, silent = FALSE) rqa1
>
> ~~~o~~o~~casnet~~o~~o~~~
> Global Measures
> Global Max.points N.points RR Singular Divergence Repetitiveness
> 1 Matrix 14161 887 0.0626 688 0.0084 1.65
>
>
> Line-based Measures
> Lines N.lines N.points Measure Rate Mean Max. ENT ENT_rel CoV
> 1 Diagonal 41 199 DET 0.224 4.85 119 0.115 0.0240 3.76
> 2 Vertical 76 164 V LAM 0.185 2.16 3 0.436 0.0913 0.17
> 3 Horizontal 76 164 H LAM 0.185 2.16 3 0.436 0.0913 0.17
> 4 V+H Total 152 328 V+H LAM 0.185 2.16 3 0.436 0.0913 0.17
>
> ~~~o~~o~~casnet~~o~~o~~~
# Create RN graph
<- igraph::graph_from_adjacency_matrix(RN1, mode="undirected", diag = FALSE)
g1 ::V(g1)$size <- igraph::degree(g1)
igraph<- casnet::make_spiral_graph(g1,
g1r markEpochsBy = weeknum[1:vcount(g1)],
markTimeBy = TRUE)
# Get RN measures
<- rn_measures(g1, silent = FALSE) rn1
>
> ~~~o~~o~~casnet~~o~~o~~~
>
> Global Network Measures
>
> EdgeDensity MeanStrengthDensity GlobalClustering NetworkTransitivity
> 1 0.05469306 NA 0.5443074 0.6294523
> AveragePathLength GlobalEfficiency
> 1 Inf 7.585679
>
> ~~~o~~o~~casnet~~o~~o~~~
# Should be the same
$RR==rn1$graph_measures$EdgeDensity rqa1
> [1] FALSE
TS 2
#----------------------
# Adjacency matrix TS_2
#----------------------
plot(ts(series$TS_2))
# Because these are generated signals, look for a drop in FNN below 1%.
<- est_parameters(y = series$TS_2, nnThres = 1)
p2
<- rn(y1 = series$TS_2, emDim = p2$optimDim, emLag = p2$optimLag, emRad = NA, targetValue = 0.05)
RN2 rn_plot(RN2)
# Get RQA measures
<- rp_measures(RN2, silent = FALSE)
rqa2
# Create RN graph
<- igraph::graph_from_adjacency_matrix(RN2, mode="undirected", diag = FALSE)
g2 V(g2)$size <- degree(g2)
<- make_spiral_graph(g2, arcs = arcs, epochColours = getColours(arcs), markTimeBy = TRUE)
g2r
# Get RN measures
<- rn_measures(g2, silent = FALSE)
rn2
# Should be the same
$RR==rn2$graph_measures$EdgeDensity rqa2
TS 3
#----------------------
# Adjacency matrix TS_3
#----------------------
plot(ts(series$TS_3))
# Because these are generated signals, look for a drop in FNN below 1%.
<- est_parameters(y = series$TS_3, nnThres = 1)
p3
<- rn(y1 = series$TS_3, emDim = p3$optimDim, emLag = p3$optimLag, emRad = NA, targetValue = 0.05)
RN3 rn_plot(RN3)
# Get RQA measures
<- rp_measures(RN3, silent = FALSE)
rqa3
# Create RN graph
<- igraph::graph_from_adjacency_matrix(RN3, mode="undirected", diag = FALSE)
g3 V(g3)$size <- degree(g3)
<- make_spiral_graph(g3,arcs = arcs ,epochColours = getColours(arcs), markTimeBy = TRUE)
g3r
# Get RN measures
<- rn_measures(g3, silent = FALSE)
rn3
# Should be the same
$RR==rn3$graph_measures$EdgeDensity rqa3