Six case studies and downloads

  1. African under-five mortality
  2. COVID-19 in China
  3. Hepatitis B in the United States
  4. US suicide: binary and count
  5. US suicide: 2016 spatial analysis
  6. Global health-adjusted life expectancy
BSTVC DESKTOP · V2 · 26.10.25

See where and when
each factor matters

The BSTVC Desktop V2 user guide: spatiotemporal regression without writing code. Six real case studies take you step by step — what to click, why, and what you should see — and finish with publication-ready figures.

Windows 10 / 116 case studies · 7 modelsReproducible resultsPublication-ready figures
⚠ One rule before you start: keep the software, data, maps and results in folders whose paths contain only English letters, digits and underscores (your Windows user name too).

How to use this guide

1 UnderstandWhat it answers · V2 2 WorkflowPrepare data · 5 steps 3 Case studiesFollow the closest one 4 FiguresRead · publish · explore 5 ReferenceTables · help · links
Five stops. The main text gives you what you need; blocks marked Advanced are folded and can be skipped on a first read.

Conventions: a numbered badge 1 on a screenshot matches the step with the same number; In plain words boxes explain an idea in one sentence; concept cards explain each new idea in five parts (in one line · an analogy · why it matters · how to use it · how to explain it). The numbers under “Expected results” match the result tables in the case folders; your own run may differ in the third or fourth significant digit.

10-minute quick start: run case 1 end to end

1Install & open 2Data Input 3Data Check 4Model 5Download & plot
Every case follows these five steps. If your table has one column per time point (a wide table), run Data Conversion once before step 2 (cases 2 and 3).
  1. Download and install V2 from the official website, then double-click the desktop icon (the first start can take a few seconds to half a minute).
  2. Data Input: data file Case-01-Continuous-Africa-U5MR\africa_u5mr_panel.csv; select all four africa_countries_v2 map files at once → Load and Validate Input → you should see 1008 rows, 10 columns and 48 map units.
  3. Data Check: time field year, space field iso3 → Run Check → the result card reads “Automatically Rearranged”.
  4. BSTVC modeling: Data Source “Checked Data”, Y U5MR, X urban_pop, PM25_exposure, pop_million, Response Type “Continuous”, Standardize “Yes”, Threads 20 → Run Model; it finishes in under 15 seconds.
  5. Download All Tables, then run the R script in the case folder to get publication-ready figures (see case 1).

Like cooking: lay out the ingredients (Data Input), check them against the recipe (Data Check), cook (Model), then plate up (download and plot).

PART 1Meet BSTVC V2

1  What BSTVC answers — shown with a real result

An ordinary regression gives each factor one coefficient, as if it worked the same way everywhere and every year. BSTVC lets that coefficient differ by area and by time point, so it answers three questions:

Where
How strong each factor is, and in which direction, in every area (spatial coefficients).
When
At which time points each factor acts more or less strongly than usual (temporal coefficients).
Which matters most
Each factor’s share of the spatiotemporal variation in the outcome, split into a spatial and a temporal part (STVPI).

Here are real results from case 1 (under-five mortality in 48 African countries, 2000–2020). Each figure answers one question:

Where: spatial coefficient maps of three factors. The same factor raises under-five mortality in some countries (red) and lowers it in others (blue).
Where: spatial coefficient maps of three factors. The same factor raises under-five mortality in some countries (red) and lowers it in others (blue).
When: temporal coefficients. The dashed line is the 21-year average; the urban-population effect was stronger than average in the first decade and weaker in the second.
When: temporal coefficients. The dashed line is the 21-year average; the urban-population effect was stronger than average in the first decade and weaker in the second.
Which matters most: STVPI. Population size and urbanisation contribute most, almost entirely through differences between countries.
Which matters most: STVPI. Population size and urbanisation contribute most, almost entirely through differences between countries.

Urbanisation relates to child mortality very differently from one country to the next, while the relationship barely changed over 20 years — so policy should be tailored by place. BSTVC computes and maps conclusions like this directly from your data.

Concept card · Local regression coefficientthe core of BSTVC
In one line
A regression coefficient says how much Y changes when X changes; BSTVC estimates one for every area and every time point — a “local” coefficient.
Analogy
The same rainfall (X) raises rivers more in the mountains than on the plains, and more in the wet season than the dry season. “How much the river rises” varies by place and season.
Why it matters
A single global coefficient averages away the fact that a factor matters a lot in some places and hardly at all in others, which leads to one-size-fits-all policy.
How to use it
Look at two tables: space.coefficients (by area) and time.coefficients (by time point). The full effect in one area at one time = its spatial coefficient + that time point’s temporal coefficient.
Say it to others
“BSTVC tells you not only whether a factor matters, but where and when it matters more.”

1.1  Three outcome types, two models

Your outcome Y is…Response TypeExampleFollow case
A positive continuous value (rate, life expectancy, concentration)ContinuousUnder-five mortality, healthy life expectancy1, 6
Only 0 / 1 (occurred or not)BinaryOutbreak in a month or not2, 4a, 5
A non-negative integer (a count)CountCases, deaths3, 4b

Data with several time points use BSTVC modeling; a single time point (one year, one census) uses BSVC modeling (case 5). All computation runs on your own computer; your data are never uploaded.

2  What V2 improves — shown with results

98–100%median narrowing of the 95% credible intervals of temporal coefficients across the six cases
39–98%median narrowing of the 95% credible intervals of spatial coefficients
Unchangedinterface, workflow, the nine parameters, and the names and columns of the six result tables
Clearersame data, same settings: V2 gives much narrower coefficient ranges, so conclusions are easier to read
Same data and settings: temporal coefficients and 95% credible intervals in V1 (orange) and V2 (blue). Each row shares one y-axis scale — the V2 bands are far narrower.
Same data and settings: temporal coefficients and 95% credible intervals in V1 (orange) and V2 (blue). Each row shares one y-axis scale — the V2 bands are far narrower.

The figure takes one factor from each of three cases: the median interval width for mean temperature (COVID case) shrinks from about 19 to 1.4, for the uninsured rate (hepatitis B case) from about 102 to 0.87, and for maternal mortality (HALE case) from 2.4 to 0.026. All cases, side by side:

CaseTemporal interval, median narrowingSpatial interval, median narrowingDIC V1 → V2WAIC V1 → V2R² / AUC V1 → V2
1 Africa U5MR (3 X)99.2% (63/63)89.4% (144/144)8,365.4 → 8,369.38,372.8 → 8,370.50.791 → 0.793
1 Africa (7 X, 4 with gaps)99.3% (147/147)85.4% (336/336)6,742.6 → 6,724.58,364.4 → 8,595.60.899 → 0.901
2 China COVID-1997.8% (72/72)90.4% (186/186)298.2 → 391.2297.2 → 568.40.950 → 0.938
3 US hepatitis B99.1% (48/48)98.2% (20/20)538.1 → 520.9564.3 → 521.50.983 → 0.992
4a US high suicide (binary)99.7% (52/52)98.1% (196/196)323.4 → 315.0336.0 → 318.90.990 → 0.990
4b US suicide deaths (Standardize = No)99.4% (52/52)92.3% (195/196)6,357.7 → 6,341.46,521.7 → 6,491.80.998 → 0.998
5 BSVC 2016 cross-section— (no temporal part)identical48.9 → 48.950.2 → 50.20.898 → 0.898
6 Global HALE (12 X)98.6% (252/252)39.2% (2051/2124)14,068.8 → 14,162.916,027.4 → 16,154.00.967 → 0.967
6 HALE (6 X)98.7% (126/126)41.9% (1020/1062)22,256.8 → 22,284.024,139.4 → 24,114.90.568 → 0.575

In brackets: narrowed pairs / all paired coefficients. R² for continuous and count outcomes, AUC for binary outcomes; both describe the fit to the same data. V1 = BSTVC Desktop 25.01.28, V2 = 26.10.25, same data and settings.

For the same data, V2 pins down where and when each factor is strong far more precisely, while the overall fit (R², AUC) stays essentially the same as V1.

Concept card · Reading V2 temporal coefficientsV2
In one line
A V2 temporal coefficient tells you how much stronger or weaker a factor is at this time point than its average over the whole study period.
Analogy
Like a weather report saying “2 °C above the long-term average” (an anomaly) rather than “30 °C today”.
Why it matters
The zero line in a temporal-coefficient plot is the period average. Reading this reference correctly stops you from mistaking “weaker than usual” for “no effect”.
How to use it
> 0: more positive than usual at this time point; < 0: more negative. For the full effect in one area in one year, add that area’s spatial coefficient and that year’s temporal coefficient (adding the means is fine).
Say it to others
“V2 temporal coefficients are anomalies: they tell you which years were stronger or weaker than usual.”
Advanced For V1 users: what else differs and what stays the same
  • Interface: the nine pages, buttons and parameters are the same as V1; the About page lists one contact address, bstvc.research@gmail.com; when no custom spatial matrix is uploaded, Data Input states that the default matrix will be used.
  • V1 and V2 temporal coefficients use different reference points, so do not compare the share of “intervals excluding 0” between versions.
  • BSVC (spatial only, case 5) gives identical results in both versions: it has no temporal coefficients, so this update does not affect it.
  • Unchanged: at least two explanatory variables are required; for binary and count models STVPI splits 100% among the factors only (there is no residual term); there is no exposure (offset) option.

For the methodology, see the published BSTVC papers (How to cite).

3  Installation and interface

  1. Download the English V2 installer BSTVC_desktop_EN_win_x64_26.10.25_setup.exe (about 520 MB) from the official website.Optional: verify SHA-256 63c7873b351037de85282ac7da0febbdc6363d3579f4f39bf68b4eeca31ff0b7 to make sure the download is complete.
  2. Double-click to install. By default it goes into your user folder %LOCALAPPDATA%\Programs and puts a shortcut on the desktop.If your Windows user name contains non-English characters, the default path does too — use an English-named account or install to a folder such as D:\BSTVC.
  3. Double-click the desktop icon. On first start the window may stay blank for a few seconds up to half a minute — do not double-click again (each click starts another copy). Start when the Overview page appears.
Overview page: navigation on the left, the three-step workflow on the right (upload data and map → run the data check → model and export result tables).
Overview page: navigation on the left, the three-step workflow on the right (upload data and map → run the data check → model and export result tables).
PageUsed to…Cases
Data InputLoad the modeling table (CSV / Excel) and map (all shapefile parts)All
Data CheckCheck that the area order in the table matches the map, and rearrange automatically if notAll
BSTVC modelingSeveral areas × several time points1, 2, 3, 4, 6
BSVC modelingA single time point5
Data ConversionTurn a wide table (one column per time point) into a long table (one row per area and time)2, 3
Field Conversion · Custom Spatial Matrix · AboutChange field types; build other spatial weight matrices; developers and contact—
Advanced Other pages and resource use
BSVC modeling page (space field only).
BSVC modeling page (space field only).
Field Conversion page.
Field Conversion page.
Custom Spatial Matrix page.
Custom Spatial Matrix page.
About page: feedback address bstvc.research@gmail.com.
About page: feedback address bstvc.research@gmail.com.

The installation takes about 1.2 GB. The largest case in this guide (177 countries × 21 years, 12 explanatory variables) uses about 3.5 GB of memory while running.

PART 2One workflow for every case

4  Prepare your data: five checks before you start

Most failed runs are data problems, not software problems. Get the data right before you open the software.

Wide and long tables
A wide table (left) and a long table (right) hold the same information in different layouts. Modeling needs the long table; the Data Conversion page turns left into right.
  1. Use a long table: one row = one area at one time point (area ID, time, Y, X1, X2…); no (area, time) pair may appear twice. Convert wide tables first.
  2. Write missing values as NA: not blanks, 0 or −999. Y may have gaps (the software returns fitted values you can use to fill them); keep missing X values to a minimum.
  3. Match the outcome type: continuous (positive values), binary (0/1 only), count (non-negative integers). A rate is not a count.
  4. Match the area ID: the table and the map attribute table need an ID field with the same name and type and the same values (the text “21” does not match the number 21).
  5. Load all map files: select .shp .dbf .shx .prj (and .cpg if present) together; note any islands without neighbours (cases 1, 2 and 6 have some).
Concept card · Long (panel) table
In one line
Each row is one area at one time point.
Analogy
Like a grade book where each row is “one student in one exam”, not one row per student with a column per exam.
Why it matters
The model looks at differences between areas and changes over time at once; the long layout keeps both dimensions explicit.
How to use it
Already long (cases 1, 4, 6) → go straight to Data Input; wide (cases 2, 3) → Data Conversion first; one year only (case 5) → BSVC.
Say it to others
“One row per area per time point — that is the standard layout for spatiotemporal models.”

4.1  The nine modeling parameters

ParameterRecommendedCommon mistake
Data SourceIf Data Check reports “Automatically Rearranged” → Checked DataKeeping Raw Data after a rearrangement: results land on the wrong areas, with no error
Response Variable YYour outcomeMixing up rates, people and case counts
Explanatory Variables XChosen by your research question, at least two; note their orderIncluding IDs, time, or the helper columns Code / timeID / spaceID
Response TypeContinuous / Binary / Count (see the table in the previous chapter)Leaving the default (Continuous) for binary or count outcomes
Time FieldYear, month, etc.Selecting it as an X
Space FieldThe ID field shared with the mapPicking a name field instead of the code field
Standardize X VariablesYesInterpreting standardized coefficients as “per one original unit”
Spatial weight matrixDefault QUEEN-B (areas sharing an edge or corner are neighbours)Switching to a custom matrix without checking the ID order
Threads20Assuming more is always faster (no gain beyond about 20)
Concept card · Standardizing explanatory variables
In one line
Express every X as “how many standard deviations above or below its mean”, so all X share one ruler.
Analogy
To compare whether height (cm) or weight (kg) matters more for performance, first express both as “standard deviations above average”.
Why it matters
Only then can coefficients be compared, and only then are STVPI percentages meaningful. Case 4 shows with real results how the percentages shift without standardization (see 4b).
How to use it
Choose “Yes”. A coefficient then means “the change in the outcome when X rises by one standard deviation”.
Say it to others
“To compare which factors matter more, standardize first.”
Concept card · Neighbours (QUEEN spatial weights)
In one line
Two areas that share an edge or a single corner are neighbours; neighbouring coefficients are assumed to be similar.
Analogy
A queen in chess moves straight and diagonally, so squares that only touch at a corner also count as adjacent.
Why it matters
“Near things are more alike”: the model borrows information between neighbours, which stabilises estimates for areas with little data.
How to use it
Keep the default. Islands without neighbours (Hainan, Madagascar, many island states) cannot borrow from neighbours — describe them separately rather than dropping them.
Say it to others
“By default, adjacent areas are assumed to behave alike; islands have no neighbours, so treat their results with extra care.”

5  Five steps through a case

All six cases follow the same workflow; only the data and a few settings differ. This chapter explains what each step should show; each case then covers only what is special about it.

StepPageYou must seeIf not
A Data Conversion
(wide tables only)
Data ConversionA conversion message reporting N rows, N = areas × time points; download as Excel xlsxCheck that every variable has exactly as many columns as time points
B Data InputData Input[OK] Data loaded successfully. [OK] Map loaded successfully.; three boxes: Rows, Columns, Map UnitsMap fails to load: a map file is missing
C Data CheckData CheckResult card “Automatically Rearranged” → choose Checked Data for modelingAn “Error” line in the grey log followed by “Success!” is normal; go by the card title
D Model & downloadBSTVC / BSVC modelingStatus line “BSTVC model completed … Currently available: 6 result tables.” → Download All TablesA greyed-out window means it is still computing; do not switch pages (see Troubleshooting)
E Read & plotRModel evaluation first, then the coefficient figures (Read & publish figures)—
Concept card · Data Check and “Automatically Rearranged”
In one line
The software reorders the areas in your table to exactly the order of the map.
Analogy
The class register and the seating plan must be in the same order, or Alice’s grade ends up on Bob’s seat.
Why it matters
With the wrong order the model still runs, but results are drawn on the wrong areas — and no error is raised.
How to use it
Run the check every time you change data; if it says “Automatically Rearranged”, choose “Checked Data” on the modeling page. The checked table gains three columns, Code, timeID, spaceID — never use them as X.
Say it to others
“The data check aligns the table with the map — never skip it.”
Concept card · 95% credible interval
In one line
Given these data and this model, the coefficient lies in this range with 95% probability.
Analogy
A forecast of “18–24 °C tomorrow”: the narrower the range, the more confident the forecast.
Why it matters
An estimate alone does not say how reliable it is; the interval tells you how certain you can be.
How to use it
In the result tables, 0.025quant to 0.975quant is the 95% interval and 0.25quant to 0.75quant the 50% interval. Narrower means more certain.
Say it to others
“The narrower the interval, the more certain the conclusion — and V2 makes it much narrower.”
PART 3Six case studies, step by step

6  Choose a case

Six cases and seven models cover three outcome types, two modeling pages and two table layouts. Pick the one closest to your study and follow it.

