Skip to contents

Interpolation

High-level wrappers and core optimization engine.

interpolate_election_br()
Interpolate Brazilian election data into census tracts
interpolate_election()
One-step IDW interpolation from source points to census tracts
reinterpolate()
Re-interpolate with different electoral variables
optimize_alpha()
Find optimal decay parameters (alpha) for spatial interpolation
compute_weight_matrix()
Compute the weight matrix
compute_travel_times()
Compute a travel-time matrix from census tract representative points to source points

Control Objects

Group tuning parameters for optimization and routing.

optim_control()
Optimization control parameters
routing_control()
Routing control parameters

Results

S3 methods for inspecting, plotting, and exporting results.

summary(<interpElections_result>)
Summarize an interpElections result
plot(<interpElections_result>) autoplot(<interpElections_result>)
Plot an interpolated variable as a choropleth map
plot_interactive()
Interactive map of interpolated results
coef(<interpElections_result>)
Extract alpha coefficients
residuals(<interpElections_result>)
Compute calibration residuals
as.data.frame(<interpElections_result>)
Convert result to data frame
save_interpolation()
Save an interpolation result to disk
load_interpolation()
Load an interpolation result from disk

Diagnostics

Model validation, residual analysis, and weight matrix diagnostics.

diagnostics()
Run diagnostic checks on an interpolation result
print(<interpElections_diagnostics>)
Print method for interpElections_diagnostics
plot_convergence()
Plot optimization convergence diagnostics
plot_alpha()
Plot alpha decay parameter diagnostics
plot_residuals()
Plot calibration residual diagnostics
residual_summary()
Tabular residual summary
plot_weights()
Plot weight matrix diagnostics
plot_connections()
Plot tract-station connections
weight_summary()
Summarize weight matrix properties per tract
plot_travel_times()
Plot travel time matrix diagnostics
plot_residual_autocorrelation()
Test residuals for spatial autocorrelation
plot_moran()
Moran's I and LISA cluster map for an interpolated variable
plot_income()
Plot income-vote ecological correlation
plot_turnout_rates()
Plot implied turnout rates by demographic bracket
plot_ecological()
Cross-election consistency check
plot_representative_points()
Plot representative point diagnostics

Setup

Configure GPU, Java, and cache.

setup_java()
Download and configure Java 21 for r5r
set_java_memory()
Set Java heap memory for r5r
setup_torch()
Install and configure torch with GPU support
use_gpu()
Enable or disable GPU acceleration
interpElections_cache()
Manage the interpElections download cache

Data

Bundled reference datasets.

muni_crosswalk
IBGE-TSE Municipality Code Crosswalk
br_election_dates
Brazilian election dates