Njira
How WorldScope handles data. This document is a contract: code in packages/core implements it, tests verify it, and the public methodology page is derived from it. If behaviour and this document disagree, one of them is a bug.
Tsambali lapangidwa kuchokera ku ndondomeko ya ndondomeko ya polojekiti, yomwe ndi gwero limodzi la choonadi.
1. Data semantics
- An observation is a value for one indicator, one country (or aggregate) and one year, as published by a provider.
nullmeans "no value reported". It is never0, never interpolated and never carried forward.- Aggregates (regions, income groups, "World") are flagged
is_aggregate. They are excluded from rankings, percentiles, correlation and notable-change lists unless explicitly requested. - Coverage = reporting series ÷ expected series for the request, plus per-country first/last year and count of missing years. Coverage is always returned and always displayable.
- Revisions: upstream values change. We record
updated_atwhen a stored value changes, and every response carriesretrievedAt. - Names: country and territory names follow the provider's naming. We do not adjudicate disputed territories; we use provider naming and boundaries with a neutral notice.
2. Year alignment
Comparing a value from 2023 with one from 2019 without saying so is misleading. The align option controls behaviour.
| Mode | Behaviour | Use |
|---|---|---|
exact | Use only the requested year(s); countries without a value are shown as "no data" | Cross-sections for a chosen year |
latest-each (default for profiles) | Each country's most recent non-null value, each labelled with its own year | "Where do things stand?" |
latest-common | The most recent year in which at least 60% of requested countries report; countries not reporting that year are shown as "no data" | Fair side-by-side comparison |
latest-common algorithm
- For each year descending, count requested countries with a non-null value.
- Choose the first year where
count / N ≥ 0.6. - If none qualifies, fall back to
latest-eachand add warningALIGNMENT_FALLBACK. - Always return
meta.coverage.alignmentwith the chosen year and threshold status.
How the modes meet the requested period (T0.13). For a time series (a range, or mrv), latest is resolved per mode: latest-common ends every series at the common year, the others at the latest year any country reports, so a country that stopped reporting shows null after its last value (never a carried-forward one). mrv N is the last N years ending there. For a single year Y (a cross-section), exact uses Y only, latest-each uses each country's most recent value on or before Y, and latest-common applies the algorithm above to years up to Y. A country with no value still gets a point, with value: null, labelled with the year that was asked about.
When values in a view come from different years, the UI must show the year next to each value and the response includes warning YEAR_MISMATCH.
3. Peer benchmarking and percentile rank
Peer groups: Sub-Saharan Africa (provider region), SADC (curated), income group (provider), and any custom group.
Peer set for a (group, indicator, year): all non-aggregate members of the group with a non-null value in that year. N is the count of reporting members, not group size.
Definitions (for country value x among values v₁…v_N)
- Rank: position
kwhen sorted from highest to lowest; ties share the best rank ("competition ranking"). Displayed as "k of N reporting countries, highest to lowest". - Percentile (mid-rank):
P = 100 × (count(v < x) + 0.5 × count(v = x)) / N. This is the fraction of the peer set below the country, counting half of exact ties, and it is stable whenNis small. - Peer summary: min, p25, median, p75, max, plus the country's marker on that range. Quartiles use linear interpolation between order statistics (the "type 7" method, the default in Excel and NumPy), so p25 of
[1, 2, 3, 4]is1.75. The marker is the country's fraction along[min, max], and is absent when every peer has the same value. The storedpeer_statdistribution adds p10, p90 and the mean by the same method, so p10 of[1, 2, 3, 4]is1.3and p90 is3.7. It is computed for every group and year with at least one reporting member, from current membership, and never includes an aggregate or a missing value.
Rules
- Rank and percentile are computed for one aligned year; show the year.
- If
N < 5, show rank and values but suppress percentile and show "few reporting countries". - No valuation. "Ranked 3rd highest" is fine; "ranked 3rd best" is not. A high percentile says nothing about whether a result is desirable for unemployment or mortality, so charts use neutral sequential colours, never red/green semantics.
- Show direction explicitly ("highest → lowest") so a rank isn't misread.
- Group membership uses the current membership by default. Historical benchmarking (membership as of year Y) is available via
validAtbut not default, since income classifications are re-issued yearly. - Percentile and rank are pure functions in
packages/core, covered by unit and property tests (ties, all-equal, N=1, N=2, NaN rejected).
4. Notable changes ("what's changing?")
Zokonzedwa
Njirayi ikufotokozedwa m'machitidwe athu koma sizinapezekebe. Palibe chilichonse patsambali chomwe chimagwiritsa ntchito lero.Purpose: surface large recent movements so users can investigate, without judging them.
5. Correlation explorer
- Inputs: indicator X, indicator Y, a year (or "latest common"), optional peer group.
- Points are countries with non-null X and Y in the chosen year. Aggregates excluded.
- Output: scatter points,
N, Pearson r and Spearman ρ, optional log-scale axes. - Always displayed with: "Correlation does not imply causation" and the note that country-level correlations do not describe individuals (ecological fallacy).
- Suppress coefficients if
N < 10; show points only. Spearman ρ is the Pearson r of the mid-ranks (tied values share the average of their ranks). A coefficient is undefined, and reported as absent rather than 0, when either variable is constant. - Highlight the selected country (default Malawi when in that context) and label outliers on hover/focus.
6. Derived series options
- Index (base = 100): each series divided by its value in the first common year × 100. Requires all series non-null in that year, otherwise disabled with an explanation.
- Log scale: allowed only for strictly positive series.
- Downsampling for display (LTTB) affects rendering only; tables and exports always contain every point. Missing values are never dropped or bridged: each run of non-null points is downsampled on its own and keeps its first and last point, so a gap is always visible.
7. Plain-language explainers
Goal: make definitions readable without inventing facts.
Three layers, always labelled:
| Layer | Source | Label in UI |
|---|---|---|
| Official definition | Provider source_note, verbatim | "Official definition (World Bank)" |
| Simplified | LLM rewrite constrained to the official text (no added facts, same units, no new numbers) | "Simplified from the official definition" |
| Editorial caveat | Human-written, sourced, dated | "Context note" |
Rules:
- The generation prompt receives only the indicator name, unit and
source_note; output is validated (no digits absent from the source; length limit; reading-level target). - Each simplified text stores
source_hash, model/version, and review status. If the source note changes, the explainer is hidden until regenerated. - Publish only reviewed simplified text for curated indicators; for the long tail, show the official definition alone.
- Never answer "what does this mean for Malawi?" from model memory. Interpretation comes from data and editorial notes only.
8. Citation format
Every export and "Cite this" button produces (APA-style, adjustable later):
World Bank. (data year range or publication year). GDP per capita (current US$) [NY.GDP.PCAP.CD]. World Development Indicators. Retrieved 19 September 2026 via WorldScope: permalink.
Rules: include indicator code, dataset name, retrieval date and the permalink to the exact QuerySpec. Include the licence line where the provider requires it, on its own line after the citation. The retrieval date is shown as a UTC calendar date, and the permalink must be an http(s) URL.
10. Known limitations (shown in the UI)
- Latest available year differs by indicator and country; lags of 1-3 years are common.
- Series can be sparse or have methodology breaks.
- Cross-country comparability depends on the indicator's definition and source.
- Upstream revisions may change historical values between retrievals.
- Translations of metadata are incomplete; English is the fallback.