CaseOutcomePageAreas × time pointsWhat it teachesV2 run time
1 Under-five mortality, AfricaContinuousBSTVC48 × 21 (long)The shortest full workflow; fixing a map errorunder 15 seconds
2 COVID-19 occurrence, ChinaBinaryBSTVC31 × 12 (wide)Data conversion; AUC; islandsunder 15 seconds
3 Acute hepatitis B, United StatesCountBSTVC5 × 12 (wide)Count outcomes; reading results with very few areasunder 15 seconds
4a High suicide-rate status, United StatesBinaryBSTVC49 × 13 (long)Deriving a 0/1 outcome from a continuous indicatorunder 15 seconds
4b Suicide deaths, United StatesCountBSTVC49 × 13 (long)Why standardize; reading model evaluation honestlyunder 15 seconds
5 High suicide-rate status, 2016BinaryBSVC49 × 1 (cross-section)Working with a single time pointunder 15 seconds
6 Healthy life expectancy, globalContinuousBSTVC177 × 21 (long)The largest case; 12 explanatory variablesabout 20 minutes

Run time is the computing time recorded by the software (running_time in model.evaluation); threads 20, default QUEEN matrix, Standardize = Yes.

Tip. First time: case 1 (no conversion, results in seconds). Continuous outcome for a paper: case 1 or 6. Binary: case 2 or 4a. Count: case 3 or 4b. One year of data: case 5.

Every case follows the same order: case card (data, sources, variables) → step by step (screenshots + why) → expected results (the numbers you should get) → interpretation → figures and how to read them (R code + publication figures + reading notes).

7  Case 1 · Continuous: under-five mortality in 48 African countries

The questionHow do urbanisation, PM2.5 exposure and population size relate to under-five mortality across African countries and over 2000–2020?
You will learnThe shortest complete workflow (the data are already a long table); what error an invalid map polygon produces and how to fix it; V2 stays fast with more variables and missing values.

7.1  Case card: data, sources and variables

ItemDetails
FolderCase-01-Continuous-Africa-U5MR
Tableafrica_u5mr_panel.csv: 48 countries × 2000–2020 = 1,008 rows, 10 columns, long table
Mapafrica_countries_v2.shp / .dbf / .shx / .prj (repaired version, 4 files); original_map\africa_countries.* is the unrepaired original, used to show the error
Sources & licencesBoundaries: Natural Earth 1:110m (public domain). Indicators: World Bank Open Data (CC BY 4.0, attribution required); under-five mortality is a UN IGME model estimate
Space / timeiso3 (ISO three-letter code, same name as in the map) / year
YU5MR: deaths under age five per 1,000 live births (no missing values)
X (main run)urban_pop (urban population, %), PM25_exposure (µg/m³), pop_million (population, millions) — all complete
X (extended run)plus GDP_pc (GDP per capita, 5.5% missing), basic_water (basic drinking water, 2.6%), electricity (access to electricity, 1.6%), health_exp (health expenditure, % of GDP, 4.0%)
SettingsContinuous · Checked Data · Standardize = Yes · QUEEN-B · Threads 20

7.2  Step A: Data Input

Case 1 Data Input: after loading, the three boxes show 1008 rows, 10 columns and 48 map units.
Case 1 Data Input: after loading, the three boxes show 1008 rows, 10 columns and 48 map units.
  1. Click Data Input on the left. Under “Modeling Table Data (CSV / Excel)” click Browse… and choose africa_u5mr_panel.csv (1).The table is already “one row per country per year”, so it can be loaded directly.
  2. Under “Modeling Map Data (shapefile)” click Browse… and select all four africa_countries_v2 files at once (hold Shift) (2); the box shows “4 files”.A shapefile is a set of files: .shp holds shapes, .dbf attributes (including iso3), .shx an index, .prj the coordinate system. With one missing the map cannot be read. This map has no .cpg file, so there are four.
  3. Leave “Spatial Weight Matrix” empty (3) and click Load and Validate Input (4).Empty = the default QUEEN adjacency matrix, which is all most studies need.
  4. Check the messages (5): [OK] Data loaded successfully., [OK] Map loaded successfully., [INFO] No custom matrix uploaded…; and the boxes (6): 1008 Rows, 10 Columns, 48 Map Units.1008 = 48 × 21: one row per country per year. 48 equals the number of map units, so table and map cover the same countries.
Tip. The “Map” tab previews the map (below) so you can confirm every polygon was read; the “Data Table” tab shows each field’s type and missing-value rate.
“Map” tab: the preview confirms that 48 African countries were loaded.
“Map” tab: the preview confirms that 48 African countries were loaded.

7.3  Step B: Data Check — and a map that needs repairing

Case 1 Data Check: BSTVC Spatiotemporal Panel, time field year, space field iso3; result “Automatically Rearranged”.
Case 1 Data Check: BSTVC Spatiotemporal Panel, time field year, space field iso3; result “Automatically Rearranged”.
  1. Click Data Check and keep the check type BSTVC Spatiotemporal Panel (1).
  2. Time Field year (2), Space Field iso3 (3), then Run Check (4).You can type into a field box to search: click it, type “ye”, press Enter.
  3. Read the result card (5): Automatically Rearranged. The grey log first shows Error: The number of spatial units per year… and ends with Success! — this is the normal progress of the check.The table is sorted alphabetically by iso3, the map in Natural Earth order; the software reorders the table to match the map.
  4. Remember to choose Checked Data in the next step. Optionally download the checked table (6) for your records.

7.3.1  The error with the original map, and how to fix it

If you load the unrepaired original_map\africa_countries.* in step A, Data Input and Data Check both succeed, but after Run Model the status line turns red:

Modeling with the unrepaired map: the status line shows an error.
Modeling with the unrepaired map: the status line shows an error.
  1. Read the message. Loop 0 is not valid: Edge 0 crosses edge 78 means a polygon boundary crosses itself. Neighbours are computed on the sphere, which rejects polygons that are invalid on the globe.
  2. Find the culprit. In R: sf::sf_use_s2(TRUE); which(!sf::st_is_valid(sf::st_read("africa_countries.shp"))) points to Sudan (SDN), which looks perfectly normal on a flat map.
  3. Repair and save a copy. Snap the coordinates to a 0.001° grid (about 100 m) and repair the geometry: all 48 polygons become valid with no isolated country. Save as africa_countries_v2.* and keep the original untouched.
  4. Start again with the new map: Data Input → Data Check → modeling completes normally.

Sudan’s border has a tiny “knot” that you cannot see on a flat map, but it trips up the software when neighbours are computed on a globe. Straighten the border, save a copy, and it works.

Tip. Before loading any new map, check it in R: sf::sf_use_s2(TRUE); all(sf::st_is_valid(sf::st_read("map.shp"))) must return TRUE.

7.4  Step C: BSTVC modeling

Case 1 parameters: Checked Data, Y = U5MR, three complete X, Continuous, year / iso3, Standardize = Yes, default QUEEN-B, Threads 20.
Case 1 parameters: Checked Data, Y = U5MR, three complete X, Continuous, year / iso3, Standardize = Yes, default QUEEN-B, Threads 20.
  1. Data Source: Checked Data (1).The check rearranged the data; Raw Data would put results on the wrong countries, silently.
  2. Response Variable Y: U5MR (2).
  3. Explanatory Variables X: type and press Enter for urban_pop, PM25_exposure, pop_million (3).Start with three complete X, then add more; never choose iso3, year, Code, timeID, spaceID.
  4. Response Type: Continuous (4).Mortality is a positive continuous value.
  5. Time Field year (5), Space Field iso3 (6).
  6. Standardize X Variables: Yes (7); Spatial weight matrix: Default QUEEN-B (8); Threads: 20 (9).
  7. Click Run Model (10). The page greys out with a “model is running” message and finishes in under 15 seconds.Do not switch pages while it runs; a grey window means it is computing.

7.5  Step D: results and download

Finished: (1) status line “BSTVC model completed. Standardized: urban_pop, PM25_exposure, pop_million. Currently available: 6 result tables.” (2) Result Module (3) Download File Type (4) Download Current Table (5) Download All Tables.
Finished: (1) status line “BSTVC model completed. Standardized: urban_pop, PM25_exposure, pop_million. Currently available: 6 result tables.” (2) Result Module (3) Download File Type (4) Download Current Table (5) Download All Tables.
  1. Check the status line (1): which variables were standardized, and that six result tables are available.
  2. Click Download All Tables (5) and save it as, for example, Case1_Africa_U5MR_all_result_tables.xlsx in an English-only path.One workbook with six sheets. The next run replaces what is on screen, so save after every run.
  3. Browse the tables with Result Module (2); start with model.evaluation.
local.prediction: one row per country and year, with fitted values and intervals, observed y and gap-filled fill_y.
local.prediction: one row per country and year, with fitted values and intervals, observed y and gap-filled fill_y.
STVPI: spatial and temporal shares of each factor, with intervals.
STVPI: spatial and temporal shares of each factor, with intervals.
Expected results. DIC 8,369.3 · WAIC 8,370.5 · LS 4.154 · eff 149.8 · pd2 131.9. Observed vs fitted R² = 0.793 (r = 0.892). STVPI: spatial part 98.3%, temporal part 0.6%, residual 1.1%; by factor (space + time): pop_million 51.5%, urban_pop 43.4%, PM25_exposure 4.0%. Sheets: local.prediction 1008×18, time.coefficients 63×9 (3 variables × 21 years), space.coefficients 48×25.

7.6  Interpretation

Across Africa, urbanisation and population size relate to child mortality very differently from country to country, and these relationships changed little over 20 years — so policy should be tailored by place rather than by period.

Note. The outcome is the estimated under-five mortality rate. Describe the direction and range of the fitted association by location and period.
Advanced Extension: seven X (four with missing values)

Increase X to seven (adding GDP_pc, basic_water, electricity and health_exp, each 1.6–5.5% missing) and keep everything else:

Expected results. About half a minute (the same setting took about 12 minutes in V1). DIC 6,724.5 · WAIC 8,595.6 · eff 51.5 · pd2 986.9 · R² 0.901. STVPI by factor: pop_million 36.7%, basic_water 24.5%, urban_pop 23.4%, GDP_pc 12.4%, health_exp 0.9%, electricity 0.8%, PM25_exposure 0.4%.
While running: the page greys out with a “model is running” message. Do not click other pages.
While running: the page greys out with a “model is running” message. Do not click other pages.
  • DIC and WAIC: 6,725 and 8,596. They are different criteria, so different values are normal; compare like with like.
  • R² rises from 0.793 with three X to 0.901.

7.7  Figures and how to read them

The result workbook can be turned straight into publication figures. The script and the finished figures (300 dpi PNG + vector PDF) are in Case-01-Continuous-Africa-U5MR\visualization\: set R’s working directory to the case folder and run source("visualization/Case1_Africa_U5MR.R").

R code for this case (click to open and copy)
# Case 1: under-five mortality in 48 African countries, 2000-2020 (continuous)
source("visualization/R/bstvc_plot_functions.R"); source("visualization/R/run_case.R")
source("visualization/R/bstvc_local_coef_functions.R"); source("visualization/R/run_local_coef.R")
cfg <- list(lang = "en",
  id = "Case1_Africa_U5MR", title = "Case 1 Africa under-five mortality",
  xlsx = "data/Case1_Africa_U5MR/all_result_tables.xlsx", shp = "data/Case1_Africa_U5MR/africa_countries_v2.shp", key = "iso3",
  data = "data/Case1_Africa_U5MR/model_data.csv",     # modelling table: covariate values for the optional module
  type = "continuous", standardized = TRUE, label_field = "name",
  t0 = 2000, tlab = "Year", time_col = "year", pred_times = c(2000, 2010, 2020), pred_label = "Under-five mortality (per 1,000)",
  var_en = c(urban_pop = "Urban population", PM25_exposure = "PM2.5 exposure", pop_million = "Population"))

run_case(cfg)          # core figures
run_local_coef(cfg)    # optional: SHAP-style local-coefficient figures
Figure 1 · Model evaluation
Figure 1 · Model evaluation
Figure 1 · Model evaluation
How to read
  • Three groups of numbers: goodness of fit (DIC, WAIC), model complexity (eff, pd2) and predictive score (LS).
  • Lower DIC, WAIC and LS are better; compare only models fitted to the same data and the same Y. DIC and WAIC are different criteria, so their values differ.
In this case
  • DIC 8,369.3, WAIC 8,370.5, LS 4.154; eff 149.8, pd2 131.9.
  • Agreement between fitted and observed values: R² = 0.793.
Figure 2 · Temporal coefficients
Figure 2 · Temporal coefficients
Figure 2 · Temporal coefficients
How to read
  • One panel per factor; time on the x-axis; the dashed zero line is the average over the whole study period.
  • Above zero: the factor acts more strongly (more positively) than usual at that time; below zero: more weakly (more negatively).
  • Dark and light bands are the 50% and 95% credible intervals — the narrower, the more certain. Each panel has its own y-axis.
In this case
  • Urban population: from 0.149 to −0.140, falling overall; strongest in 2000, weakest in 2020.
  • Population: from 0.078 to −0.073, falling overall; strongest in 2000, weakest in 2019.
  • PM2.5 exposure: from −0.010 to 0.016, rising overall; strongest in 2014, weakest in 2008.
Figure 3 · Spatial coefficient maps (core)
Figure 3 · Spatial coefficient maps (core)
Figure 3 · Spatial coefficient maps (core)
How to read
  • One map per factor; colour = the area’s spatial coefficient: red raises the outcome, blue lowers it, darker = stronger.
  • Each map has its own classes — read the values in the legend to compare.
  • A spatial coefficient is the area’s average effect over the study period; the full effect in one area at one time = spatial coefficient + that time point’s temporal coefficient.
In this case
  • Population: from −25.60 (Ghana) to 6.86 (eSwatini).
  • Urban population: from −8.78 (Dem. Rep. Congo) to 19.49 (Egypt).
  • PM2.5 exposure: from −1.73 (South Africa) to 0.47 (Egypt).
Figure 3b · Direction-probability maps
Figure 3b · Direction-probability maps
Figure 3b · Direction-probability maps
How to read
  • Colour = the probability that the area’s effect is positive, on a continuous 0–1 scale: deep red = almost surely raises the outcome, deep blue = almost surely lowers it, near white = direction uncertain.
  • Read it with figure 3: figure 3 shows how large the effect is, figure 3b how certain its direction is.
In this case
  • Population: in 25% of areas a positive effect has a probability above 0.8; in 73% a negative effect has a probability above 0.8.
  • Urban population: in 35% of areas a positive effect has a probability above 0.8; in 50% a negative effect has a probability above 0.8.
  • PM2.5 exposure: in 10% of areas a positive effect has a probability above 0.8; in 35% a negative effect has a probability above 0.8.
Figure 4 · Hot and cold spots of spatial coefficients
Figure 4 · Hot and cold spots of spatial coefficients
Figure 4 · Hot and cold spots
How to read
  • Finds clusters of high spatial coefficients (hot spots, red) and low ones (cold spots, blue); grey = no cluster.
  • Answers whether areas where a factor acts especially strongly (or weakly) are contiguous — useful for defining priority regions.
In this case
  • Urban population: 2 hot spots (e.g. Liberia, Ghana), 1 cold spots (e.g. S. Sudan).
  • PM2.5 exposure: 1 hot spots (e.g. Cameroon), 10 cold spots (e.g. Zimbabwe, Botswana, Mozambique).
  • Population: 2 hot spots (e.g. S. Sudan, eSwatini), 2 cold spots (e.g. Liberia, Ghana).
Figure 5 · STVPI: who contributes most
Figure 5 · STVPI: who contributes most
Figure 5 · STVPI panels
How to read
  • Top left (“Overall”): how much of the spatiotemporal variation is spatial and how much temporal.
  • Other panels: each factor’s contribution (space + time, spatial part, temporal part); circles = estimates, thick / thin bars = 50% / 95% credible intervals.
  • Percentages of different factors are comparable only when covariates are standardized.
In this case
  • By factor (space + time): pop_million 51.5%, urban_pop 43.4%, PM25_exposure 4.0%.
  • Where intervals overlap heavily, do not over-interpret the ranking.
Figure 6 · Spatial and temporal shares of each factor
Figure 6 · Spatial and temporal shares of each factor
Figure 6 · STVPI stacked bars
How to read
  • One bar per factor; bar length = total contribution; the two segments = spatial and temporal parts.
In this case
  • The longest bars are the candidate key factors; a dominant spatial segment calls for place-specific action, a visible temporal segment for timing as well.
Figure 7 · Model fit
Figure 7 · Model fit
Figure 7 · Model fit
How to read
  • Observed values on the x-axis, fitted values on the y-axis; the closer to the dashed line, the better.
  • R² closer to 1 is better; RMSE is the typical error in the units of Y.
In this case
  • R² = 0.793, RMSE = 21.40 (1008 observed units).
Figure 8 · Fitted-value maps (several time points, one colour scale)
Figure 8 · Fitted-value maps (several time points, one colour scale)
Figure 8 · Fitted-value maps
How to read
  • Several time points side by side on one colour scale: colour changes are changes over time.
  • Areas and years missing in the data also get fitted values, which can be used to fill gaps.
In this case
  • Compare the first and last time points for the overall trend and any change in the spatial pattern.

Want to dig deeper into the local coefficients of each area? The full set of SHAP-style figures for this case is in the corresponding section of chapter 14.

8  Case 2 · Binary: monthly COVID-19 occurrence in 31 Chinese provinces, 2020 (wide → long)

The questionHow do air quality, temperature, vegetation, night-time light and population movement relate to whether a province had an outbreak in a given month (0/1), and how does this differ between provinces and months?
You will learnTurning a wide table into a long one with Data Conversion; setting up a binary outcome and reading ROC/AUC; interpreting an area without neighbours (Hainan).
Disclaimer. The map of China in this case is for illustration only; for publication, redraw it with an officially approved base map.

8.1  Case card: data, sources and variables

ItemDetails
FolderCase-02-Binary-China-COVID-19 (official example data)
Tablecovid_binary_wide.xlsx, a wide table: 31 rows × 86 columns, columns = variable + year-month (e.g. PM25_202001)
MapChina_Provincial_Map\ChinaProv.* (5 files + .sbn/.sbx)
SourcesNational Health Commission of China (outbreaks), multi-source remote sensing, meteorological and environmental monitoring platforms, Baidu migration data
Space / timegb (provincial administrative code, numeric) / month (1–12, created during conversion)
Youtbreak: whether an outbreak occurred in the month (0 = no, 1 = yes)
X (6)In the official file these six X are already standardized (z-scores, mean 0, SD 1); original units are not provided. PM25, temperature (mean), NDVI, night_light, in_migration, out_migration (the migration indices have blocks of missing values, kept as NA)
SettingsBinary · Checked Data · Standardize = Yes · QUEEN-B · Threads 20

8.2  Step A: Data Conversion (wide → long)

In the wide table each variable has one column per month; conversion stacks them into 31 × 12 = 372 rows.

Data Conversion page with variable 1 filled in: (1) number of variables, 7 (2) name of the converted value column (3) start column (4) end column (5) select by range (6) the 12 selected columns.
Data Conversion page with variable 1 filled in: (1) number of variables, 7 (2) name of the converted value column (3) start column (4) end column (5) select by range (6) the 12 selected columns.
  1. Click Data Conversion. Under “Spatial Cross-sectional Source Data (CSV / Excel)” choose covid_binary_wide.xlsx and click Load Data for Conversion. The preview shows 31 rows; the check card reports a wide table and counts the columns with a time stamp.
  2. ID Columns (constant across time): gb.ID columns are repeated in every row; they are the key that links the table to the map. Do not put the province-name column into a variable block.
  3. Time Sequence (numeric): 1:12; New Time Column Name: month.“1:12” means the new time column takes the values 1, 2, …, 12, matching columns 1–12 of each variable block.
  4. Number of Variables to Convert: 7 (1); seven collapsible variable blocks appear.Six X plus one Y.
  5. Open variable 1 and set the converted column name to PM25 (2).
  6. Start column PM25_202001 (3), end column PM25_202012 (4), then select by range (5). The grey box (6) lists the 12 columns in time order.Columns must run from January to December; if they are not contiguous, pick them one by one in the grey box.
  7. Repeat for the other six variables: temperature, NDVI, night_light, in_migration, outbreak, out_migration. Each variable must have exactly 12 columns.
  8. Click Start Conversion; the result reports a panel of 372 rows and 9 columns (gb + month + 7 variables).
  9. Choose Excel xlsx as the format, click Download Converted Table and save it as BSTVC_panel_converted.xlsx.Excel is the safest format to reopen; CSV works too if your data contain only English characters.
After Start Conversion: the converted table appears on the right and can be downloaded as CSV, Excel xlsx or Excel xls.
After Start Conversion: the converted table appears on the right and can be downloaded as CSV, Excel xlsx or Excel xls.
Note. Conversion only changes the layout; it does not align the area order with the map — you still need the Data Check.

8.3  Step B: Data Input

Case 2 Data Input: 372 rows, 9 columns, 31 map units.
Case 2 Data Input: 372 rows, 9 columns, 31 map units.
  1. Table: the converted BSTVC_panel_converted.xlsx (1), not the original wide table.
  2. Map: all ChinaProv files (2), then Load and Validate Input (4).
  3. Check: 372 rows, 9 columns, 31 map units (6).

8.4  Step C: Data Check

Case 2 Data Check: time month, space gb, result “Automatically Rearranged”.
Case 2 Data Check: time month, space gb, result “Automatically Rearranged”.

Time Field month, Space Field gb → Run Check → card title Automatically Rearranged → choose Checked Data for modeling.

8.5  Step D: modeling and download

Case 2 parameters: note (4) — the Response Type must be changed to Binary.
Case 2 parameters: note (4) — the Response Type must be changed to Binary.
  1. Data Source Checked Data (1); Y outbreak (2); X, the six variables PM25, temperature, NDVI, night_light, in_migration, out_migration (3).
  2. Response Type = Binary (4) — do not leave the default “Continuous”.The outcome is only 0 or 1.
  3. Time month (5), space gb (6), Standardize = Yes, QUEEN-B, Threads 20, then Run Model (10); it finishes in under 15 seconds.
  4. Download All Tables.
Finished: the status line lists the six standardized variables and six available result tables.
Finished: the status line lists the six standardized variables and six available result tables.
Expected results. DIC 391.1 · WAIC 568.2 · LS 1.201 · eff 72.5 · pd2 149.2. AUC = 0.938 (372 province-months). STVPI (no residual for binary outcomes): spatial part 74.1%, temporal part 25.9%; by factor: night_light 39.0%, PM25 23.3%, temperature 11.6%, NDVI 7.4%, in_migration 6.7%, out_migration 6.5%. time.coefficients 72 rows (6 × 12), space.coefficients 31 rows.
Concept card · AUC (accuracy for binary outcomes)
In one line
Pick one province-month with an outbreak and one without at random: AUC is the probability that the model scores the first one higher.
Analogy
Asking the model to rank two students: AUC = 0.95 means it gets the order right 95 times out of 100.
Why it matters
R² does not suit 0/1 outcomes, and AUC does not depend on whether you set the cut-off at 0.5 or 0.3.
How to use it
0.5 = guessing, 0.7–0.8 acceptable, above 0.9 very good. It is computed on the fitted data, not on new data.
Say it to others
“An AUC of 0.94 means the model separates outbreak and non-outbreak province-months very well.”
Technical note: AUC is the area under the ROC curve, equal to the Mann–Whitney rank statistic; here it is computed from predict_y (fitted probability) against observed y in local.prediction.

8.6  Interpretation

Outbreaks were most strongly associated with night-time light (economic activity and crowding), and the associations clearly changed during the year. Hainan is an “island” without neighbours, so its result should be read on its own.

Note. DIC and WAIC are different criteria, so different values are normal. Repeated runs with the same input give the same result.

8.7  Figures and how to read them

The result workbook can be turned straight into publication figures. The script and the finished figures (300 dpi PNG + vector PDF) are in Case-02-Binary-China-COVID-19\visualization\: set R’s working directory to the case folder and run source("visualization/Case2_COVID.R").

R code for this case (click to open and copy)
# Case 2: monthly COVID-19 occurrence in 31 Chinese provinces, 2020 (binary). Map for illustration only.
source("visualization/R/bstvc_plot_functions.R"); source("visualization/R/run_case.R")
source("visualization/R/bstvc_local_coef_functions.R"); source("visualization/R/run_local_coef.R")
cfg <- list(lang = "en",
  id = "Case2_COVID", title = "Case 2 COVID-19 occurrence",
  xlsx = "data/Case2_COVID/all_result_tables.xlsx", shp = "data/Case2_COVID/ChinaProv.shp", key = "gb",
  data = "data/Case2_COVID/model_data.xlsx", wide = list(suffix = sprintf("_2020%02d", 1:12), times = 1:12),
  type = "binary", standardized = TRUE, label_field = "name",
  t0 = 1, tlab = "Month (2020)", time_col = "month", pred_times = c(1, 3, 5, 7, 9, 11), time_labels = setNames(month.abb, 1:12),
  pred_label = "Fitted probability",
  map_note = "Note: map for illustration only; redraw with an officially approved base map for publication.",
  var_en = c(PM25 = "PM2.5", temperature = "Mean temperature", NDVI = "NDVI", night_light = "Night-time light",
             in_migration = "In-migration index", out_migration = "Out-migration index"))

run_case(cfg)          # core figures
run_local_coef(cfg)    # optional: SHAP-style local-coefficient figures
Figure 1 · Model evaluation
Figure 1 · Model evaluation
Figure 1 · Model evaluation
How to read
  • Three groups of numbers: goodness of fit (DIC, WAIC), model complexity (eff, pd2) and predictive score (LS).
  • Lower DIC, WAIC and LS are better; compare only models fitted to the same data and the same Y. DIC and WAIC are different criteria, so their values differ.
In this case
  • DIC 391.1, WAIC 568.2, LS 1.201; eff 72.5, pd2 149.2.
  • Agreement between fitted and observed values: AUC = 0.938.
Figure 2 · Temporal coefficients
Figure 2 · Temporal coefficients
Figure 2 · Temporal coefficients
How to read
  • One panel per factor; time on the x-axis; the dashed zero line is the average over the whole study period.
  • Above zero: the factor acts more strongly (more positively) than usual at that time; below zero: more weakly (more negatively).
  • Dark and light bands are the 50% and 95% credible intervals — the narrower, the more certain. Each panel has its own y-axis.
In this case
  • Mean temperature: from −1.365 to 0.785, rising overall; strongest in Dec, weakest in Jan.
  • Night-time light: from −0.474 to 0.329, rising overall; strongest in Dec, weakest in Jan.
  • In-migration index: from −0.083 to 0.106, rising overall; strongest in Dec, weakest in Feb.
  • Out-migration index: from −0.079 to 0.097, rising overall; strongest in Dec, weakest in Feb.
Figure 3 · Spatial coefficient maps (core) (Map for illustration only; redraw with an officially approved base map for publication.)
Figure 3 · Spatial coefficient maps (core) (Map for illustration only; redraw with an officially approved base map for publication.)
Figure 3 · Spatial coefficient maps (core)
How to read
  • One map per factor; colour = the area’s spatial coefficient: red raises the outcome, blue lowers it, darker = stronger.
  • Each map has its own classes — read the values in the legend to compare.
  • A spatial coefficient is the area’s average effect over the study period; the full effect in one area at one time = spatial coefficient + that time point’s temporal coefficient.
In this case
  • Night-time light: from −5.09 (Liaoning) to 3.31 (Tianjin).
  • PM2.5: from −3.00 (Fujian) to 1.88 (Heilongjiang).
  • NDVI: from −0.07 (Hainan) to 0.73 (Sichuan).
  • Mean temperature: from −0.67 (Anhui) to −0.02 (Hainan).
Figure 3b · Direction-probability maps (Map for illustration only; redraw with an officially approved base map for publication.)
Figure 3b · Direction-probability maps (Map for illustration only; redraw with an officially approved base map for publication.)
Figure 3b · Direction-probability maps
How to read
  • Colour = the probability that the area’s effect is positive, on a continuous 0–1 scale: deep red = almost surely raises the outcome, deep blue = almost surely lowers it, near white = direction uncertain.
  • Read it with figure 3: figure 3 shows how large the effect is, figure 3b how certain its direction is.
In this case
  • Mean temperature: in 0% of areas a positive effect has a probability above 0.8; in 97% a negative effect has a probability above 0.8.
  • Night-time light: in 23% of areas a positive effect has a probability above 0.8; in 32% a negative effect has a probability above 0.8.
  • PM2.5: in 35% of areas a positive effect has a probability above 0.8; in 10% a negative effect has a probability above 0.8.
  • NDVI: in 29% of areas a positive effect has a probability above 0.8; in 0% a negative effect has a probability above 0.8.
Figure 4 · Hot and cold spots of spatial coefficients (Map for illustration only; redraw with an officially approved base map for publication.)
Figure 4 · Hot and cold spots of spatial coefficients (Map for illustration only; redraw with an officially approved base map for publication.)
Figure 4 · Hot and cold spots
How to read
  • Finds clusters of high spatial coefficients (hot spots, red) and low ones (cold spots, blue); grey = no cluster.
  • Answers whether areas where a factor acts especially strongly (or weakly) are contiguous — useful for defining priority regions.
In this case
  • PM2.5: 0 hot spots, 5 cold spots (e.g. Fujian, Zhejiang, Jiangxi).
  • Mean temperature: 0 hot spots, 0 cold spots.
  • NDVI: 7 hot spots (e.g. Sichuan, Tibet, Qinghai), 1 cold spots (e.g. Hebei).
  • Night-time light: 5 hot spots (e.g. Zhejiang, Jiangsu, Jiangxi), 7 cold spots (e.g. Inner Mongolia, Jilin, Liaoning).
Figure 5 · STVPI: who contributes most
Figure 5 · STVPI: who contributes most
Figure 5 · STVPI panels
How to read
  • Top left (“Overall”): how much of the spatiotemporal variation is spatial and how much temporal.
  • Other panels: each factor’s contribution (space + time, spatial part, temporal part); circles = estimates, thick / thin bars = 50% / 95% credible intervals.
  • Percentages of different factors are comparable only when covariates are standardized.
In this case
  • By factor (space + time): night_light 39.0%, PM25 23.3%, temperature 11.6%, NDVI 7.4%, in_migration 6.7%, out_migration 6.5%.
  • Where intervals overlap heavily, do not over-interpret the ranking.
Figure 6 · Spatial and temporal shares of each factor
Figure 6 · Spatial and temporal shares of each factor
Figure 6 · STVPI stacked bars
How to read
  • One bar per factor; bar length = total contribution; the two segments = spatial and temporal parts.
In this case
  • The longest bars are the candidate key factors; a dominant spatial segment calls for place-specific action, a visible temporal segment for timing as well.
Figure 7 · Model fit
Figure 7 · Model fit
Figure 7 · Model fit
How to read
  • The closer the ROC curve to the top-left corner, the better; AUC 0.5 = guessing, 1 = perfect separation.
  • This is the fit to the same data, not predictive ability on new data.
In this case
  • AUC = 0.938 (372 observations).
Figure 8 · Fitted-value maps (several time points, one colour scale) (Map for illustration only; redraw with an officially approved base map for publication.)
Figure 8 · Fitted-value maps (several time points, one colour scale) (Map for illustration only; redraw with an officially approved base map for publication.)
Figure 8 · Fitted-value maps
How to read
  • Several time points side by side on one colour scale: colour changes are changes over time.
  • Areas and years missing in the data also get fitted values, which can be used to fill gaps.
In this case
  • Compare the first and last time points for the overall trend and any change in the spatial pattern.

Want to dig deeper into the local coefficients of each area? The full set of SHAP-style figures for this case is in the corresponding section of chapter 14.

9  Case 3 · Count: acute hepatitis B in five Appalachian US states (wide → long)

The questionHow do population density, the uninsured rate, poverty and precipitation relate to acute hepatitis B case counts in five states over 2012–2023, and how does this vary by state and year?
You will learnSetting up a count outcome; reading results when there are only five areas; resetting Data Conversion before a second use.

9.1  Case card: data, sources and variables

ItemDetails
FolderCase-03-Count-US-Hepatitis-B (official example data)
Tablehbv_a5_wide.xlsx: wide table, 5 rows × 68 columns, columns = variable + year (e.g. cases_2012)
Mapus_a5_map\us_a5.* (Kentucky, North Carolina, Tennessee, Virginia, West Virginia)
SourcesUS CDC (cases), American Community Survey (population density, poverty, uninsured rate), NOAA (annual precipitation); no missing values
Space / timeGEOID (state FIPS code) / year (2012–2023, created during conversion)
Ycases: reported acute hepatitis B cases (non-negative integers)
X (4)pop_density (people/km²), uninsured, poverty (proportions), precipitation (inches)
SettingsCount · Checked Data · Standardize = Yes · QUEEN-B · Threads 20

9.2  Step A: Data Conversion

Case 3 Data Conversion: 5 variables; variable 1 = cases (cases_2012 → cases_2023).
Case 3 Data Conversion: 5 variables; variable 1 = cases (cases_2012 → cases_2023).
  1. Load hbv_a5_wide.xlsx on the Data Conversion page; the check card should report 60 columns with time information (5 variables × 12 years).
  2. ID Columns GEOID; Time Sequence 2012:2023; New Time Column Name year; Number of Variables 5.If you have just done case 2, the form still holds 7 variables and 1:12 — re-enter every field.
  3. Five variable blocks: cases (cases_2012 → cases_2023), pop_density, uninsured, poverty, precipitation, each selected by range.
  4. Start Conversion → a panel of 60 rows and 7 columns → download as Excel xlsx.

9.3  Steps B and C: Data Input and Data Check

Data Input: 60 rows, 7 columns, 5 map units.
Data Input: 60 rows, 7 columns, 5 map units.
Data Check: year / GEOID, Automatically Rearranged.
Data Check: year / GEOID, Automatically Rearranged.

Load the converted table and the five us_a5 files (the extra .sbn .sbx .shp.xml are not needed); check 60 rows, 7 columns, 5 map units. Data Check: time year, space GEOID → Automatically Rearranged.

9.4  Step D: modeling and download

Case 3 parameters: Response Type “Count”.
Case 3 parameters: Response Type “Count”.
  1. Checked Data; Y cases; X pop_density, uninsured, poverty, precipitation; Response Type = Count; time year; space GEOID; Standardize = Yes; QUEEN-B; Threads 20 → Run Model; it finishes in under 15 seconds.Case counts are non-negative integers.
  2. Download All Tables.
