## ----------------------------------------------------------------------------- #| label: setup #| echo: false #| eval: true library(wowi) library(mwana) ## ----------------------------------------------------------------------------- #| label: sample-data #| echo: true head(anthro) ## ----------------------------------------------------------------------------- #| label: wrangle-data-with-mwana #| echo: true a <- anthro |> mw_wrangle_wfhz( sex = sex, weight = weight, height = height, .recode_sex = FALSE ) |> define_wasting( zscores = wfhz, oedema = oedema, .by = "zscores" ) |> dplyr::rename( longitude = y, latitude = x ) ## ----------------------------------------------------------------------------- #| label: single-area-set-up #| echo: false ## Set up a temporary directory just for this demo ---- directory <- file.path(withr::local_tempdir(), "input-files") ## ----------------------------------------------------------------------------- #| label: single-area-subset-df #| echo: true ## Filter out one district from the data set ----- d <- subset(a, district == "Kotido") ## ----------------------------------------------------------------------------- #| label: single-area-run-satscan #| echo: true #| eval: false # ## Load rsatscan ---- # library(rsatscan) #<1> # # ## Set up the parameters ---- # results <- ww_run_satscan( # .data = d, # filename = "Kotido", # dir = directory, # sslocation = "/Applications/SaTScan.app/Contents/app", # ssbatchfilename = "satscan", # satscan_version = "10.3.2", # .by_area = FALSE, # .scan_for = "high-low-rates", # .gam_based = "wfhz", # area = NULL, # latitude = latitude, # longitude = longitude, # cleanup = TRUE, # verbose = FALSE # ) ## ----------------------------------------------------------------------------- #| label: single-area-show-files #> [1] "Kotido.cas" "Kotido.clustermap.html" "Kotido.col.prj" #> [4] "Kotido.ctl" "Kotido.geo" "Kotido.gis.prj" #> [7] "Kotido.gis.shp" "Kotido.gis.shx" "Kotido.prm" ## ----------------------------------------------------------------------------- #| label: single-area-show-txt #> [1] " _____________________________" #> [2] "" #> [3] " SaTScan v10.3.2" #> [4] " _____________________________" #> [5] "" #> [6] "results" #> [7] "" #> [8] "Program run on: Sat Aug 2 16:20:17 2025" #> [9] "" #> [10] "Purely Spatial analysis" #> [11] "scanning for clusters with high or low rates" #> [12] "using the Bernoulli model." #> [13] "_______________________________________________________________________________________________" #> [14] "" #> [15] "SUMMARY OF DATA" #> [16] "" #> [17] "Study period.......................: 2025/08/02 to 2025/08/02" #> [18] "Number of locations................: 36" #> [19] "Total population...................: 333" #> [20] "Total number of cases..............: 26" #> [21] "Percent cases......................: 7.8" #> [22] "_______________________________________________________________________________________________" #> [23] "" #> [24] "CLUSTERS DETECTED" #> [25] "" #> [26] "1.Location IDs included.: 10, 9" #> [27] " Coordinates / radius..: (34.113909 N, 3.087933 E) / 1.20 km" #> [28] " Span..................: 1.20 km" #> [29] " Population............: 25" #> [30] " Number of cases.......: 6" #> [31] " Expected cases........: 1.95" #> [32] " Observed / expected...: 3.07" #> [33] " Relative risk.........: 3.70" #> [34] " Percent cases in area.: 24.0" #> [35] " Log likelihood ratio..: 3.458213" #> [36] " P-value...............: 0.55" #> [37] "" #> [38] "2.Location IDs included.: 2, 3, 1" #> [39] " Coordinates / radius..: (33.930353 N, 3.172303 E) / 4.00 km" #> [40] " Span..................: 5.88 km" #> [41] " Population............: 35" #> [42] " Number of cases.......: 0" #> [43] " Expected cases........: 2.73" #> [44] " Observed / expected...: 0" #> [45] " Relative risk.........: 0" #> [46] " Percent cases in area.: 0" #> [47] " Log likelihood ratio..: 3.013494" #> [48] " P-value...............: 0.68" ## ----------------------------------------------------------------------------- #| label: single-area-show-df ## # A tibble: 2 × 18 ## survey_area nr_EAs total_children total_cases `%_cases` location_ids geo radius span children n_cases expected_cases observedExpected relative_risk ## ## 1 District 36 532 104 19 23,24,26,25,3… 13.6… 1.43 … 1.88… 170 4 33.2 0.12 0.085 ## 2 District 36 532 104 19 16,20,14,12,1… 13.8… 26.24… 43.5… 258 84 50.4 1.67 4.46 ## # ℹ 4 more variables: `%_cases_in_area` , log_lik_ratio , pvalue , ipc_amn ## ----------------------------------------------------------------------------- #| label: multiple-area-subset-df #| echo: true ## Filter out two districts ----- ds <- subset(a, district == "Kotido" | district == "Abim") ## ----------------------------------------------------------------------------- #| label: multiple-area-run-satscan #| echo: true #| eval: false # ## Set up the parameters ---- # multiple_area <- ww_run_satscan( # .data = ds, # filename = NULL, # dir = directory, # sslocation = "/Applications/SaTScan.app/Contents/app", # ssbatchfilename = "satscan", # satscan_version = "10.3.2", # .by_area = TRUE, # .scan_for = "high-low-rates", # .gam_based = "wfhz", # latitude = latitude, # longitude = longitude, # area = district, # cleanup = TRUE, # verbose = FALSE # ) ## ----------------------------------------------------------------------------- #| label: multiple-area-show-files #> [1] "Abim.cas" "Abim.clustermap.html" "Abim.col.prj" #> [4] "Abim.ctl" "Abim.geo" "Abim.gis.prj" #> [7] "Abim.gis.shp" "Abim.gis.shx" "Abim.prm" #> [10] "Kotido.cas" "Kotido.clustermap.html" "Kotido.col.prj" #> [13] "Kotido.ctl" "Kotido.geo" "Kotido.gis.prj" #> [16] "Kotido.gis.shp" "Kotido.gis.shx" "Kotido.prm" ## ----------------------------------------------------------------------------- #| label: multiple-area-show-df #> # A tibble: 8 × 19 #> survey_area nr_EAs total_children total_cases `%_cases` location_ids geo #> #> 1 Kotido 36 333 26 7 10,9 34.1… #> 2 Kotido 36 333 26 7 2,3,1 33.9… #> 3 Kotido 36 333 26 7 15 34.1… #> 4 Kotido 36 333 26 7 28,30 34.0… #> 5 Abim 31 223 15 6 111,116,117,112… 33.6… #> 6 Abim 31 223 15 6 135,136,137,133 33.9… #> 7 Abim 31 223 15 6 127,129,128,130 33.8… #> 8 Abim 31 223 15 6 126,143,131 33.7… #> # ℹ 12 more variables: radius , span , children , n_cases , #> # expected_cases , observedExpected , relative_risk , #> # `%_cases_in_area` , log_lik_ratio , pvalue , ipc_amn , #> # area