Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8a46acd

Browse files
authored
Merge pull request#927 from SpatLyu/v2.0
rebuild vignettes
2 parentsb4cca38 +b7a1ccc commit8a46acd

File tree

6 files changed

+44
-28
lines changed

6 files changed

+44
-28
lines changed

‎man/figures/gccm/fig1-1.png‎

480 Bytes
Loading

‎man/figures/gccm/fig2-1.png‎

-249 Bytes
Loading

‎man/figures/gcmc/fig1-1.png‎

393 Bytes
Loading

‎vignettes/main3_gccm.Rmd‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
title:"Geographical Convergent Cross Mapping"
33
author:"Wenbo Lv"
44
date:|
5-
| Last update: 2025-11-25
6-
| Last run: 2025-12-01
5+
| Last update: 2025-12-15
6+
| Last run: 2025-12-15
77
output:rmarkdown::html_vignette
88
vignette:>
99
%\VignetteIndexEntry{3. Geographical Convergent Cross Mapping}
@@ -81,7 +81,7 @@ where $\rho_{x \to y}$ is the correlation after convergence, used to measure the
8181

8282
##Usage examples
8383

84-
###An exampleof spatiallattice data
84+
###Exampleof spatialvector data
8585

8686
Load the`spEDM` package and its county-level population density data:
8787

@@ -143,7 +143,7 @@ pd_res = spEDM::gccm(data = popd_sf, cause = "pre", effect = "popd",
143143
E= c(3,9),k=12,nb=popd_nb,progressbar=FALSE)
144144
endTime= Sys.time()
145145
print(difftime(endTime,startTime,units="mins"))
146-
## Time difference of2.147843 mins
146+
## Time difference of1.867319 mins
147147
pd_res
148148
## libsizes pre->popd popd->pre
149149
## 1 100 0.1199174 0.03313697
@@ -174,7 +174,7 @@ plot(pd_res, xlimits = c(0, 2800), draw_ci = TRUE) +
174174

175175
<br>
176176

177-
###An exampleof spatialgrid data
177+
###Exampleof spatialraster data
178178

179179
Load the`spEDM` package and its farmland NPP data:
180180

@@ -235,11 +235,11 @@ Run GCCM:
235235
startTime= Sys.time()
236236
npp_res=spEDM::gccm(data=npp,cause="pre",effect="npp",
237237
libsizes=matrix(rep(seq(10,130,20),2),ncol=2),
238-
E= c(2,10),k=12,lib=nnaindice,pred=predindice,
238+
E= c(2,10),k=12,lib=nnaindice,pred=predindice,
239239
progressbar=FALSE)
240240
endTime= Sys.time()
241241
print(difftime(endTime,startTime,units="mins"))
242-
## Time difference of1.097801 mins
242+
## Time difference of0.9425755 mins
243243
npp_res
244244
## libsizes pre->npp npp->pre
245245
## 1 10 0.1235069 0.1061684

‎vignettes/main4_gpc.Rmd‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
title:"Geographical Pattern Causality"
33
author:"Wenbo Lv"
44
date:|
5-
| Last update: 2025-11-25
6-
| Last run: 2025-12-01
5+
| Last update: 2025-12-15
6+
| Last run: 2025-12-15
77
output:rmarkdown::html_vignette
88
vignette:>
99
%\VignetteIndexEntry{4. Geographical Pattern Causality}
@@ -67,7 +67,7 @@ where $\bowtie$ encodes positive, negative, or dark matching rules.
6767

6868
##Usage examples
6969

70-
###An exampleof spatiallattice data
70+
###Exampleof spatialvector data
7171

7272
Load the`spEDM` package and its columbus spatial analysis data:
7373