The six tables in the Result Module list: (1) model.evaluation (2) local.prediction (3) summary.random.effects (4) time.coefficients (5) space.coefficients (6) contribution.STVPI.
The six tables in the Result Module list: (1) model.evaluation (2) local.prediction (3) summary.random.effects (4) time.coefficients (5) space.coefficients (6) contribution.STVPI.
Expected results. DIC 520.9 · WAIC 521.5 · LS 6.696 · eff 54.6 · pd2 39.3; observed vs fitted R² = 0.992. STVPI: spatial 63.2%, temporal 36.8%; by factor: pop_density 53.1%, uninsured 21.4%, poverty 14.2%, precipitation 10.8%. time.coefficients 48 rows (4 × 12), space.coefficients 5 rows.

9.5  Interpretation

In these five states, population density shows the strongest association with hepatitis B cases, but with so few areas the case mainly demonstrates how to use a count model.

Note. Case counts depend directly on population size. There is no population offset option, so the associations describe case counts, not incidence rates or risk.

9.6  Figures and how to read them

The result workbook can be turned straight into publication figures. The script and the finished figures (300 dpi PNG + vector PDF) are in Case-03-Count-US-Hepatitis-B\visualization\: set R’s working directory to the case folder and run source("visualization/Case3_HBV.R").

R code for this case (click to open and copy)
# Case 3: acute hepatitis B cases in five US states, 2012-2023 (count)
source("visualization/R/bstvc_plot_functions.R"); source("visualization/R/run_case.R")
source("visualization/R/bstvc_local_coef_functions.R"); source("visualization/R/run_local_coef.R")
cfg <- list(lang = "en",
  id = "Case3_HBV", title = "Case 3 US acute hepatitis B",
  xlsx = "data/Case3_HBV/all_result_tables.xlsx", shp = "data/Case3_HBV/us_a5.shp", key = "GEOID", k = 4,
  data = "data/Case3_HBV/model_data.xlsx", wide = list(suffix = paste0("_", 2012:2023), times = 2012:2023),
  type = "count", standardized = TRUE, label_field = "NAME",
  t0 = 2012, tlab = "Year", time_col = "year", pred_times = c(2012, 2015, 2018, 2021, 2023), pred_label = "Cases",
  var_en = c(pop_density = "Population density", uninsured = "Uninsured rate", poverty = "Poverty rate", precipitation = "Annual precipitation"))

run_case(cfg)          # core figures
run_local_coef(cfg)    # optional: SHAP-style local-coefficient figures
Figure 1 · Model evaluation
Figure 1 · Model evaluation
Figure 1 · Model evaluation
How to read
  • Three groups of numbers: goodness of fit (DIC, WAIC), model complexity (eff, pd2) and predictive score (LS).
  • Lower DIC, WAIC and LS are better; compare only models fitted to the same data and the same Y. DIC and WAIC are different criteria, so their values differ.
In this case
  • DIC 520.9, WAIC 521.5, LS 6.696; eff 54.6, pd2 39.3.
  • Agreement between fitted and observed values: R² = 0.992.
Figure 2 · Temporal coefficients
Figure 2 · Temporal coefficients
Figure 2 · Temporal coefficients
How to read
  • One panel per factor; time on the x-axis; the dashed zero line is the average over the whole study period.
  • Above zero: the factor acts more strongly (more positively) than usual at that time; below zero: more weakly (more negatively).
  • Dark and light bands are the 50% and 95% credible intervals — the narrower, the more certain. Each panel has its own y-axis.
In this case
  • Population density: from −1.217 to 3.081, rising overall; strongest in 2023, weakest in 2016.
  • Poverty rate: from −1.016 to 3.075, rising overall; strongest in 2023, weakest in 2013.
  • Uninsured rate: from 1.029 to −2.297, falling overall; strongest in 2013, weakest in 2023.
  • Annual precipitation: from −0.637 to 0.521, rising overall; strongest in 2017, weakest in 2015.
Figure 3 · Spatial coefficient maps (core)
Figure 3 · Spatial coefficient maps (core)
Figure 3 · Spatial coefficient maps (core)
How to read
  • One map per factor; colour = the area’s spatial coefficient: red raises the outcome, blue lowers it, darker = stronger.
  • Each map has its own classes — read the values in the legend to compare.
  • A spatial coefficient is the area’s average effect over the study period; the full effect in one area at one time = spatial coefficient + that time point’s temporal coefficient.
In this case
  • Population density: from −1.01 (Kentucky) to 28.92 (Tennessee).
  • Uninsured rate: from −2.58 (North Carolina) to 1.18 (Tennessee).
  • Poverty rate: from 4.07 (Kentucky) to 5.50 (North Carolina).
  • Annual precipitation: from −0.62 (North Carolina) to 0.37 (Kentucky).
Figure 3b · Direction-probability maps
Figure 3b · Direction-probability maps
Figure 3b · Direction-probability maps
How to read
  • Colour = the probability that the area’s effect is positive, on a continuous 0–1 scale: deep red = almost surely raises the outcome, deep blue = almost surely lowers it, near white = direction uncertain.
  • Read it with figure 3: figure 3 shows how large the effect is, figure 3b how certain its direction is.
In this case
  • Poverty rate: in 100% of areas a positive effect has a probability above 0.8; in 0% a negative effect has a probability above 0.8.
  • Annual precipitation: in 20% of areas a positive effect has a probability above 0.8; in 80% a negative effect has a probability above 0.8.
  • Population density: in 60% of areas a positive effect has a probability above 0.8; in 20% a negative effect has a probability above 0.8.
  • Uninsured rate: in 20% of areas a positive effect has a probability above 0.8; in 60% a negative effect has a probability above 0.8.
Figure 5 · STVPI: who contributes most
Figure 5 · STVPI: who contributes most
Figure 5 · STVPI panels
How to read
  • Top left (“Overall”): how much of the spatiotemporal variation is spatial and how much temporal.
  • Other panels: each factor’s contribution (space + time, spatial part, temporal part); circles = estimates, thick / thin bars = 50% / 95% credible intervals.
  • Percentages of different factors are comparable only when covariates are standardized.
In this case
  • By factor (space + time): pop_density 53.1%, uninsured 21.4%, poverty 14.2%, precipitation 10.8%.
  • Where intervals overlap heavily, do not over-interpret the ranking.
Figure 6 · Spatial and temporal shares of each factor
Figure 6 · Spatial and temporal shares of each factor
Figure 6 · STVPI stacked bars
How to read
  • One bar per factor; bar length = total contribution; the two segments = spatial and temporal parts.
In this case
  • The longest bars are the candidate key factors; a dominant spatial segment calls for place-specific action, a visible temporal segment for timing as well.
Figure 7 · Model fit
Figure 7 · Model fit
Figure 7 · Model fit
How to read
  • Observed values on the x-axis, fitted values on the y-axis; the closer to the dashed line, the better.
  • R² closer to 1 is better; RMSE is the typical error in the units of Y.
In this case
  • R² = 0.992, RMSE = 6.40 (60 observed units).
Figure 8 · Fitted-value maps (several time points, one colour scale)
Figure 8 · Fitted-value maps (several time points, one colour scale)
Figure 8 · Fitted-value maps
How to read
  • Several time points side by side on one colour scale: colour changes are changes over time.
  • Areas and years missing in the data also get fitted values, which can be used to fill gaps.
In this case
  • Compare the first and last time points for the overall trend and any change in the spatial pattern.

Want to dig deeper into the local coefficients of each area? The full set of SHAP-style figures for this case is in the corresponding section of chapter 14.

10  Case 4 · US suicide: binary (4a) and count (4b) outcomes from one panel

The questionHow are poverty, income, population size and drug-overdose mortality associated with suicide across 49 US areas (48 contiguous states + District of Columbia) in 2004–2016?
You will learnOne panel, two outcome types just by switching Y; setting up a count outcome; reading model evaluation honestly; why factors must be standardized before their contributions are compared.

10.1  Case card: data, sources and variables

ItemDetails
FolderCase-04-US-Suicide-Binary-and-Count
Tableus_suicide_panel.csv: 49 × 13 = 637 rows, 10 columns, long table (a wide version, us_suicide_wide.csv, is included to practise Data Conversion)
Mapus_states_contiguous.* (5 files, fields stusps, name)
Sources & licencesBoundaries: US Census Bureau 2020 cartographic boundaries 1:20m (public domain). Deaths: CDC NCHS “Leading Causes of Death”. Drug-overdose mortality and population: CDC NCHS. Poverty and household income: Census Bureau SAIPE. CDC open data (data.cdc.gov) — check its terms of use before reuse
Space / timestusps (state postal code) / year
Y (choose one)(a) high_suicide: 1 if the age-adjusted suicide rate is above that year’s median of the 49 areas (a derived teaching outcome, not an official indicator); (b) suicide_deaths: a count, 29–4,294
X (4, complete)poverty (%), median_income_k (median household income, thousand USD), pop_million (population, millions), drug_aadr (age-adjusted drug-overdose death rate per 100,000)
Settings(a) Binary, (b) Count; both: Checked Data · Standardize = Yes · QUEEN-B · Threads 20

10.2  Steps A and B: Data Input and Data Check (same for 4a and 4b)

Data Input: 637 rows, 10 columns, 49 map units.
Data Input: 637 rows, 10 columns, 49 map units.
Data Check: year / stusps, Automatically Rearranged.
Data Check: year / stusps, Automatically Rearranged.
  1. Data Input: table us_suicide_panel.csv, the five us_states_contiguous map files → Load and Validate Input → check 637 rows, 10 columns, 49 map units.637 = 49 × 13.
  2. Data Check: time year, space stusps → Automatically Rearranged → use Checked Data for modeling.

10.3  Step C (4a): binary model

Case 4a parameters: Y = high_suicide, four X, Binary, Standardize = Yes.
Case 4a parameters: Y = high_suicide, four X, Binary, Standardize = Yes.

Checked Data; Y high_suicide; X poverty, median_income_k, pop_million, drug_aadr; Binary; time year; space stusps; Standardize = Yes; QUEEN-B; Threads 20 → Run Model (under 15 seconds) → Download All Tables.

Case 4a finished.
Case 4a finished.
Expected results (4a). DIC 315.0 · WAIC 318.9 · LS 1.125 · eff 60.0 · pd2 46.6 · AUC 0.990. STVPI: spatial 87.6%, temporal 12.4%; by factor: pop_million 49.5%, median_income_k 23.5%, poverty 16.2%, drug_aadr 8.5%.

Interpretation: Y splits areas at each year’s median, so the model describes which areas fall in the upper half — not how high the rate is. Population size has the largest STVPI: its association with being in the upper half varies most between areas.

Each year the 49 areas are split into a “high” and a “low” group; the model asks which factors relate to being in the high group and how that differs between states.

10.4  4b: count outcome (Standardize = Yes) — reporting the evaluation as it is

Case 4b parameters: Y = suicide_deaths, Count, Standardize X Variables = Yes (7).
Case 4b parameters: Y = suicide_deaths, Count, Standardize X Variables = Yes (7).
  1. On the same page switch Y to suicide_deaths and the Response Type to Count (24).Deaths are non-negative integers.
  2. Standardize X Variables = Yes (7).Only on a common scale can the STVPI percentages of different factors be compared (see the comparison below).
  3. Keep everything else → Run Model (under 15 seconds) → Download All Tables → open model.evaluation.
Case 4b finished: the status line lists the four standardized variables; model.evaluation shows one row.
Case 4b finished: the status line lists the four standardized variables; model.evaluation shows one row.
Expected results (4b, Standardize = Yes). DIC −34,436.9 · WAIC 32,442.2 · LS 19.109 · eff −43,715.8 · pd2 9,645.2; fitted vs observed deaths R² = 0.925. Repeated runs with the same setting give the same result.

How to read these numbers: here eff and DIC are negative. eff is the software’s model-complexity measure and can be negative for some data and settings; WAIC’s complexity measure pd2 is positive. This is the genuine output for these data and settings and is shown as it is; whether and how to use it is for each user to judge in light of their research aims.

Concept card · Model evaluation: DIC, WAIC, LS, eff and pd2
In one line
DIC and WAIC measure “good fit without excess complexity”, LS scores leave-one-out prediction; lower is better for all three. eff and pd2 are the complexity estimates of the two criteria.
Analogy
Two teachers grade the same exam with different marking schemes (DIC and WAIC), so their marks differ.
Why it matters
Together they describe the fit; on the same data and the same Y they let you compare models.
How to use it
Compare DIC with DIC and WAIC with WAIC, never DIC with WAIC; report all values in a supplementary table.
Say it to others
“DIC and WAIC are two different rulers: lower is better, and you only compare on the same data.”

10.4.1  Comparison: STVPI changes with standardization

To show how standardization affects each factor’s contribution, three cases were run with Standardize = Yes and No (all else equal); the table compares each factor’s STVPI (space + time):

CaseFactorSTVPI · Standardize = YesSTVPI · Standardize = No
Case 1 continuousurban_pop43.4%10.3%
Case 1 continuousPM25_exposure4.0%3.1%
Case 1 continuouspop_million51.4%77.7%
Case 4a binarypoverty16.2%16.7%
Case 4a binarymedian_income_k23.5%6.9%
Case 4a binarypop_million49.5%45.2%
Case 4a binarydrug_aadr8.5%27.0%
Case 4b countdrug_aadr6.6%3.6%
Case 4b countpop_million80.0%81.1%
Case 4b countmedian_income_k7.9%5.9%
Case 4b countpoverty5.4%9.4%

STVPI = posterior mean of the space + time total; red = the two settings differ by more than 5 percentage points. The case 4b “Standardize = Yes” column comes from the fit with negative eff. All other settings identical.

STVPI shifts with the units of X (case 1 urban population 43% → 10%; case 4a drug-overdose mortality 9% → 27%), and without standardization even the model fit differs. So standardize before comparing the contributions of different X; without it, interpret each variable’s own coefficient pattern only. With Standardize = No, case 4b gives eff = 172.8 and DIC = 6,341.4, but the STVPI values of its X cannot then be compared.

Contribution percentages are like dividing a total score among subjects: if subjects are marked on different scales (metres and centimetres mixed), the shares are wrong. Standardizing puts everything on one scale first.

10.5  Figures and how to read them: 4a binary

The result workbook can be turned straight into publication figures. The script and the finished figures (300 dpi PNG + vector PDF) are in Case-04-US-Suicide-Binary-and-Count\visualization\: set R’s working directory to the case folder and run source("visualization/Case4a_US_suicide_binary.R").

R code for this case (click to open and copy)
# Case 4a: high suicide-rate status in 49 US areas, 2004-2016 (binary, derived)
source("visualization/R/bstvc_plot_functions.R"); source("visualization/R/run_case.R")
source("visualization/R/bstvc_local_coef_functions.R"); source("visualization/R/run_local_coef.R")
cfg <- list(lang = "en",
  id = "Case4a_US_suicide_binary", title = "Case 4a US high suicide rate",
  xlsx = "data/Case4a_US_suicide_binary/all_result_tables.xlsx", shp = "data/Case4a_US_suicide_binary/us_states_contiguous.shp", key = "stusps",
  data = "data/Case4a_US_suicide_binary/model_data.csv",
  type = "binary", standardized = TRUE, label_field = "name",
  t0 = 2004, tlab = "Year", time_col = "year", pred_times = c(2004, 2010, 2016), pred_label = "Fitted probability",
  var_en = c(poverty = "Poverty rate", median_income_k = "Median household income", pop_million = "Population", drug_aadr = "Drug overdose mortality"))

run_case(cfg)          # core figures
run_local_coef(cfg)    # optional: SHAP-style local-coefficient figures
Figure 1 · Model evaluation
Figure 1 · Model evaluation
Figure 1 · Model evaluation
How to read
  • Three groups of numbers: goodness of fit (DIC, WAIC), model complexity (eff, pd2) and predictive score (LS).
  • Lower DIC, WAIC and LS are better; compare only models fitted to the same data and the same Y. DIC and WAIC are different criteria, so their values differ.
In this case
  • DIC 315.0, WAIC 318.9, LS 1.125; eff 60.0, pd2 46.6.
  • Agreement between fitted and observed values: AUC = 0.990.
Figure 2 · Temporal coefficients
Figure 2 · Temporal coefficients
Figure 2 · Temporal coefficients
How to read
  • One panel per factor; time on the x-axis; the dashed zero line is the average over the whole study period.
  • Above zero: the factor acts more strongly (more positively) than usual at that time; below zero: more weakly (more negatively).
  • Dark and light bands are the 50% and 95% credible intervals — the narrower, the more certain. Each panel has its own y-axis.
In this case
  • Drug overdose mortality: from 0.446 to −0.607, falling overall; strongest in 2004, weakest in 2016.
  • Population: from 0.255 to −0.417, falling overall; strongest in 2006, weakest in 2016.
  • Median household income: from −0.013 to −0.068, falling overall; strongest in 2010, weakest in 2016.
  • Poverty rate: from 0.005 to 0.023, rising overall; strongest in 2015, weakest in 2007.
Figure 3 · Spatial coefficient maps (core)
Figure 3 · Spatial coefficient maps (core)
Figure 3 · Spatial coefficient maps (core)
How to read
  • One map per factor; colour = the area’s spatial coefficient: red raises the outcome, blue lowers it, darker = stronger.
  • Each map has its own classes — read the values in the legend to compare.
  • A spatial coefficient is the area’s average effect over the study period; the full effect in one area at one time = spatial coefficient + that time point’s temporal coefficient.
