General analytics
AuraScore 87/100

Civic Service Delivery Equity Scorecard Script Generator

Creates an R tidyverse script to calculate demographic-adjusted municipal service response time metrics from 311 ticket data.

Use this template when civic data scientists need to quantify municipal operational performance across socioeconomic sectors and generate automated equity scorecards for civic leadership reviews.

Template

Role: Principal Civic Data Scientist specializing in urban analytics and social equity benchmarking.

Context

  • Department Under Review: {{target_agency_name}}
  • Census Boundary File: {{census_tract_shapefile}}
  • Analysis Timespan: {{service_ticket_timespan}}
  • Social Vulnerability Indicators: {{demographic_equity_metrics}}
  • Operational SLA Standard: {{sla_target_hours}}

Task

Generate a complete R analytics script using tidyverse, sf, and modelsummary to join municipal 311 service records with demographic census data, compute resolution SLA compliance across demographic tiers, and generate an empirical equity index score.

Method

  1. Ingest municipal 311 service tickets for {{target_agency_name}} over the period defined by {{service_ticket_timespan}}.
  2. Read and validate spatial boundary geometries from {{census_tract_shapefile}} using the sf library.
  3. Execute a spatial point-in-polygon join to associate each service request with its corresponding census tract.
  4. Compute ticket resolution duration in hours and evaluate compliance against {{sla_target_hours}}.
  5. Merge tract-level demographic indicators from {{demographic_equity_metrics}} into the processed service data.
  6. Construct a generalized linear model to test for statistically significant response time disparities across socioeconomic tiers.
  7. Compute a normalized Service Delivery Equity Index (0-100 scale) aggregating baseline performance across tracts.
  8. Format findings into clean summary tibbles and export the final scorecard to disk.

Constraints

  • MUST write idiomatic, tidyverse-aligned R code adhering strictly to modern R style conventions.
  • MUST NOT hardcode absolute local file paths in the script logic.
  • Spatial coordinate reference systems (CRS) MUST be explicitly validated and aligned before spatial joins.
  • Script must handle missing resolution timestamps by categorizing tickets as unresolved rather than dropping rows.

Output format

Structure the generated output into three dedicated sections:

  1. Package Dependencies and Setup: Library import commands and CRS alignment parameters.
  2. Complete R Analytics Script: Fully annotated R script containing data ingestion, spatial joins, modeling, and index calculation.
  3. Metric Definition Reference: Explanations of the Equity Index formulas and linear model coefficients.

Self-review

  • Verify that spatial joins explicitly check for and resolve invalid geometries using sf functions.
  • Ensure that all 5 variables are meaningfully utilized in the generated script.
  • Confirm that statistical disparity tests properly control for request volume variations across tracts.
AuraScore breakdown
87/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering12/12 · Strong

Hard boundaries — what the model must and must not do.

Output specification12/14 · Strong

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency5/10 · Thin

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness3/5 · Adequate

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

data-analytics
data-general
public-sector-nonprofit
r
civic analytics
equity