Public
Edited
Oct 1, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
misd_drug_comparison_data = tidy(
drug_arrests_by_county.filter(d => d.county == county & d.year > 2004),
mutate({
close: (d) => Math.abs(d.m_drug_est - arrests)
})
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
felony_drug_arrests_2023 = Math.round(drug_arrests_by_county.filter(d => d.county == county & d.year == 2023).map(d => d.f_drug)[0])
Insert cell
felony_drug_arrests_for_chart = tidy(
drug_arrests_by_county.filter(d => d.county == county),
mutate({
close: (d) => Math.abs(d.f_drug - felony_drug_arrests)
})
)
Insert cell
total_drug_arrests_for_chart = tidy(
drug_arrests_by_county.filter(d => d.county == county),
mutate({
close: (d) => Math.abs(d.total_drug - total_drug_arrests)
})
)
Insert cell
number_of_arrests_fentanyl = Math.round(felony_drug_arrests*fentanyl_contam_pct)
Insert cell
number_of_people_fentanyl = number_of_arrests_fentanyl * 0.5
Insert cell
increase_in_prison_population = number_of_people_fentanyl * 1.5
Insert cell
prison_costs_due_to_fentanyl = (increase_in_prison_population *
marginal_cost_prison)
Insert cell
Insert cell
number_of_total_arrests_fentanyl = Math.round(total_drug_arrests*fentanyl_contam_pct)
Insert cell
armed_fentanyl_annual = number_of_total_arrests_fentanyl * fraction_armed * armed_fraction_in_system
Insert cell
armed_fentanyl_increase_in_prison_pop = armed_fentanyl_annual * 1.5
Insert cell
state_costs_prison_armed_fentanyl = armed_fentanyl_increase_in_prison_pop * marginal_cost_prison
Insert cell
Insert cell
petty_theft_input_comparison_data = tidy(
drug_arrests_by_county.filter(d => d.county == county & d.year > 2004),
mutate({
close: (d) => Math.abs(d.est_petty_theft_arrests - misdemeanor_theft_arrests)
})
)
Insert cell
estimated_misd_theft_arrests = Math.round(drug_arrests_by_county.filter(d => d.county == county & d.year == 2022).map(d => d.est_petty_theft_arrests)[0])
Insert cell
annual_jail_admissions_pretrial = misdemeanor_theft_arrests * pct_2priors
Insert cell
county_costs_pretrial_theft = annual_jail_admissions_pretrial *
alos_jail_theft *
marginal_cost_jail
Insert cell
people_sentenced_to_jail = annual_jail_admissions_pretrial *
pct_misd_theft_in_system * pct_custodial_sentence *
(1 - pct_sentenced_to_prison)
Insert cell
county_cost_jail_sentence_theft = people_sentenced_to_jail * (159/365) * marginal_cost_jail
Insert cell
people_sentenced_to_prison = annual_jail_admissions_pretrial *
pct_misd_theft_in_system *
pct_sentenced_to_prison *
pct_custodial_sentence
Insert cell
state_cost_prison_petty_theft_2priors = people_sentenced_to_prison *
marginal_cost_prison*1.5
Insert cell
Insert cell
state_costs = state_cost_of_prison_program_failure +
state_cost_prison_petty_theft_2priors +
state_costs_prison_armed_fentanyl +
prison_costs_due_to_fentanyl
Insert cell
county_costs = county_cost_jail_sentence_theft +
county_cost_of_jail_pretrial +
county_cost_of_jail_program_failure +
county_costs_pretrial_theft
Insert cell
cost_of_intervention_programs
Insert cell
county_cost_of_jail_pretrial
Insert cell
estimated_total_cost = cost_of_intervention_programs + county_costs + state_costs
Insert cell
total_increase_people_incarcerated = number_impacted *
failure_rate *
fail_to_prison_rate *
2 + // tmf prison sentence population
(1 - fail_to_prison_rate) * number_impacted * failure_rate + // tmf jail sentence population
(number_impacted * alos_jail) / 365 + // tmf jail pretrial population
increase_in_prison_population + // fentanyl sentencing enhancements prison population
armed_fentanyl_increase_in_prison_pop + // armed fentanyl sentence prison population
(annual_jail_admissions_pretrial * alos_jail_theft) / 365 + //theft pretrial population
people_sentenced_to_jail + // theft jail sentence population
people_sentenced_to_prison * 2 // theft prison sentence population
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
sud_spending_data = FileAttachment(
"average outpatient service rate -- all counties@3.csv"
).csv({ typed: true })
Insert cell
county_list = ["Alameda County",
"Alpine County",
"Amador County",
"Butte County",
"Calaveras County",
"Colusa County",
"Contra Costa County",
"Del Norte County",
"El Dorado County",
"Fresno County",
"Glenn County",
"Humboldt County",
"Imperial County",
"Inyo County",
"Kern County",
"Kings County",
"Lake County",
"Lassen County",
"Los Angeles County",
"Madera County",
"Marin County",
"Mariposa County",
"Mendocino County",
"Merced County",
"Modoc County",
"Mono County",
"Monterey County",
"Napa County",
"Nevada County",
"Orange County",
"Placer County",
"Plumas County",
"Riverside County",
"Sacramento County",
"San Benito County",
"San Bernardino County",
"San Diego County",
"San Francisco County",
"San Joaquin County",
"San Luis Obispo County",
"San Mateo County",
"Santa Barbara County",
"Santa Clara County",
"Santa Cruz County",
"Shasta County",
"Sierra County",
"Siskiyou County",
"Solano County",
"Sonoma County",
"Stanislaus County",
"Sutter County",
"Tehama County",
"Trinity County",
"Tulare County",
"Tuolumne County",
"Ventura County",
"Yolo County",
"Yuba County"]
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more