In this case
  • Population: from −10.10 (Oregon) to 4.09 (Rhode Island).
  • Median household income: from −3.79 (Delaware) to 0.82 (Washington).
  • Poverty rate: from −1.96 (Louisiana) to 1.10 (Iowa).
  • Drug overdose mortality: from 1.77 (Rhode Island) to 2.13 (Nebraska).
Figure 3b · Direction-probability maps
Figure 3b · Direction-probability maps
Figure 3b · Direction-probability maps
How to read
  • Colour = the probability that the area’s effect is positive, on a continuous 0–1 scale: deep red = almost surely raises the outcome, deep blue = almost surely lowers it, near white = direction uncertain.
  • Read it with figure 3: figure 3 shows how large the effect is, figure 3b how certain its direction is.
In this case
  • Drug overdose mortality: in 100% of areas a positive effect has a probability above 0.8; in 0% a negative effect has a probability above 0.8.
  • Population: in 2% of areas a positive effect has a probability above 0.8; in 82% a negative effect has a probability above 0.8.
  • Median household income: in 2% of areas a positive effect has a probability above 0.8; in 65% a negative effect has a probability above 0.8.
  • Poverty rate: in 8% of areas a positive effect has a probability above 0.8; in 12% a negative effect has a probability above 0.8.
Figure 4 · Hot and cold spots of spatial coefficients
Figure 4 · Hot and cold spots of spatial coefficients
Figure 4 · Hot and cold spots
How to read
  • Finds clusters of high spatial coefficients (hot spots, red) and low ones (cold spots, blue); grey = no cluster.
  • Answers whether areas where a factor acts especially strongly (or weakly) are contiguous — useful for defining priority regions.
In this case
  • Poverty rate: 5 hot spots (e.g. South Dakota, Iowa, Minnesota), 9 cold spots (e.g. Louisiana, Mississippi, Arkansas).
  • Median household income: 8 hot spots (e.g. Idaho, Oregon, Utah), 9 cold spots (e.g. New York, Massachusetts, Connecticut).
  • Population: 6 hot spots (e.g. Rhode Island, Connecticut, Massachusetts), 10 cold spots (e.g. Idaho, Nevada, Oregon).
  • Drug overdose mortality: 12 hot spots (e.g. Colorado, Utah, Arizona), 11 cold spots (e.g. Massachusetts, New York, Connecticut).
Figure 5 · STVPI: who contributes most
Figure 5 · STVPI: who contributes most
Figure 5 · STVPI panels
How to read
  • Top left (“Overall”): how much of the spatiotemporal variation is spatial and how much temporal.
  • Other panels: each factor’s contribution (space + time, spatial part, temporal part); circles = estimates, thick / thin bars = 50% / 95% credible intervals.
  • Percentages of different factors are comparable only when covariates are standardized.
In this case
  • By factor (space + time): pop_million 49.5%, median_income_k 23.5%, poverty 16.2%, drug_aadr 8.5%.
  • Where intervals overlap heavily, do not over-interpret the ranking.
Figure 6 · Spatial and temporal shares of each factor
Figure 6 · Spatial and temporal shares of each factor
Figure 6 · STVPI stacked bars
How to read
  • One bar per factor; bar length = total contribution; the two segments = spatial and temporal parts.
In this case
  • The longest bars are the candidate key factors; a dominant spatial segment calls for place-specific action, a visible temporal segment for timing as well.
Figure 7 · Model fit
Figure 7 · Model fit
Figure 7 · Model fit
How to read
  • The closer the ROC curve to the top-left corner, the better; AUC 0.5 = guessing, 1 = perfect separation.
  • This is the fit to the same data, not predictive ability on new data.
In this case
  • AUC = 0.990 (637 observations).
Figure 8 · Fitted-value maps (several time points, one colour scale)
Figure 8 · Fitted-value maps (several time points, one colour scale)
Figure 8 · Fitted-value maps
How to read
  • Several time points side by side on one colour scale: colour changes are changes over time.
  • Areas and years missing in the data also get fitted values, which can be used to fill gaps.
In this case
  • Compare the first and last time points for the overall trend and any change in the spatial pattern.

Want to dig deeper into the local coefficients of each area? The full set of SHAP-style figures for this case is in the corresponding section of chapter 14.

10.6  Figures and how to read them: 4b count

The result workbook can be turned straight into publication figures. The script and the finished figures (300 dpi PNG + vector PDF) are in Case-04-US-Suicide-Binary-and-Count\visualization\: set R’s working directory to the case folder and run source("visualization/Case4b_US_suicide_count.R").

R code for this case (click to open and copy)
# Case 4b: suicide deaths in 49 US areas, 2004-2016 (count, standardized)
source("visualization/R/bstvc_plot_functions.R"); source("visualization/R/run_case.R")
source("visualization/R/bstvc_local_coef_functions.R"); source("visualization/R/run_local_coef.R")
cfg <- list(lang = "en",
  id = "Case4b_US_suicide_count", title = "Case 4b US suicide deaths",
  xlsx = "data/Case4b_US_suicide_count/all_result_tables.xlsx", shp = "data/Case4b_US_suicide_count/us_states_contiguous.shp", key = "stusps",
  data = "data/Case4b_US_suicide_count/model_data.csv",
  type = "count", standardized = TRUE, logaxes = TRUE, label_field = "name",
  t0 = 2004, tlab = "Year", time_col = "year", pred_times = c(2004, 2010, 2016), pred_label = "Deaths",
  var_en = c(poverty = "Poverty rate", median_income_k = "Median household income", pop_million = "Population", drug_aadr = "Drug overdose mortality"))

run_case(cfg)          # core figures
run_local_coef(cfg)    # optional: SHAP-style local-coefficient figures
Note. The 4b figures come from the “Standardize = Yes” result tables (negative eff) and show the software output as it is; read them together with the model evaluation in figure 1.
Figure 1 · Model evaluation
Figure 1 · Model evaluation
Figure 1 · Model evaluation
How to read
  • Three groups of numbers: goodness of fit (DIC, WAIC), model complexity (eff, pd2) and predictive score (LS).
  • Lower DIC, WAIC and LS are better; compare only models fitted to the same data and the same Y. DIC and WAIC are different criteria, so their values differ.
In this case
  • DIC −34,436.9, WAIC 32,442.2, LS 19.109; eff −43,715.8, pd2 9,645.2.
  • Agreement between fitted and observed values: R² = 0.925.
Figure 2 · Temporal coefficients
Figure 2 · Temporal coefficients
Figure 2 · Temporal coefficients
How to read
  • One panel per factor; time on the x-axis; the dashed zero line is the average over the whole study period.
  • Above zero: the factor acts more strongly (more positively) than usual at that time; below zero: more weakly (more negatively).
  • Dark and light bands are the 50% and 95% credible intervals — the narrower, the more certain. Each panel has its own y-axis.
In this case
  • Poverty rate: from −0.379 to 0.445, rising overall; strongest in 2016, weakest in 2004.
  • Population: from 0.366 to −0.165, falling overall; strongest in 2004, weakest in 2014.
  • Median household income: from 0.082 to −0.220, rising overall; strongest in 2011, weakest in 2008.
  • Drug overdose mortality: from 0.083 to −0.080, falling overall; strongest in 2007, weakest in 2010.
Figure 3 · Spatial coefficient maps (core)
Figure 3 · Spatial coefficient maps (core)
Figure 3 · Spatial coefficient maps (core)
How to read
  • One map per factor; colour = the area’s spatial coefficient: red raises the outcome, blue lowers it, darker = stronger.
  • Each map has its own classes — read the values in the legend to compare.
  • A spatial coefficient is the area’s average effect over the study period; the full effect in one area at one time = spatial coefficient + that time point’s temporal coefficient.
In this case
  • Population: from −196.02 (Missouri) to 173.37 (Washington).
  • Median household income: from −12.94 (Washington) to 4.99 (Missouri).
  • Drug overdose mortality: from −1.72 (Georgia) to 15.12 (Arizona).
  • Poverty rate: from −7.83 (Washington) to 4.32 (Missouri).
Figure 3b · Direction-probability maps
Figure 3b · Direction-probability maps
Figure 3b · Direction-probability maps
How to read
  • Colour = the probability that the area’s effect is positive, on a continuous 0–1 scale: deep red = almost surely raises the outcome, deep blue = almost surely lowers it, near white = direction uncertain.
  • Read it with figure 3: figure 3 shows how large the effect is, figure 3b how certain its direction is.
In this case
  • Population: in 33% of areas a positive effect has a probability above 0.8; in 67% a negative effect has a probability above 0.8.
  • Poverty rate: in 53% of areas a positive effect has a probability above 0.8; in 43% a negative effect has a probability above 0.8.
  • Median household income: in 55% of areas a positive effect has a probability above 0.8; in 33% a negative effect has a probability above 0.8.
  • Drug overdose mortality: in 61% of areas a positive effect has a probability above 0.8; in 24% a negative effect has a probability above 0.8.
Figure 4 · Hot and cold spots of spatial coefficients
Figure 4 · Hot and cold spots of spatial coefficients
Figure 4 · Hot and cold spots
How to read
  • Finds clusters of high spatial coefficients (hot spots, red) and low ones (cold spots, blue); grey = no cluster.
  • Answers whether areas where a factor acts especially strongly (or weakly) are contiguous — useful for defining priority regions.
In this case
  • Poverty rate: 0 hot spots, 1 cold spots (e.g. Washington).
  • Median household income: 0 hot spots, 3 cold spots (e.g. Washington, Alabama, Mississippi).
  • Population: 0 hot spots, 2 cold spots (e.g. Iowa, Kansas).
  • Drug overdose mortality: 5 hot spots (e.g. California, Nevada, Arizona), 0 cold spots.
Figure 5 · STVPI: who contributes most
Figure 5 · STVPI: who contributes most
Figure 5 · STVPI panels
How to read
  • Top left (“Overall”): how much of the spatiotemporal variation is spatial and how much temporal.
  • Other panels: each factor’s contribution (space + time, spatial part, temporal part); circles = estimates, thick / thin bars = 50% / 95% credible intervals.
  • Percentages of different factors are comparable only when covariates are standardized.
In this case
  • By factor (space + time): pop_million 80.0%, median_income_k 7.9%, drug_aadr 6.6%, poverty 5.4%.
  • Where intervals overlap heavily, do not over-interpret the ranking.
Figure 6 · Spatial and temporal shares of each factor
Figure 6 · Spatial and temporal shares of each factor
Figure 6 · STVPI stacked bars
How to read
  • One bar per factor; bar length = total contribution; the two segments = spatial and temporal parts.
In this case
  • The longest bars are the candidate key factors; a dominant spatial segment calls for place-specific action, a visible temporal segment for timing as well.
Figure 7 · Model fit
Figure 7 · Model fit
Figure 7 · Model fit
How to read
  • Observed values on the x-axis, fitted values on the y-axis; the closer to the dashed line, the better.
  • R² closer to 1 is better; RMSE is the typical error in the units of Y.
In this case
  • R² = 0.925, RMSE = 203.63 (637 observed units).
Figure 8 · Fitted-value maps (several time points, one colour scale)
Figure 8 · Fitted-value maps (several time points, one colour scale)
Figure 8 · Fitted-value maps
How to read
  • Several time points side by side on one colour scale: colour changes are changes over time.
  • Areas and years missing in the data also get fitted values, which can be used to fill gaps.
In this case
  • Compare the first and last time points for the overall trend and any change in the spatial pattern.

Want to dig deeper into the local coefficients of each area? The full set of SHAP-style figures for this case is in the corresponding section of chapter 14.

11  Case 5 · Spatial-only BSVC: high suicide-rate status in 49 US areas, 2016

The questionWith a single year of data, how do the associations of four factors with high suicide-rate status differ across 49 areas?
You will learnUsing the BSVC page; the cross-section check; spatial coefficients only, five result tables.

11.1  Case card

Tableus_suicide_2016_cross_section.csv: the 49 rows of the case-4 panel with year = 2016; each area appears once
Mapus_states_contiguous.* (as in case 4)
Y / Xhigh_suicide (0/1) / the four X of case 4
SettingsBSVC modeling · Binary · Checked Data · Standardize = Yes · QUEEN-B · Threads 20
Concept card · BSVC versus BSTVC
In one line
BSVC lets coefficients vary across areas (one time point); BSTVC lets them vary across areas and over time (several time points).
Analogy
BSVC is a photograph; BSTVC is a video.
Why it matters
Many data sets are a single census or one year; BSVC fits them, while BSTVC would have no time information to use.
How to use it
Data Check with “BSVC Spatial Cross-section” selected (space field only) → BSVC modeling on the left → no time field → five result tables (no time.coefficients).
Say it to others
“With one year of data, use BSVC — it shows how areas differ.”
Note: each area contributes one observation — far less information than a multi-year panel — so coefficient intervals are usually wider; STVPI has a spatial part only.

11.2  Steps A and B: Data Input and the cross-section check

Data Input: 49 rows, 10 columns, 49 map units.
Data Input: 49 rows, 10 columns, 49 map units.
Data Check: (1) BSVC Spatial Cross-section (3) space field stusps (4) Run Check (5) result.
Data Check: (1) BSVC Spatial Cross-section (3) space field stusps (4) Run Check (5) result.
  1. Data Input: load the cross-section table and the map → check 49 rows, 10 columns, 49 map units.
  2. Data Check: select BSVC Spatial Cross-section (1) — the time field disappears; Space Field stusps (3) → Run Check (4) → Automatically Rearranged (5).

11.3  Step C: BSVC modeling

BSVC parameters: there is no time field (position 5 is empty).
BSVC parameters: there is no time field (position 5 is empty).

Click BSVC modeling on the left: Checked Data (1) · Y high_suicide (2) · the four X (3) · Binary (4) · space stusps (6) · Standardize = Yes (7) · QUEEN-B (8) · Threads 20 (9) → Run Model (10); it finishes in under 15 seconds.

BSVC finished: the Result Module lists five tables.
BSVC finished: the Result Module lists five tables.
Expected results. DIC 48.9 · WAIC 50.2 · LS 0.519 · eff 4.49 · pd2 5.03 · AUC 0.898 (49 areas). STVPI (spatial only): drug_aadr 23.0%, poverty 21.2%, pop_million 18.5%, median_income_k 18.1%.

11.4  Interpretation

With one year and one “high or not” label per state, the model captures the broad differences between areas but cannot tell which factor matters most.

11.5  Figures and how to read them

The result workbook can be turned straight into publication figures. The script and the finished figures (300 dpi PNG + vector PDF) are in Case-05-BSVC-US-Suicide-2016\visualization\: set R’s working directory to the case folder and run source("visualization/Case5_BSVC_US_suicide_2016.R").

R code for this case (click to open and copy)
# Case 5: BSVC spatial model, high suicide-rate status in 49 US areas, 2016 (binary)
source("visualization/R/bstvc_plot_functions.R"); source("visualization/R/run_case.R")
source("visualization/R/bstvc_local_coef_functions.R"); source("visualization/R/run_local_coef.R")
cfg <- list(lang = "en",
  id = "Case5_BSVC_US_suicide_2016", title = "Case 5 BSVC US 2016",
  xlsx = "data/Case5_BSVC_US_suicide_2016/all_result_tables.xlsx", shp = "data/Case5_BSVC_US_suicide_2016/us_states_contiguous.shp", key = "stusps",
  data = "data/Case5_BSVC_US_suicide_2016/model_data.csv",
  type = "binary", model = "bsvc", standardized = TRUE, label_field = "name", pred_label = "Fitted probability",
  var_en = c(poverty = "Poverty rate", median_income_k = "Median household income", pop_million = "Population", drug_aadr = "Drug overdose mortality"))

run_case(cfg)          # core figures
run_local_coef(cfg)    # optional: SHAP-style local-coefficient figures
Figure 1 · Model evaluation
Figure 1 · Model evaluation
Figure 1 · Model evaluation
How to read
  • Three groups of numbers: goodness of fit (DIC, WAIC), model complexity (eff, pd2) and predictive score (LS).
  • Lower DIC, WAIC and LS are better; compare only models fitted to the same data and the same Y. DIC and WAIC are different criteria, so their values differ.
In this case
  • DIC 48.9, WAIC 50.2, LS 0.519; eff 4.5, pd2 5.0.
  • Agreement between fitted and observed values: AUC = 0.898.
Figure 3 · Spatial coefficient maps (core)
Figure 3 · Spatial coefficient maps (core)
Figure 3 · Spatial coefficient maps (core)
How to read
  • One map per factor; colour = the area’s spatial coefficient: red raises the outcome, blue lowers it, darker = stronger.
  • Each map has its own classes — read the values in the legend to compare.
  • A spatial coefficient is the area’s average effect over the study period; the full effect in one area at one time = spatial coefficient + that time point’s temporal coefficient.
In this case
  • Drug overdose mortality: from 0.04 (Rhode Island) to 0.48 (Nebraska).
  • Poverty rate: from −1.51 (Louisiana) to −1.35 (Minnesota).
  • Median household income: from −2.42 (Rhode Island) to −2.27 (Louisiana).
  • Population: from −2.45 (Oregon) to −2.33 (Rhode Island).
Figure 3b · Direction-probability maps
Figure 3b · Direction-probability maps
Figure 3b · Direction-probability maps
How to read
  • Colour = the probability that the area’s effect is positive, on a continuous 0–1 scale: deep red = almost surely raises the outcome, deep blue = almost surely lowers it, near white = direction uncertain.
  • Read it with figure 3: figure 3 shows how large the effect is, figure 3b how certain its direction is.
In this case
  • Poverty rate: in 0% of areas a positive effect has a probability above 0.8; in 100% a negative effect has a probability above 0.8.
  • Median household income: in 0% of areas a positive effect has a probability above 0.8; in 100% a negative effect has a probability above 0.8.
  • Population: in 0% of areas a positive effect has a probability above 0.8; in 100% a negative effect has a probability above 0.8.
  • Drug overdose mortality: in 4% of areas a positive effect has a probability above 0.8; in 0% a negative effect has a probability above 0.8.
Figure 4 · Hot and cold spots of spatial coefficients
Figure 4 · Hot and cold spots of spatial coefficients
Figure 4 · Hot and cold spots
How to read
  • Finds clusters of high spatial coefficients (hot spots, red) and low ones (cold spots, blue); grey = no cluster.
  • Answers whether areas where a factor acts especially strongly (or weakly) are contiguous — useful for defining priority regions.
In this case
  • Poverty rate: 5 hot spots (e.g. Minnesota, Iowa, Wisconsin), 9 cold spots (e.g. Mississippi, Louisiana, Arkansas).
  • Median household income: 9 hot spots (e.g. Arkansas, Louisiana, Mississippi), 11 cold spots (e.g. Massachusetts, New York, Connecticut).
  • Population: 10 hot spots (e.g. Massachusetts, Connecticut, Rhode Island), 6 cold spots (e.g. Idaho, Nevada, Oregon).
  • Drug overdose mortality: 7 hot spots (e.g. South Dakota, Iowa, Nebraska), 11 cold spots (e.g. Massachusetts, New York, Connecticut).
Figure 5 · STVPI: who contributes most
Figure 5 · STVPI: who contributes most
Figure 5 · STVPI panels
How to read
  • Top left (“Overall”): how much of the spatiotemporal variation is spatial and how much temporal.
  • Other panels: each factor’s contribution (space + time, spatial part, temporal part); circles = estimates, thick / thin bars = 50% / 95% credible intervals.
  • Percentages of different factors are comparable only when covariates are standardized.
In this case
  • By factor (space + time): drug_aadr 23.0%, poverty 21.2%, pop_million 18.5%, median_income_k 18.1%.
  • Where intervals overlap heavily, do not over-interpret the ranking.
Figure 7 · Model fit
Figure 7 · Model fit
Figure 7 · Model fit
How to read
  • The closer the ROC curve to the top-left corner, the better; AUC 0.5 = guessing, 1 = perfect separation.
  • This is the fit to the same data, not predictive ability on new data.
In this case
  • AUC = 0.898 (49 observations).
Figure 8 · Fitted probability map
Figure 8 · Fitted probability map
Figure 8 · Fitted map
How to read
  • Colour = each area’s fitted probability.
In this case
  • A single year, so only the spatial pattern.

Want to dig deeper into the local coefficients of each area? The full set of SHAP-style figures for this case is in the corresponding section of chapter 14.

12  Case 6 · The largest case: healthy life expectancy in 177 countries and territories (12 X)

The questionHow are 12 socioeconomic, health-system, environmental and behavioural factors associated with healthy life expectancy (HALE) across countries in 2000–2020, and how does this vary over space and time?
You will learnHow long a large model takes and how to tell it is still running; why more variables give a better fit; reading maps with many island states.

12.1  Case card: data, sources and variables

ItemDetails
FolderCase-06-Continuous-Global-HALE (official example data, keeping the variables with documented meaning)
TableHALE_global_panel.csv: 177 × 21 = 3,717 rows, 15 columns, long table
MapTestMap_Continuous.* (5 files, area ID ISO_A3)
SourcesGlobal Burden of Disease (GBD), World Bank, GIOVANNI, global air-quality data
YHALE (years), 7.3% missing
X (12)In the official file, all X except maternal mortality and PM2.5 are already standardized (z-scores); original units are not provided. maternal_mortality, high_alcohol, high_BMI, vitA_deficiency, female_employment, urban_pop, GNI_pc, health_exp, physicians, heat_exposure, NDVI, PM25 (female_employment 45% missing, physicians 44% missing)
SettingsContinuous · Checked Data · Standardize = Yes · QUEEN-B · Threads 20

12.2  Step A: Data Input

Data Input: 3717 rows, 15 columns, 177 map units.
Data Input: 3717 rows, 15 columns, 177 map units.
  1. In the Browse… dialog you can paste a full path into the Windows “File name” box and press Enter (1).
  2. Map: all five TestMap_Continuous files (2); the box shows “5 files”.
  3. Load and Validate Input (4) → check 3717 rows, 15 columns, 177 map units (6). The “Data Table” tab shows each field’s missing-value rate.
“Map” tab: preview of 177 countries and territories.
“Map” tab: preview of 177 countries and territories.

12.3  Step B: Data Check

Data Check: year / ISO_A3, Automatically Rearranged.
Data Check: year / ISO_A3, Automatically Rearranged.

Time year, space ISO_A3 → Run Check → Automatically Rearranged.

12.4  Step C: modeling — the most demanding step

Case 6 parameters: 12 X, Continuous, Threads 20.
Case 6 parameters: 12 X, Continuous, Threads 20.
  1. Checked Data; Y HALE; X: type each of the 12 names into the box and press Enter (3).Typing is faster than scrolling a long list and avoids mistakes.
  2. Continuous; time year; space ISO_A3; Standardize = Yes; QUEEN-B.
  3. Threads 20 (9).The default of 6 is much slower; beyond about 20 there is no further gain.
  4. Run Model. This case takes about 20 minutes; the page stays grey the whole time.
While running: the page greys out with a “model is running” message. Do not click other pages.
While running: the page greys out with a “model is running” message. Do not click other pages.
Tip. To tell whether it is still computing: high CPU use and changing memory in Task Manager = still running; the window updates only when everything is done. The official BSTVC Monitor shows progress live.

12.5  Step D: results and download

Finished: the status line lists the 12 standardized variables; browse and download each table with Result Module.
Finished: the status line lists the 12 standardized variables; browse and download each table with Result Module.
local.prediction: one row per country and year. Continuous outcomes have predict_y and fill_y (missing Y filled with fitted values).
local.prediction: one row per country and year. Continuous outcomes have predict_y and fill_y (missing Y filled with fitted values).
contribution.STVPI: spatial / temporal / residual shares and each factor’s contribution.
contribution.STVPI: spatial / temporal / residual shares and each factor’s contribution.
Expected results. DIC 14,156.6 · WAIC 16,153.7 · LS 2.223 · eff 654.6 · pd2 1,539.6; observed vs fitted R² = 0.967 (r = 0.984, RMSE = 1.33 years, 3,444 country-years with observations). STVPI: spatial 99.4%, temporal 0.5%, residual 0.1%; by factor: GNI_pc 51.0%, urban_pop 11.3%, high_alcohol 9.5%, heat_exposure 8.7%, maternal_mortality 7.7%, vitA_deficiency 6.2%, high_BMI 3.0%, health_exp 1.6%, PM25 0.3%, physicians 0.1%, NDVI 0.1%, female_employment 0.0%.
Concept card · STVPI (spatiotemporal variance partitioning index)
In one line
Splits the spatiotemporal variation explained by the model into percentages by factor and into spatial and temporal parts, to show who contributes most.
Analogy
How much of the spread in a class’s grades comes from “different schools” (space) versus “different terms” (time), and which subject drives each.
Why it matters
A coefficient says how strong an effect is; STVPI says how much a factor weighs in the overall pattern — useful for identifying key drivers.
How to use it
Rank factors by space.time.X (factor total), then see whether it comes mainly from space.X or time.X. Binary and count models have no residual term; the percentages are shared among the covariates.
Say it to others
“STVPI tells you who the main players are, and whether they act mainly between areas or over time.”
Technical note: Song et al. (2022); Wan et al. (2022). A relative-contribution measure with 2.5%–97.5% posterior intervals.

12.6  Interpretation

Differences in healthy life expectancy are mostly differences between countries; in this model the effects of income, urbanisation and other factors vary a lot from country to country but changed little over 20 years.

12.7  Why 12 variables: a quick trial versus the full run

RunNumber of XTimeDICR²
Quick trial6 (maternal_mortality, NDVI, high_BMI, vitA_deficiency, PM25, urban_pop)about 54 seconds22,2840.575
Full run12about 20 minutes14,1570.967

With too few variables the model cannot explain differences in national levels and R² is clearly lower. Rule of thumb: first confirm the workflow with a few X, then run the full model with every substantively relevant X and 20 threads. R² describes the fit to these data, not predictive ability on new data.

Concept card · R² (and why it can be low or even negative)
In one line
R² = 1 − residual sum of squares / total sum of squares: how much better the model does than simply guessing the mean.
Analogy
To guess everyone’s height with no information, you guess the average; R² measures how much better your method is than that naive guess. Worse than the naive guess gives a negative R².
Why it matters
It shows at a glance whether fitted and observed values agree.
How to use it
Computed on observed units from predict_y against y in local.prediction; figure 7 of the plotting script draws it.
Say it to others
“An R² of 0.97 means the model reproduces 97% of the variation — in the data it was fitted to, not in the future.”

12.8  Figures and how to read them

The result workbook can be turned straight into publication figures. The script and the finished figures (300 dpi PNG + vector PDF) are in Case-06-Continuous-Global-HALE\visualization\: set R’s working directory to the case folder and run source("visualization/Case6_HALE_global.R").

R code for this case (click to open and copy)
# Case 6: healthy life expectancy in 177 countries, 2000-2020 (continuous, 12 covariates)
source("visualization/R/bstvc_plot_functions.R"); source("visualization/R/run_case.R")
source("visualization/R/bstvc_local_coef_functions.R"); source("visualization/R/run_local_coef.R")
cfg <- list(lang = "en",
  id = "Case6_HALE_global", title = "Case 6 global HALE",
  xlsx = "data/Case6_HALE_global/all_result_tables.xlsx", shp = "data/Case6_HALE_global/TestMap_Continuous.shp", key = "ISO_A3", drop = "ATA",
  data = "data/Case6_HALE_global/model_data.csv",
  type = "continuous", standardized = TRUE,
  t0 = 2000, tlab = "Year", time_col = "year", pred_times = c(2000, 2010, 2020), pred_label = "HALE (years)",
  var_en = c(maternal_mortality = "Maternal mortality", high_alcohol = "High alcohol use", high_BMI = "High BMI",
             vitA_deficiency = "Vitamin A deficiency", female_employment = "Female employment", urban_pop = "Urban population",
             GNI_pc = "GNI per capita", health_exp = "Health expenditure", physicians = "Physicians per 1,000",
             heat_exposure = "Heat exposure", NDVI = "NDVI", PM25 = "PM2.5"))

run_case(cfg)          # core figures
run_local_coef(cfg)    # optional: SHAP-style local-coefficient figures
Figure 1 · Model evaluation
Figure 1 · Model evaluation
Figure 1 · Model evaluation
How to read
  • Three groups of numbers: goodness of fit (DIC, WAIC), model complexity (eff, pd2) and predictive score (LS).
  • Lower DIC, WAIC and LS are better; compare only models fitted to the same data and the same Y. DIC and WAIC are different criteria, so their values differ.
In this case
  • DIC 14,156.6, WAIC 16,153.7, LS 2.223; eff 654.6, pd2 1,539.6.
  • Agreement between fitted and observed values: R² = 0.967.
Figure 2 · Temporal coefficients
Figure 2 · Temporal coefficients
Figure 2 · Temporal coefficients
How to read
  • One panel per factor; time on the x-axis; the dashed zero line is the average over the whole study period.
  • Above zero: the factor acts more strongly (more positively) than usual at that time; below zero: more weakly (more negatively).
  • Dark and light bands are the 50% and 95% credible intervals — the narrower, the more certain. Each panel has its own y-axis.
In this case
  • GNI per capita: from 0.191 to −0.080, falling overall; strongest in 2000, weakest in 2019.
  • Maternal mortality: from −0.045 to 0.130, rising overall; strongest in 2020, weakest in 2003.
  • Vitamin A deficiency: from −0.009 to −0.037, falling overall; strongest in 2009, weakest in 2020.
  • Heat exposure: from 0.029 to −0.004, falling overall; strongest in 2000, weakest in 2013.
Figure 3 · Spatial coefficient maps (core)
Figure 3 · Spatial coefficient maps (core)
Figure 3 · Spatial coefficient maps (core)
How to read
  • One map per factor; colour = the area’s spatial coefficient: red raises the outcome, blue lowers it, darker = stronger.
  • Each map has its own classes — read the values in the legend to compare.
  • A spatial coefficient is the area’s average effect over the study period; the full effect in one area at one time = spatial coefficient + that time point’s temporal coefficient.
In this case
  • GNI per capita: from −29.11 (eSwatini) to 13.59 (United Republic of Tanzania).
  • Urban population: from −6.30 (Ivory Coast) to 3.80 (Gambia).
  • High alcohol use: from −5.39 (Lesotho) to 2.61 (Mongolia).
  • Maternal mortality: from −5.45 (Montenegro) to 2.44 (Gambia).
Figure 3b · Direction-probability maps
Figure 3b · Direction-probability maps
Figure 3b · Direction-probability maps
How to read
  • Colour = the probability that the area’s effect is positive, on a continuous 0–1 scale: deep red = almost surely raises the outcome, deep blue = almost surely lowers it, near white = direction uncertain.
  • Read it with figure 3: figure 3 shows how large the effect is, figure 3b how certain its direction is.
In this case
  • High alcohol use: in 10% of areas a positive effect has a probability above 0.8; in 51% a negative effect has a probability above 0.8.
  • Urban population: in 28% of areas a positive effect has a probability above 0.8; in 32% a negative effect has a probability above 0.8.
  • GNI per capita: in 8% of areas a positive effect has a probability above 0.8; in 51% a negative effect has a probability above 0.8.
  • Maternal mortality: in 11% of areas a positive effect has a probability above 0.8; in 44% a negative effect has a probability above 0.8.
Figure 4 · Hot and cold spots of spatial coefficients
Figure 4 · Hot and cold spots of spatial coefficients
Figure 4 · Hot and cold spots
How to read
  • Finds clusters of high spatial coefficients (hot spots, red) and low ones (cold spots, blue); grey = no cluster.
  • Answers whether areas where a factor acts especially strongly (or weakly) are contiguous — useful for defining priority regions.
In this case
  • Maternal mortality: 4 hot spots (e.g. Senegal, Zambia, Gambia), 30 cold spots (e.g. Republic of Serbia, Montenegro, Croatia).
  • High alcohol use: 16 hot spots (e.g. Brazil, Bolivia, Argentina), 30 cold spots (e.g. Saudi Arabia, Algeria, Oman).
  • High BMI: 22 hot spots (e.g. Lesotho, Guinea, Cambodia), 8 cold spots (e.g. Colombia, Angola, Germany).
  • Vitamin A deficiency: 2 hot spots (e.g. Malaysia, Thailand), 20 cold spots (e.g. Russia, Norway, Finland).
Figure 5 · STVPI: who contributes most
Figure 5 · STVPI: who contributes most
Figure 5 · STVPI panels
How to read
  • Top left (“Overall”): how much of the spatiotemporal variation is spatial and how much temporal.
  • Other panels: each factor’s contribution (space + time, spatial part, temporal part); circles = estimates, thick / thin bars = 50% / 95% credible intervals.
  • Percentages of different factors are comparable only when covariates are standardized.
In this case
  • By factor (space + time): GNI_pc 51.0%, urban_pop 11.3%, high_alcohol 9.5%, heat_exposure 8.7%, maternal_mortality 7.7%, vitA_deficiency 6.2%, high_BMI 3.0%, health_exp 1.6%, PM25 0.3%, physicians 0.1%, NDVI 0.1%, female_employment 0.0%.
  • Where intervals overlap heavily, do not over-interpret the ranking.
Figure 6 · Spatial and temporal shares of each factor
Figure 6 · Spatial and temporal shares of each factor
Figure 6 · STVPI stacked bars
How to read
  • One bar per factor; bar length = total contribution; the two segments = spatial and temporal parts.
In this case
  • The longest bars are the candidate key factors; a dominant spatial segment calls for place-specific action, a visible temporal segment for timing as well.
Figure 7 · Model fit
Figure 7 · Model fit
Figure 7 · Model fit
How to read
  • Observed values on the x-axis, fitted values on the y-axis; the closer to the dashed line, the better.
  • R² closer to 1 is better; RMSE is the typical error in the units of Y.
In this case
  • R² = 0.967, RMSE = 1.33 (3444 observed units).
Figure 8 · Fitted-value maps (several time points, one colour scale)
Figure 8 · Fitted-value maps (several time points, one colour scale)
Figure 8 · Fitted-value maps
How to read
  • Several time points side by side on one colour scale: colour changes are changes over time.
  • Areas and years missing in the data also get fitted values, which can be used to fill gaps.
In this case
  • Compare the first and last time points for the overall trend and any change in the spatial pattern.

Want to dig deeper into the local coefficients of each area? The full set of SHAP-style figures for this case is in the corresponding section of chapter 14.

PART 4Reading and publishing figures

13  Read & publish figures: from result tables to journal figures

The software exports six result tables. Every case comes with a ready-made R script that draws the full set of publication figures in one run (300 dpi PNG + vector PDF); for your own results you only change a few file names.

BSTVC softwareDownload All Tables (xlsx) One R scriptsource(case script) Nine core figuresPNG 300 dpi + PDF Read in orderfit→share→time→space→fit Write the paperlegends + templates
The full chain from software output to publication figure.

13.1  Reading order: the big picture first, then the details

  1. Figure 1, model evaluation: how well the model fits overall.
  2. Figures 5 and 6, STVPI: who are the main players, and do they act mainly between areas or over time? This tells you whether to focus on the spatial or the temporal figures.
  3. Figure 2, temporal coefficients: when effects are stronger or weaker than usual.
  4. Figures 3, 3b and 4, spatial coefficients (core): where effects are strong, how certain their direction is, and whether they cluster.
  5. Figures 7 and 8, fit: how well the model reproduces the observations, and the spatiotemporal pattern of the outcome itself.

It is the same order as reading a health check-up: the overall verdict first, then the key indicators, then the details.

13.2  The nine core figures: what they answer, how to read them, what to avoid

FigureQuestionHow to readAvoid
1 Model evaluationHow good is the fit overall?Lower DIC, WAIC and LS are better; compare only on the same data and YComparing DIC with WAIC
2 Temporal coefficientsWhen are effects stronger / weaker?Zero = the study-period average; read the level and trend of each curveTreating a temporal coefficient as the whole effect in that year (add the spatial coefficient)
3 Spatial coefficient mapsWhere are effects stronger / weaker?Red raises the outcome, blue lowers it; each map has its own classes — read the legend valuesComparing colour intensity across maps
3b Direction-probability mapsHow certain is the direction?Continuous 0–1: deep red = almost surely positive, deep blue = almost surely negative, white = uncertainReading it as effect size (use figure 3 for size)
4 Hot and cold spotsDo high (low) effects cluster?Red = cluster of high values, blue = cluster of low valuesTreating it as confirmatory (it is exploratory)
5 STVPI panelsWhich factors matter most? Space or time?Circles = estimates; thick / thin bars = 50% / 95% intervalsComparing percentages of unstandardized X
6 STVPI stacked barsWhat makes up each factor’s contribution?Bar length = total; two segments = spatial / temporalRanking without looking at the intervals
7 Model fitHow well are observations reproduced?Continuous / count: points near the dashed line, R²; binary: ROC curve and AUCReading it as predictive ability on new data
8 Fitted-value mapsHow is the outcome distributed in space and time?Several time points share one colour scaleColouring each time point separately and then comparing

13.3  Publication standard

All figures follow the conventions of international journals and contain no titles or long explanations inside the figure (journals expect these in the figure legend):

Layout
Single column 89 mm / double column 183 mm; about 7 pt sans-serif text; panels labelled with bold lowercase a, b, c.
Colour
Colour-blind-safe Okabe–Ito palette for categories; blue–white–red diverging scale for coefficients, with white at zero.
Formats
Every figure as a 300 dpi PNG and a vector PDF; the PDF can be fine-tuned in Illustrator or Inkscape.
Advanced Figure-legend templates
FigureLegend template
2Temporal coefficients of [covariates], [period]. Lines show posterior means; dark and light bands show 50% and 95% credible intervals. The dashed line marks the average over the study period.
3Spatial coefficients of [covariates] across [n] [areas]. Each map uses its own classification; red indicates a positive and blue a negative association with [outcome].
3bPosterior probability that the spatial coefficient is positive. Values close to 1 (red) or 0 (blue) indicate high certainty about the direction of the association.
5Spatiotemporal variance partitioning (STVPI). Points show posterior means; thick and thin bars show 50% and 95% credible intervals.
7Model fit. Observed versus fitted values (posterior means); the dashed line is the 1:1 line. / ROC curve of fitted probabilities.

Click any thumbnail to jump to that case’s figures.

Temporal
Spatial
Direction
STVPI
1 Africa U5MR
2 China COVID-19
3 US hepatitis B
4a US high suicide
4b US suicide deaths
5 BSVC 2016
(no temporal)
6 Global HALE

The map of China in case 2 is for illustration only; for publication, redraw it with an officially approved base map.

13.5  Writing it up: sentence templates

WhatTemplate (replace the brackets with your results)
Model and settingsWe fitted a Bayesian spatiotemporally varying coefficients model (BSTVC; BSTVC Desktop 26.10.25) to a [type] outcome for [N] areas × [T] time points with [K] standardized covariates and queen contiguity.
EvaluationThe model had a DIC of [ ], a WAIC of [ ] and an LS of [ ]; the R² (or AUC) between fitted and observed values was [ ] (Table S1).
Key factorsSTVPI showed that [factor A] ([x]%, 95% CrI [a]–[b]%) and [factor B] ([y]%) were the main contributors to spatiotemporal variation, mostly through the spatial component ([s]%).
Temporal patternRelative to the study-period average, the association of [factor A] was stronger in [period] and weaker in [period] (Fig. 2).
Spatial patternSpatial coefficients of [factor A] were higher in [region] and lower in [region]; in [region] the posterior probability of a positive association exceeded [0.9] (Figs. 3, 3b), forming a cluster of high values (Fig. 4).

14  Advanced: SHAP-style views of local coefficients (optional)

This optional module adds depth; the spatial coefficient maps of the previous chapter remain the core. Every area and time point has its own local regression coefficient — just as SHAP gives every sample and feature its own explanation value in machine learning — so the whole family of SHAP plots can be borrowed to explore the results from more angles.

Concept card · Local coefficients and SHAPwhy the analogy works
In one line
SHAP shows how much each feature pushed one prediction up or down; BSTVC’s local coefficients show how strongly each factor acts in each area and time point. Both are “local explanations”.
Analogy
A class average is a single number; a local explanation is a report for every student saying which subjects pulled the grade up and which pulled it down.
Why it matters
A map shows one factor at a time; SHAP-style plots put all factors and all areas side by side to reveal dominant factors, patterns and types of areas.
How to use it
Run run_local_coef(cfg) (already in each case script); it needs the modeling table (data in cfg) to read each area’s covariate values.
Say it to others
“BSTVC’s local coefficients are interpretable by design — like SHAP, one figure shows what drives each area.”
Note: “contribution” = local coefficient (spatial + temporal at that time point) × the area’s standardized covariate value. It describes how much the outcome is pushed up or down because the area deviates from the average on that factor.
FigureQuestionHow to read
9 Coefficient beeswarmHow much does each factor’s effect differ between areas?One dot per area; the wider the spread, the larger the differences; colour = the area’s covariate level
10 Mean effect strengthWhich factor acts most strongly overall?Longer bars = stronger (sign ignored); brackets give the share of areas with a positive coefficient
11 DependenceIs the effect stronger where the covariate is high?One dot per area; a rising black line = the higher X, the more positive the effect
12 Contribution waterfallWhich factors push one area’s outcome up or down?Red raises, blue lowers, sorted by size (default: the areas with the highest and lowest fitted values)
13 Area × factor heatmapWhich areas share an effect pattern?Red = stronger than other areas for that factor; neighbouring rows have similar patterns
14 Space-time heatmapHow does the most important factor’s effect change by area and time?Read across for time, down for areas
15 Area typesCan areas be grouped by their effect patterns?Left: each type’s mean coefficient profile; right: where each type is
16 Contribution beeswarmDoes each factor push the outcome up or down? (closest to the SHAP summary plot)Right = raises, left = lowers; red dots on the right = higher X, higher outcome
17 Coefficient distributionAre coefficients single-peaked or polarised across areas?Wider violin = more areas at that value
18 Decision plotHow does each area’s outcome build up step by step?One line per area; where a line bends, that factor makes the area stand out
19 Interaction dependenceDo two factors reinforce each other?Colour = level of the second factor; red dots at the top = mutual reinforcement
20 Dominant factorWhich factor should each area prioritise?Colour = the factor with the largest contribution in that area
22 Direction over timeHow does the share of areas with a positive effect change over time?Near 100% = positive almost everywhere; around 50% = direction varies by area

The sections below give the full set of advanced figures for every case, each with reading notes computed directly from the result tables.

14.1  Case 1 · Under-five mortality, Africa

Reading notes
How to read
  • Start with figures 16 and 10 to find the main players, then figures 12 and 20 for specific areas, and figure 15 to group areas into types.
In this case
  • Mean effect strength, strongest first: Population (7.43; positive in 25% of areas) > Urban population (4.12; positive in 40% of areas) > PM2.5 exposure (0.338; positive in 31% of areas).
  • Direction varies by area (positive in 20–80% of areas): Population, Urban population, PM2.5 exposure — best explored with figures 16 and 20 for area-specific action.
Figure 16 · Contribution beeswarm
Figure 16 · Contribution beeswarm
Figure 10 · Mean effect strength
Figure 10 · Mean effect strength
Figure 9 · Coefficient beeswarm
Figure 9 · Coefficient beeswarm
Figure 17 · Coefficient distribution
Figure 17 · Coefficient distribution
Figure 19 · Interaction dependence (the two strongest factors)
Figure 19 · Interaction dependence (the two strongest factors)
Figure 20 · Dominant factor
Figure 20 · Dominant factor
Figure 13 · Area × factor heatmap
Figure 13 · Area × factor heatmap
Figure 14 · Space-time heatmap of the most important factor
Figure 14 · Space-time heatmap of the most important factor
Figure 18 · Decision plot
Figure 18 · Decision plot
Figure 12 · Contribution waterfall (areas with the highest and lowest fitted value, last time point)
Figure 12 · Contribution waterfall (areas with the highest and lowest fitted value, last time point)
Figure 11 · Dependence
Figure 11 · Dependence
Figure 15 · Area types
Figure 15 · Area types
Figure 22 · Direction over time
Figure 22 · Direction over time

All advanced figures (PNG + PDF) are in Case-01-Continuous-Africa-U5MR\visualization\outputs\en\local_coef_module\.

14.2  Case 2 · COVID-19 occurrence, China

Reading notes
How to read
  • Start with figures 16 and 10 to find the main players, then figures 12 and 20 for specific areas, and figure 15 to group areas into types.
In this case
  • Mean effect strength, strongest first: Night-time light (1.74; positive in 39% of areas) > PM2.5 (0.865; positive in 71% of areas) > Mean temperature (0.608; positive in 0% of areas) > In-migration index (0.517; positive in 97% of areas) > Out-migration index (0.41; positive in 97% of areas) ….
  • Direction varies by area (positive in 20–80% of areas): Night-time light, PM2.5 — best explored with figures 16 and 20 for area-specific action.
  • Same direction in most areas: Mean temperature, In-migration index, Out-migration index, NDVI.
Figure 16 · Contribution beeswarm
Figure 16 · Contribution beeswarm
Figure 10 · Mean effect strength
Figure 10 · Mean effect strength
Figure 9 · Coefficient beeswarm
Figure 9 · Coefficient beeswarm
Figure 17 · Coefficient distribution
Figure 17 · Coefficient distribution
Figure 19 · Interaction dependence (the two strongest factors)
Figure 19 · Interaction dependence (the two strongest factors)
Figure 20 · Dominant factor (Map for illustration only; redraw with an officially approved base map for publication.)
Figure 20 · Dominant factor (Map for illustration only; redraw with an officially approved base map for publication.)
Figure 13 · Area × factor heatmap
Figure 13 · Area × factor heatmap
Figure 14 · Space-time heatmap of the most important factor
Figure 14 · Space-time heatmap of the most important factor
Figure 18 · Decision plot
Figure 18 · Decision plot
Figure 12 · Contribution waterfall (areas with the highest and lowest fitted value, last time point)
Figure 12 · Contribution waterfall (areas with the highest and lowest fitted value, last time point)
Figure 11 · Dependence
Figure 11 · Dependence
Figure 15 · Area types (Map for illustration only; redraw with an officially approved base map for publication.)
Figure 15 · Area types (Map for illustration only; redraw with an officially approved base map for publication.)
Figure 22 · Direction over time
Figure 22 · Direction over time

All advanced figures (PNG + PDF) are in Case-02-Binary-China-COVID-19\visualization\outputs\en\local_coef_module\.

14.3  Case 3 · Acute hepatitis B, United States

Note. With only five states, area types (figure 15) are not drawn; the other figures are illustrative only.
Reading notes
How to read
  • Start with figures 16 and 10 to find the main players, then figures 12 and 20 for specific areas, and figure 15 to group areas into types.
In this case
  • Mean effect strength, strongest first: Population density (9.42; positive in 60% of areas) > Poverty rate (4.61; positive in 100% of areas) > Uninsured rate (1.34; positive in 20% of areas) > Annual precipitation (0.342; positive in 20% of areas).
  • Direction varies by area (positive in 20–80% of areas): Population density, Uninsured rate, Annual precipitation — best explored with figures 16 and 20 for area-specific action.
  • Same direction in most areas: Poverty rate.
Figure 16 · Contribution beeswarm
Figure 16 · Contribution beeswarm
Figure 10 · Mean effect strength
Figure 10 · Mean effect strength
Figure 9 · Coefficient beeswarm
Figure 9 · Coefficient beeswarm
Figure 17 · Coefficient distribution
Figure 17 · Coefficient distribution
Figure 19 · Interaction dependence (the two strongest factors)
Figure 19 · Interaction dependence (the two strongest factors)
Figure 20 · Dominant factor
Figure 20 · Dominant factor
Figure 13 · Area × factor heatmap
Figure 13 · Area × factor heatmap
Figure 14 · Space-time heatmap of the most important factor
Figure 14 · Space-time heatmap of the most important factor
Figure 18 · Decision plot
Figure 18 · Decision plot
Figure 12 · Contribution waterfall (areas with the highest and lowest fitted value, last time point)
Figure 12 · Contribution waterfall (areas with the highest and lowest fitted value, last time point)
Figure 11 · Dependence
Figure 11 · Dependence
Figure 22 · Direction over time
Figure 22 · Direction over time

All advanced figures (PNG + PDF) are in Case-03-Count-US-Hepatitis-B\visualization\outputs\en\local_coef_module\.

14.4  Case 4a · High suicide-rate status, United States

Reading notes
How to read
  • Start with figures 16 and 10 to find the main players, then figures 12 and 20 for specific areas, and figure 15 to group areas into types.
In this case
  • Mean effect strength, strongest first: Population (4.93; positive in 8% of areas) > Drug overdose mortality (1.99; positive in 100% of areas) > Median household income (1.57; positive in 8% of areas) > Poverty rate (0.497; positive in 63% of areas).
  • Direction varies by area (positive in 20–80% of areas): Poverty rate — best explored with figures 16 and 20 for area-specific action.
  • Same direction in most areas: Population, Drug overdose mortality, Median household income.
Figure 16 · Contribution beeswarm
Figure 16 · Contribution beeswarm
Figure 10 · Mean effect strength
Figure 10 · Mean effect strength
Figure 9 · Coefficient beeswarm
Figure 9 · Coefficient beeswarm
Figure 17 · Coefficient distribution
Figure 17 · Coefficient distribution
Figure 19 · Interaction dependence (the two strongest factors)
Figure 19 · Interaction dependence (the two strongest factors)
Figure 20 · Dominant factor
Figure 20 · Dominant factor
Figure 13 · Area × factor heatmap
Figure 13 · Area × factor heatmap
Figure 14 · Space-time heatmap of the most important factor
Figure 14 · Space-time heatmap of the most important factor
Figure 18 · Decision plot
Figure 18 · Decision plot
Figure 12 · Contribution waterfall (areas with the highest and lowest fitted value, last time point)
Figure 12 · Contribution waterfall (areas with the highest and lowest fitted value, last time point)
Figure 11 · Dependence
Figure 11 · Dependence
Figure 15 · Area types
Figure 15 · Area types
Figure 22 · Direction over time
Figure 22 · Direction over time

All advanced figures (PNG + PDF) are in Case-04-US-Suicide-Binary-and-Count\visualization\outputs\en\local_coef_module\.

14.5  Case 4b · Suicide deaths, United States

Note. eff is negative in this model’s evaluation; the figures show the software output as it is, to be judged by the user.
Reading notes
How to read
  • Start with figures 16 and 10 to find the main players, then figures 12 and 20 for specific areas, and figure 15 to group areas into types.
In this case
  • Mean effect strength, strongest first: Population (29.3; positive in 33% of areas) > Median household income (1.44; positive in 61% of areas) > Poverty rate (1; positive in 53% of areas) > Drug overdose mortality (0.669; positive in 69% of areas).
  • Direction varies by area (positive in 20–80% of areas): Population, Median household income, Poverty rate, Drug overdose mortality — best explored with figures 16 and 20 for area-specific action.
Figure 16 · Contribution beeswarm
Figure 16 · Contribution beeswarm
Figure 10 · Mean effect strength
Figure 10 · Mean effect strength
Figure 9 · Coefficient beeswarm
Figure 9 · Coefficient beeswarm
Figure 17 · Coefficient distribution
Figure 17 · Coefficient distribution
Figure 19 · Interaction dependence (the two strongest factors)
Figure 19 · Interaction dependence (the two strongest factors)
Figure 20 · Dominant factor
Figure 20 · Dominant factor
Figure 13 · Area × factor heatmap
Figure 13 · Area × factor heatmap
Figure 14 · Space-time heatmap of the most important factor
Figure 14 · Space-time heatmap of the most important factor
Figure 18 · Decision plot
Figure 18 · Decision plot
Figure 12 · Contribution waterfall (areas with the highest and lowest fitted value, last time point)
Figure 12 · Contribution waterfall (areas with the highest and lowest fitted value, last time point)
Figure 11 · Dependence
Figure 11 · Dependence
Figure 15 · Area types
Figure 15 · Area types
Figure 22 · Direction over time
Figure 22 · Direction over time

All advanced figures (PNG + PDF) are in Case-04-US-Suicide-Binary-and-Count\visualization\outputs\en\local_coef_module\.

14.6  Case 5 · High suicide-rate status, 2016 (BSVC)

Note. A single time point: no space-time heatmap (figure 14) and no direction over time (figure 22).
Reading notes
How to read
  • Start with figures 16 and 10 to find the main players, then figures 12 and 20 for specific areas, and figure 15 to group areas into types.
In this case
  • Mean effect strength, strongest first: Population (2.42; positive in 0% of areas) > Median household income (2.34; positive in 0% of areas) > Poverty rate (1.39; positive in 0% of areas) > Drug overdose mortality (0.344; positive in 100% of areas).
  • Same direction in most areas: Population, Median household income, Poverty rate, Drug overdose mortality.
Figure 16 · Contribution beeswarm
Figure 16 · Contribution beeswarm
Figure 10 · Mean effect strength
Figure 10 · Mean effect strength
Figure 9 · Coefficient beeswarm
Figure 9 · Coefficient beeswarm
Figure 17 · Coefficient distribution
Figure 17 · Coefficient distribution
Figure 19 · Interaction dependence (the two strongest factors)
Figure 19 · Interaction dependence (the two strongest factors)
Figure 20 · Dominant factor
Figure 20 · Dominant factor
Figure 13 · Area × factor heatmap
Figure 13 · Area × factor heatmap
Figure 18 · Decision plot
Figure 18 · Decision plot
Figure 12 · Contribution waterfall (areas with the highest and lowest fitted value, last time point)
Figure 12 · Contribution waterfall (areas with the highest and lowest fitted value, last time point)
Figure 11 · Dependence
Figure 11 · Dependence
Figure 15 · Area types
Figure 15 · Area types

All advanced figures (PNG + PDF) are in Case-05-BSVC-US-Suicide-2016\visualization\outputs\en\local_coef_module\.

14.7  Case 6 · Healthy life expectancy, global

Reading notes
How to read
  • Start with figures 16 and 10 to find the main players, then figures 12 and 20 for specific areas, and figure 15 to group areas into types.
In this case
  • Mean effect strength, strongest first: GNI per capita (6.36; positive in 20% of areas) > High alcohol use (1.26; positive in 21% of areas) > Maternal mortality (1.06; positive in 27% of areas) > Urban population (0.943; positive in 52% of areas) > Heat exposure (0.755; positive in 34% of areas) ….
  • Direction varies by area (positive in 20–80% of areas): GNI per capita, High alcohol use, Maternal mortality, Urban population, Heat exposure — best explored with figures 16 and 20 for area-specific action.
  • Same direction in most areas: NDVI, Female employment.
Figure 16 · Contribution beeswarm
Figure 16 · Contribution beeswarm
Figure 10 · Mean effect strength
Figure 10 · Mean effect strength
Figure 9 · Coefficient beeswarm
Figure 9 · Coefficient beeswarm
Figure 17 · Coefficient distribution
Figure 17 · Coefficient distribution
Figure 19 · Interaction dependence (the two strongest factors)
Figure 19 · Interaction dependence (the two strongest factors)
Figure 20 · Dominant factor
Figure 20 · Dominant factor
Figure 13 · Area × factor heatmap
Figure 13 · Area × factor heatmap
Figure 14 · Space-time heatmap of the most important factor
Figure 14 · Space-time heatmap of the most important factor
Figure 18 · Decision plot
Figure 18 · Decision plot
Figure 12 · Contribution waterfall (areas with the highest and lowest fitted value, last time point)
Figure 12 · Contribution waterfall (areas with the highest and lowest fitted value, last time point)
Figure 11 · Dependence
Figure 11 · Dependence
Figure 15 · Area types
Figure 15 · Area types
Figure 22 · Direction over time
Figure 22 · Direction over time

All advanced figures (PNG + PDF) are in Case-06-Continuous-Global-HALE\visualization\outputs\en\local_coef_module\.

PART 5Reference

15  The six result tables

The six tables in Result Module (BSVC has no time.coefficients).
The six tables in Result Module (BSVC has no time.coefficients).
TableContentsUse
model.evaluationDIC, eff, LS, running_time (minutes), waic, pd2Read it first. Lower DIC, WAIC and LS are better; compare only on the same data and Y; report all values in a supplementary table
local.predictionFitted values for every area × time point (mean, SD, quantiles), observed y, predict_y; continuous outcomes also have fill_y (missing Y filled with fitted values)R² / AUC, gap filling, fitted-value maps
summary.random.effectsA summary of how much each factor varies over space and over timeLarger values = the factor’s effect varies more over space (or time)
time.coefficientsOne row per factor per time point: mean, sd, quantiles, time_index, explain_variableTemporal-coefficient plots; read as “stronger / weaker than the study-period average”
space.coefficientsOne row per area: X_mean, X_sd, X_0.025quant … X_0.975quant; the last column is the area IDJoin to the map by area ID; spatial coefficient and direction-probability maps
contribution.STVPIShares and intervals of space.X, time.X, space.time.X, plus the totals and residual (continuous only)Identify key factors; binary / count outcomes have no residual

The full effect in one area in one year = that area’s X_mean in space.coefficients + that year’s mean in time.coefficients (add the means). Without standardization, coefficients of different factors have different units and cannot be compared.

16  Plotting in R: three steps

  1. Install R (4.2 or later) and, once, the packages: install.packages(c("readxl","dplyr","tidyr","ggplot2","sf","patchwork","scales","RColorBrewer","classInt","ragg","systemfonts")).
  2. Set R’s working directory to a case folder (English-only path), e.g. setwd("D:/BSTVC_data/Case-01-Continuous-Africa-U5MR").
  3. source("visualization/Case1_Africa_U5MR.R"); the figures appear in visualization/outputs/.
Using your own results. Copy the closest case script and change a few entries in cfg: the result workbook xlsx, the map shp, the area ID key, the outcome type, the first time point t0, the modeling table data (for the advanced module) and the display names var_en. For core figures only, delete the run_local_coef line.
Example script: case 1
# Case 1: under-five mortality in 48 African countries, 2000-2020 (continuous)
# Run inside the R_visualization_en folder:  source("scripts/Case1_Africa_U5MR.R")   ->  outputs/Case1_Africa_U5MR/en/ (300 dpi PNG + vector PDF)
source("R/bstvc_plot_functions.R"); source("R/run_case.R")
source("R/bstvc_local_coef_functions.R"); source("R/run_local_coef.R")
cfg <- list(lang = "en",
  id = "Case1_Africa_U5MR", title = "Case 1 Africa under-five mortality",
  xlsx = "data/Case1_Africa_U5MR/all_result_tables.xlsx", shp = "data/Case1_Africa_U5MR/africa_countries_v2.shp", key = "iso3",
  data = "data/Case1_Africa_U5MR/model_data.csv",     # modelling table: covariate values for the optional module
  type = "continuous", standardized = TRUE, label_field = "name",
  t0 = 2000, tlab = "Year", time_col = "year", pred_times = c(2000, 2010, 2020), pred_label = "Under-five mortality (per 1,000)",
  var_en = c(urban_pop = "Urban population", PM25_exposure = "PM2.5 exposure", pop_million = "Population"))

run_case(cfg)          # core figures
run_local_coef(cfg)    # optional: SHAP-style local-coefficient figures
run_case.R: one configuration draws all core figures
# =====================================================================================
#  run_case.R  -  one call draws the full set of core figures for one BSTVC / BSVC workbook
# = "zh" "en"
#  Usage: source("R/bstvc_plot_functions.R"); source("R/run_case.R"); run_case(cfg)   (see scripts/*.R)
#  Output: outputs/<id>/<lang>/  (300 dpi PNG + vector PDF; no titles or captions inside the figures)
# =====================================================================================
.cfg_lang <- function(cfg) {                      # pick the language-specific settings (fields ending in _en)
  lang <- if (is.null(cfg$lang)) "zh" else cfg$lang; bstvc_lang(lang)
  if (lang == "en") for (f in c("tlab", "pred_label", "time_labels", "map_note", "label_field", "short", "title"))
    if (!is.null(cfg[[paste0(f, "_en")]])) cfg[[f]] <- cfg[[paste0(f, "_en")]]
  if (lang == "en" && !is.null(cfg$label_col)) cfg$label_col <- NULL
  cfg$lang <- lang; cfg
}
.saver <- function(cfg) function(p, stem, w, h) {   # cfg$map_note: one line under every map figure (e.g. a disclaimer)
  if (!is.null(cfg$map_note) && grepl("fig03|fig04|fig08_prediction_maps|fig15|fig20", stem)) {
    note <- grid::textGrob(cfg$map_note, x = unit(2, "mm"), hjust = 0, gp = grid::gpar(fontfamily = BSTVC_FONT, fontsize = 6, col = "grey35"))
    p <- patchwork::wrap_elements(full = p) / patchwork::wrap_elements(full = note) + patchwork::plot_layout(heights = unit(c(1, 4), c("null", "mm"))); h <- h + 4 }
  save_pub(p, paste0(cfg$id, "_", stem), w, h, outdir = cfg$outdir)
}
.read_case <- function(cfg) {
  res <- read_bstvc(cfg$xlsx); if (cfg$lang == "en") res <- translate_res(res, cfg$var_en)
  map <- sf::st_read(cfg$shp, quiet = TRUE)
  if (!is.null(cfg$drop)) map <- map[!as.character(map[[cfg$key]]) %in% cfg$drop, ]
  map <- map[!duplicated(as.character(map[[cfg$key]])), ]
  bb <- sf::st_bbox(map); list(res = res, map = map, asp = unname((bb[4] - bb[2]) / (bb[3] - bb[1])))
}
run_case <- function(cfg) {
  stopifnot(file.exists(cfg$xlsx), file.exists(cfg$shp))
  cfg <- .cfg_lang(cfg)
  cfg$outdir <- file.path(if (is.null(cfg$outdir)) file.path("outputs", cfg$id) else cfg$outdir, cfg$lang)
  dir.create(cfg$outdir, showWarnings = FALSE, recursive = TRUE)
  R <- .read_case(cfg); res <- R$res; map <- R$map; st <- "nature"; fac <- res$factors; k <- if (is.null(cfg[["k"]])) 6 else cfg[["k"]]
  nc <- min(3, length(fac)); nr <- ceiling(length(fac) / nc)
  mapH <- function(nr, ncol, extra = 8, legend = 0) { pw <- (183 - 4) / ncol - legend; round(nr * (R$asp * pw + 9) + extra) }
  S <- .saver(cfg)
  cat("\n=== ", cfg$title, " [", cfg$lang, "] ===\n", sep = "")
  # 1 global model evaluation
  ev <- res$model.evaluation; cat(check_model_eval(ev), sep = "\n")
  write.csv(model_eval_table(ev), file.path(cfg$outdir, paste0(cfg$id, "_model_evaluation.csv")), row.names = FALSE)
  S(plot_model_card(ev), "fig01_model_evaluation", 183, 55)
  # 2 temporal coefficients (BSTVC only)
  if (!is.null(res$time.coefficients))
    S(plot_time_coef(res$time.coefficients, cfg$t0, cfg$tlab, ncol = nc), "fig02_time_coefficients", 183, 12 + 42 * nr)
  # 3 spatial coefficients (core): coefficient maps + direction-probability maps; 4 hot / cold spots
  sc <- res$space.coefficients
  labs_map <- if (!is.null(cfg$label_field)) setNames(as.character(map[[cfg$label_field]]), as.character(map[[cfg$key]])) else NULL
  if (isTRUE(cfg$no_maps)) {
    S(plot_space_coef_intervals(sc, cfg$key, fac, labs_map, ncol = nc), "fig03_spatial_coefficients", 183, 20 + 60 * nr)
  } else {
    S(plot_space_coef_maps(map, cfg$key, sc, fac, ncol = nc, k = k, standardized = cfg$standardized), "fig03_spatial_coefficients", 183, mapH(nr, nc, 6, legend = 17))
    S(plot_direction_prob_maps(map, cfg$key, sc, fac, ncol = nc), "fig03b_direction_probability", 183, mapH(nr, nc, 16))
    hs <- plot_hotspot_maps(map, cfg$key, sc, fac, ncol = nc)
    if (!is.null(hs)) S(hs, "fig04_hotspots_Gi_star", 183, mapH(nr, nc, 14))
  }
  # 5-6 STVPI
  sv <- read_stvpi(res)
  S(plot_stvpi_facets(sv, ncol = 2), "fig05_STVPI_faceted", 183, 40 + 10 * length(fac))
  if (any(grepl("^time\\.", sv$effect))) S(plot_stvpi_stacked(sv), "fig06_STVPI_stacked", 120, 18 + 6 * length(fac))
  # 7-8 fit and predictions
  lp <- res$local.prediction; typ <- cfg$type
  S(plot_prediction_accuracy(lp, typ, logaxes = isTRUE(cfg$logaxes)), "fig07_prediction_accuracy", 89, 80)
  if (isTRUE(cfg$no_maps) && !is.null(cfg$time_col)) {
    S(plot_prediction_tiles(lp, cfg$key, cfg$time_col, labs_map, legend_title = cfg$pred_label, time_labels = cfg$time_labels), "fig08_prediction_tiles", 140, 110)
  } else if (!is.null(cfg$time_col) && cfg$time_col %in% names(lp)) {
    tm <- cfg$pred_times; ncp <- min(3, length(tm))
    p <- plot_prediction_maps(map, cfg$key, lp, cfg$time_col, tm, "predict_y", ncol = ncp, legend_title = cfg$pred_label)
    if (!is.null(cfg$time_labels)) p$data$time <- factor(cfg$time_labels[as.character(p$data$time)], levels = cfg$time_labels[as.character(tm)])
    S(p, "fig08_prediction_maps", 183, mapH(ceiling(length(tm) / ncp), ncp, 18))
  } else {
    S(plot_map_classed(map, cfg$key, data.frame(key = lp[[cfg$key]], value = lp$predict_y), NULL, k = 7, legend_title = cfg$pred_label), "fig08_prediction_map", 120, round(R$asp * 95 + 10))
  }
  invisible(res)
}

17  Troubleshooting

SymptomWhat to do
The window stays blank for a while after double-clickingNormal; the program is starting. Do not double-click again.
The map fails to loadA file is missing: select .shp .dbf .shx .prj (and .cpg) together.
The Data Check log shows “Error” but ends with “Success!”Normal progress messages; go by the card title.
Results look shifted on the mapRaw Data was used after an “Automatically Rearranged” check. Choose Checked Data and run again.
My column is missing from a drop-downA different table is loaded (e.g. the wide table instead of the converted long one). Reload and select again.
Run fails with Loop 0 is not valid: Edge 0 crosses edge …A polygon in the map crosses itself. See the fix in case 1.
The window stays grey with a running messageLarge models take time (case 6 about about 20 minutes). High CPU use and changing memory in Task Manager = still computing; if there is no activity for a long time and the window does not update, close and restart the software.
Error with a single XAt least two X are required.
eff or DIC is negativeThis is the genuine output for these data and settings; report it as it is and judge it in context (see case 4b).
k-nearest-neighbour matrix errors or gives no outputA documented limitation; use the default QUEEN matrix or another matrix.
Numbers differ slightly from this guideNormal numerical variation; the third or fourth significant digit may differ between runs.

17.1  Good habits

  1. Keep the program, data, maps and results in English-only paths.
  2. One folder per study: table, map and results together; never overwrite raw data, and give converted files new names.
  3. Start small: run with two or three complete X first, then add variables.
  4. Download all tables right after each run and note the settings next to them (Y, X and order, type, time, space, standardization, matrix, threads, software version, date) — the workbook does not store them.

18  Websites, resources and citation

Feedback: bstvc.research@gmail.com. Suggested subject “BSTVC V2 | short description”; include the software version, Windows version, steps, settings, the full message and screenshots; de-identify any data first.

18.1  How to cite

Please cite the methodological papers and state the software version (BSTVC Desktop 26.10.25), date of use and settings. For the methodology, see these published papers:

Free to download for research use.

Appendix

A. One-page checklist

  1. All paths in English.
  2. Table: long (or converted); missing values as NA; no duplicate (area, time); at least two X.
  3. Map: all files; ID field with the same name and type as in the table; valid polygons; islands noted.
  4. Data Input → two OK messages and three boxes.
  5. Data Check → “Automatically Rearranged” → Checked Data for modeling.
  6. Modeling: Y · X · Response Type · time · space · Standardize = Yes · QUEEN · Threads 20 → Run.
  7. Read the model evaluation first and record everything; download all tables at once and note the settings.
  8. Run the case script for figures; read them in the order evaluation → contributions → time → space → fit.

B. Accompanying files

This guideA single HTML file; open it in a browser and share it freely
Six case foldersData, maps, README.md (variables and expected results), reference_results_V2/ (V2 result tables), visualization/ (plotting script + publication figures + advanced figures)
R_visualizationPlotting code and data for all cases; one place to redraw every figure