@@ -268,7 +268,7 @@ plot(crime_convergence, ylimits = c(-0.01,1),
268268

269269
<br>
270270

271-
###An exampleof spatialgrid data
271+
###Exampleof spatialraster data
272272

273273
Load the`spEDM` package and its farmland NPP data:
274274

‎vignettes/main5_gcmc.Rmd‎

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
title:"Geographical Cross Mapping Cardinality"
33
author:"Wenbo Lv"
44
date:|
5-
| Last update: 2025-11-20
6-
| Last run: 2025-12-01
5+
| Last update: 2025-12-15
6+
| Last run: 2025-12-15
77
output:rmarkdown::html_vignette
88
vignette:>
99
%\VignetteIndexEntry{5. Geographical Cross Mapping Cardinality}
@@ -25,7 +25,7 @@ To measure causal strengths from spatial cross-sectional data, GCMC (Geographica
2525

2626
##Usage examples
2727

28-
###An exampleof spatiallattice data
28+
###Exampleof spatialvector data
2929

3030
Load the`spEDM` package and its county-level population density data:
3131

@@ -80,27 +80,35 @@ spEDM::fnn(popd_sf, "popd", E = 1:15, eps = stats::sd(popd_sf$popd) / 10)
8080

8181
The false nearest neighbours (FNN) ratio decreased to approximately 0.3 when the embedding dimension E reached 10, and remained relatively stable thereafter. Therefore, we adopted $E = 10$ as the embedding dimension for subsequent GCMC analysis.
8282

83+
Adopt an empirical k value derived from the square root of the product of embedding dimension and number of prediction samples:
84+
85+
86+
```r
87+
ceiling(sqrt(10* nrow(popd_sf)))
88+
## [1] 168
89+
```
90+
8391
Then, run GCMC:
8492

8593

8694
```r
8795
# temperature and population density
88-
g1=spEDM::gcmc(popd_sf,"tem","popd",E=10,k=200,nb=popd_nb,progressbar=FALSE)
96+
g1=spEDM::gcmc(popd_sf,"tem","popd",E=10,k=168,nb=popd_nb,progressbar=FALSE)
8997
g1
9098
## neighbors tem->popd popd->tem
91-
## 1200 0.5754 0.08985
99+
## 1168 0.6186579 0.1063634
92100

93101
# elevation and population density
94-
g2=spEDM::gcmc(popd_sf,"elev","popd",E=10,k=200,nb=popd_nb,progressbar=FALSE)
102+
g2=spEDM::gcmc(popd_sf,"elev","popd",E=10,k=168,nb=popd_nb,progressbar=FALSE)
95103
g2
96104
## neighbors elev->popd popd->elev
97-
## 1200 0.2675 0.077025
105+
## 1168 0.3006307 0.09279337
98106

99107
# elevation and temperature
100-
g3=spEDM::gcmc(popd_sf,"elev","tem",E=10,k=200,nb=popd_nb,progressbar=FALSE)
108+
g3=spEDM::gcmc(popd_sf,"elev","tem",E=10,k=168,nb=popd_nb,progressbar=FALSE)
101109
g3
102110
## neighbors elev->tem tem->elev
103-
## 1200 0.224925 0.4775
111+
## 1168 0.2424178 0.5001772
104112
```
105113

106114
Here we define two functions to process the results and plot the causal strengths matrix.
@@ -174,13 +182,13 @@ res1 = list(g1,g2,g3) |>
174182
purrr::map(.process_xmap_result)|>
175183
purrr::list_rbind()
176184
res1
177-
## cause effectcs sig
178-
## 1 tem popd 0.575400 1.861243e-02
179-
## 2 popd tem 0.089850 5.082649e-115
180-
## 3 elev popd 0.267500 9.449794e-16
181-
## 4 popd elev 0.077025 2.308728e-147
182-
## 5 elev tem 0.224925 1.985034e-23
183-
## 6 tem elev 0.477500 4.965603e-01
185+
## cause effect cs sig
186+
## 1 tem popd 0.61865788 6.192749e-04
187+
## 2 popd tem 0.10636338 2.155996e-74
188+
## 3 elev popd 0.30063067 1.757118e-09
189+
## 4 popd elev 0.09279337 7.741115e-95
190+
## 5 elev tem 0.24241780 1.674870e-16
191+
## 6 tem elev 0.50017715 9.961254e-01
184192
```
185193

186194
Visualize the result:
@@ -194,7 +202,7 @@ plot_cs_matrix(res1)
194202

195203
<br>
196204

197-
###An exampleof spatialgrid data
205+
###Exampleof spatialraster data
198206

199207
Load the`spEDM` package and its farmland NPP data:
200208

@@ -256,6 +264,14 @@ spEDM::fnn(npp, "npp", E = 1:25, lib = predindice, pred = predindice,
256264

257265
At $E = 18$, the false nearest neighbor ratio stabilizes at 0.10 and remains constant thereafter. Therefore, $E = 18$ is selected for the subsequent GCMC analysis.
258266

267+
Adopt an empirical k value derived from the square root of the product of embedding dimension and number of prediction samples:
268+
269+
270+
```r
271+
ceiling(sqrt(18*1500))
272+
## [1] 165
273+
```
274+
259275

260276
```r
261277
# precipitation and npp

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp