tables for manuscript. recreated ruca table

This commit is contained in:
2025-10-10 08:58:06 -07:00
parent 388f0ae1c2
commit abff7981c2
54 changed files with 679283 additions and 17766 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,7 @@
Period,Rurality,Poisson Δ,Poisson p,NB Δ,NB p
Before 2020,Rural,"0.01 (-0.10, 0.12)",0.828,"-9.83 (-14.87, -4.51)",<0.001
Before 2020,Suburban,"0.02 (-0.21, 0.25)",0.862,"-7.10 (-15.48, 1.48)",0.107
Before 2020,Urban,"0.13 (0.05, 0.21)",<0.001,"-1.64 (-2.86, -0.46)",0.008
2020 and After,Rural,"0.07 (0.00, 0.14)",0.049,"-13.92 (-18.48, -9.26)",<0.001
2020 and After,Suburban,"0.14 (0.02, 0.26)",0.022,"-7.23 (-13.89, -0.40)",0.037
2020 and After,Urban,"0.29 (0.24, 0.34)",<0.001,"-2.87 (-3.73, -2.01)",<0.001
1 Period Rurality Poisson Δ Poisson p NB Δ NB p
2 Before 2020 Rural 0.01 (-0.10, 0.12) 0.828 -9.83 (-14.87, -4.51) <0.001
3 Before 2020 Suburban 0.02 (-0.21, 0.25) 0.862 -7.10 (-15.48, 1.48) 0.107
4 Before 2020 Urban 0.13 (0.05, 0.21) <0.001 -1.64 (-2.86, -0.46) 0.008
5 2020 and After Rural 0.07 (0.00, 0.14) 0.049 -13.92 (-18.48, -9.26) <0.001
6 2020 and After Suburban 0.14 (0.02, 0.26) 0.022 -7.23 (-13.89, -0.40) 0.037
7 2020 and After Urban 0.29 (0.24, 0.34) <0.001 -2.87 (-3.73, -2.01) <0.001

View File

@@ -0,0 +1,7 @@
Period,Rurality,Poisson Δ (days),NB Δ (days),Difference (NB - Poisson),Poisson p,NB p
Before 2020,Rural,0.0125075677145938,-9.826219107892053,-9.838726675606646,0.828,0.0004
Before 2020,Suburban,0.0192862765678301,-7.100280417538358,-7.119566694106188,0.862,0.1072
Before 2020,Urban,0.1305571823770012,-1.6388416472647436,-1.7693988296417449,0.0,0.008
2020 and After,Rural,0.0727709345083023,-13.917287633807826,-13.990058568316128,0.049,0.0
2020 and After,Suburban,0.1438421422124148,-7.230488621220758,-7.374330763433172,0.022,0.0368
2020 and After,Urban,0.2921678186765097,-2.869383763253332,-3.161551581929842,0.0,0.0
1 Period Rurality Poisson Δ (days) NB Δ (days) Difference (NB - Poisson) Poisson p NB p
2 Before 2020 Rural 0.0125075677145938 -9.826219107892053 -9.838726675606646 0.828 0.0004
3 Before 2020 Suburban 0.0192862765678301 -7.100280417538358 -7.119566694106188 0.862 0.1072
4 Before 2020 Urban 0.1305571823770012 -1.6388416472647436 -1.7693988296417449 0.0 0.008
5 2020 and After Rural 0.0727709345083023 -13.917287633807826 -13.990058568316128 0.049 0.0
6 2020 and After Suburban 0.1438421422124148 -7.230488621220758 -7.374330763433172 0.022 0.0368
7 2020 and After Urban 0.2921678186765097 -2.869383763253332 -3.161551581929842 0.0 0.0

View File

@@ -0,0 +1,13 @@
Period,Rurality,Model,Δ (days),95% CI Lower,95% CI Upper,p-value,Δ (hours),Hours CI Lower,Hours CI Upper
Before 2020,Rural,Poisson,0.0125075677145938,-0.1007299005887473,0.1242653832992618,0.828,0.3001816251502512,-2.417517614129935,2.9823691991822834
Before 2020,Rural,Negative Binomial,-9.826219107892053,-14.869599396708646,-4.507633417615492,0.0004,-235.82925858940928,-356.8703855210075,-108.1832020227718
Before 2020,Suburban,Poisson,0.0192862765678301,-0.2070683547625284,0.2474055366045697,0.862,0.4628706376279224,-4.969640514300682,5.937732878509673
Before 2020,Suburban,Negative Binomial,-7.100280417538358,-15.484324609933072,1.4802600357437907,0.1072,-170.4067300209206,-371.62379063839376,35.52624085785098
Before 2020,Urban,Poisson,0.1305571823770012,0.0529612911724684,0.2084385013879577,0.0,3.133372377048029,1.2710709881392417,5.002524033310984
Before 2020,Urban,Negative Binomial,-1.6388416472647436,-2.8560915098428508,-0.4644060319162429,0.008,-39.33219953435385,-68.54619623622841,-11.14574476598983
2020 and After,Rural,Poisson,0.0727709345083023,0.0005333461979639,0.144294044390127,0.049,1.7465024281992552,0.0128003087511336,3.463057065363048
2020 and After,Rural,Negative Binomial,-13.917287633807826,-18.48415448898385,-9.260262673475022,0.0,-334.01490321138783,-443.6197077356125,-222.2463041634005
2020 and After,Suburban,Poisson,0.1438421422124148,0.0193728479256509,0.2640026911376328,0.022,3.452211413097955,0.4649483502156215,6.336064587303188
2020 and After,Suburban,Negative Binomial,-7.230488621220758,-13.88880956784627,-0.396495094273276,0.0368,-173.5317269092982,-333.3314296283105,-9.515882262558623
2020 and After,Urban,Poisson,0.2921678186765097,0.2442461679633707,0.3427039893841879,0.0,7.0120276482362325,5.861908031120897,8.22489574522051
2020 and After,Urban,Negative Binomial,-2.869383763253332,-3.7289121485454073,-2.005130365939876,0.0,-68.86521031807997,-89.49389156508977,-48.12312878255703
1 Period Rurality Model Δ (days) 95% CI Lower 95% CI Upper p-value Δ (hours) Hours CI Lower Hours CI Upper
2 Before 2020 Rural Poisson 0.0125075677145938 -0.1007299005887473 0.1242653832992618 0.828 0.3001816251502512 -2.417517614129935 2.9823691991822834
3 Before 2020 Rural Negative Binomial -9.826219107892053 -14.869599396708646 -4.507633417615492 0.0004 -235.82925858940928 -356.8703855210075 -108.1832020227718
4 Before 2020 Suburban Poisson 0.0192862765678301 -0.2070683547625284 0.2474055366045697 0.862 0.4628706376279224 -4.969640514300682 5.937732878509673
5 Before 2020 Suburban Negative Binomial -7.100280417538358 -15.484324609933072 1.4802600357437907 0.1072 -170.4067300209206 -371.62379063839376 35.52624085785098
6 Before 2020 Urban Poisson 0.1305571823770012 0.0529612911724684 0.2084385013879577 0.0 3.133372377048029 1.2710709881392417 5.002524033310984
7 Before 2020 Urban Negative Binomial -1.6388416472647436 -2.8560915098428508 -0.4644060319162429 0.008 -39.33219953435385 -68.54619623622841 -11.14574476598983
8 2020 and After Rural Poisson 0.0727709345083023 0.0005333461979639 0.144294044390127 0.049 1.7465024281992552 0.0128003087511336 3.463057065363048
9 2020 and After Rural Negative Binomial -13.917287633807826 -18.48415448898385 -9.260262673475022 0.0 -334.01490321138783 -443.6197077356125 -222.2463041634005
10 2020 and After Suburban Poisson 0.1438421422124148 0.0193728479256509 0.2640026911376328 0.022 3.452211413097955 0.4649483502156215 6.336064587303188
11 2020 and After Suburban Negative Binomial -7.230488621220758 -13.88880956784627 -0.396495094273276 0.0368 -173.5317269092982 -333.3314296283105 -9.515882262558623
12 2020 and After Urban Poisson 0.2921678186765097 0.2442461679633707 0.3427039893841879 0.0 7.0120276482362325 5.861908031120897 8.22489574522051
13 2020 and After Urban Negative Binomial -2.869383763253332 -3.7289121485454073 -2.005130365939876 0.0 -68.86521031807997 -89.49389156508977 -48.12312878255703

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

View File

@@ -0,0 +1,53 @@
import pandas as pd
# Load the data with counts by strata
df = pd.read_csv("poisson_predicted_groups_boot_final.csv")
# Create a pivot table with counts
counts_table = df.pivot_table(
index=["spill_type", "Period"],
columns="rurality",
values="n",
aggfunc="first"
)
# Reorder columns
counts_table = counts_table[["Urban", "Suburban", "Rural"]]
# Add total column
counts_table["Total"] = counts_table.sum(axis=1)
# Reset index to make it cleaner
counts_table = counts_table.reset_index()
# Rename columns for publication
counts_table.columns.name = None
counts_table.rename(columns={
"spill_type": "Spill Type",
"Period": "Period"
}, inplace=True)
# Save to CSV
counts_table.to_csv("table3_cell_counts_by_strata.csv", index=False)
print("Table 3: Cell Counts by Strata")
print("="*80)
print(counts_table.to_string(index=False))
print("\n")
print(f"Total observations: {counts_table['Total'].sum():,.0f}")
# Also create a formatted version for Word
counts_table_formatted = counts_table.copy()
for col in ["Urban", "Suburban", "Rural", "Total"]:
counts_table_formatted[col] = counts_table_formatted[col].apply(lambda x: f"{int(x):,}")
print("\n" + "="*80)
print("Formatted for Word/LaTeX:")
print("="*80)
print(counts_table_formatted.to_string(index=False))
# Save formatted version
counts_table_formatted.to_csv("table3_cell_counts_formatted.csv", index=False)
print("\n✓ Saved: table3_cell_counts_by_strata.csv")
print("✓ Saved: table3_cell_counts_formatted.csv")

View File

@@ -1,7 +1,7 @@
spill_type,rurality,n_months,cov_type_used,immediate_median,immediate_ci_lower,immediate_ci_upper,immediate_p_boot,slope_median,slope_ci_lower,slope_ci_upper,slope_p_boot
Historical,Urban,117,HAC(3),-0.6250991837929991,-0.9772868254796147,-0.2619678514805641,0.0040000000000000036,0.008677356602081509,0.0024123586979186433,0.01534362269873128,0.012
Historical,Suburban,65,HAC(3),-1.5555203555268773,-2.760016526399644,-0.37589988751216996,0.008000000000000007,0.018111983033016497,-0.002105555534072708,0.03884445206697719,0.084
Historical,Rural,105,HAC(3),-0.24590595010391308,-0.824718160817529,0.40663717560118645,0.45799999999999996,0.00013021988464623603,-0.0107828487359158,0.010256027360183254,0.976
Recent,Urban,118,HAC(3),-0.15628489133359408,-0.5468189876262599,0.26330563995054274,0.44799999999999995,0.001369074917704279,-0.005773664319305678,0.008682893452063814,0.7
Recent,Suburban,92,HAC(3),-0.23244391793278704,-1.2135798544269085,0.67739991550723,0.6359999999999999,-0.003999467175621145,-0.017363911188202664,0.010956067039010234,0.562
Recent,Rural,118,HAC(3),-0.02527235325752801,-0.36146457009829014,0.35820151045927684,0.8859999999999999,-0.002781214701541218,-0.008208128151727126,0.002389512920216333,0.27
Historical,Urban,117,HAC(3),-0.6143298365704635,-0.9701974488679479,-0.2576102437589131,0.0020000000000000018,0.008548526458438652,0.0025645936683214026,0.014992999515163894,0.008
Historical,Suburban,65,HAC(3),-1.5419172264856993,-2.8005057370759436,-0.5092818284564702,0.0020000000000000018,0.018288851239152915,-0.001413811154498385,0.04054252593164273,0.076
Historical,Rural,105,HAC(3),-0.2319822274291954,-0.8686730523534315,0.39757251088646645,0.44599999999999995,-6.973679570138947e-05,-0.011328809843695048,0.011024892423937206,0.98
Recent,Urban,118,HAC(3),-0.17454324356137912,-0.5863332553476475,0.2245678547101131,0.44599999999999995,0.0016865010996214614,-0.005893803703454753,0.009254460119298775,0.686
Recent,Suburban,92,HAC(3),-0.17958384840540031,-1.2130013501446437,0.7370245819198297,0.6759999999999999,-0.0047429405935390115,-0.01925760998354386,0.00966656492524187,0.528
Recent,Rural,118,HAC(3),-0.015990389127948444,-0.3694722611284897,0.34107009362805324,0.9039999999999999,-0.003043894243530523,-0.008093280725626546,0.002427039704067753,0.252
1 spill_type rurality n_months cov_type_used immediate_median immediate_ci_lower immediate_ci_upper immediate_p_boot slope_median slope_ci_lower slope_ci_upper slope_p_boot
2 Historical Urban 117 HAC(3) -0.6250991837929991 -0.6143298365704635 -0.9772868254796147 -0.9701974488679479 -0.2619678514805641 -0.2576102437589131 0.0040000000000000036 0.0020000000000000018 0.008677356602081509 0.008548526458438652 0.0024123586979186433 0.0025645936683214026 0.01534362269873128 0.014992999515163894 0.012 0.008
3 Historical Suburban 65 HAC(3) -1.5555203555268773 -1.5419172264856993 -2.760016526399644 -2.8005057370759436 -0.37589988751216996 -0.5092818284564702 0.008000000000000007 0.0020000000000000018 0.018111983033016497 0.018288851239152915 -0.002105555534072708 -0.001413811154498385 0.03884445206697719 0.04054252593164273 0.084 0.076
4 Historical Rural 105 HAC(3) -0.24590595010391308 -0.2319822274291954 -0.824718160817529 -0.8686730523534315 0.40663717560118645 0.39757251088646645 0.45799999999999996 0.44599999999999995 0.00013021988464623603 -6.973679570138947e-05 -0.0107828487359158 -0.011328809843695048 0.010256027360183254 0.011024892423937206 0.976 0.98
5 Recent Urban 118 HAC(3) -0.15628489133359408 -0.17454324356137912 -0.5468189876262599 -0.5863332553476475 0.26330563995054274 0.2245678547101131 0.44799999999999995 0.44599999999999995 0.001369074917704279 0.0016865010996214614 -0.005773664319305678 -0.005893803703454753 0.008682893452063814 0.009254460119298775 0.7 0.686
6 Recent Suburban 92 HAC(3) -0.23244391793278704 -0.17958384840540031 -1.2135798544269085 -1.2130013501446437 0.67739991550723 0.7370245819198297 0.6359999999999999 0.6759999999999999 -0.003999467175621145 -0.0047429405935390115 -0.017363911188202664 -0.01925760998354386 0.010956067039010234 0.00966656492524187 0.562 0.528
7 Recent Rural 118 HAC(3) -0.02527235325752801 -0.015990389127948444 -0.36146457009829014 -0.3694722611284897 0.35820151045927684 0.34107009362805324 0.8859999999999999 0.9039999999999999 -0.002781214701541218 -0.003043894243530523 -0.008208128151727126 -0.008093280725626546 0.002389512920216333 0.002427039704067753 0.27 0.252

Binary file not shown.

Before

Width:  |  Height:  |  Size: 329 KiB

After

Width:  |  Height:  |  Size: 329 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 682 KiB

After

Width:  |  Height:  |  Size: 684 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

View File

@@ -1,7 +1,7 @@
spill_type,rurality,n_months,cov_type,coef_post,p_post,coef_timepost,p_timepost
Historical,Urban,118,OLS-GLM,-2.2558997513868926,1.3476569456688608e-63,0.030369443639893377,1.2996649901502465e-48
Historical,Suburban,118,OLS-GLM,-1.34383735287832,0.009457923117687337,0.016932518245171085,0.0417093239079251
Historical,Rural,118,OLS-GLM,-2.7164423892570597,1.3022260138535194e-21,0.04369289171690502,3.1047832219194077e-23
Recent,Urban,118,OLS-GLM,-0.23865705652862768,0.14267759889367287,0.0008995270283667922,0.7140399407335487
Recent,Suburban,118,OLS-GLM,0.4297773652745585,0.16457183794635,-0.0008188605523384556,0.8724230164238238
Recent,Rural,118,OLS-GLM,0.734195574412651,4.848782193840399e-09,-0.011298705684153811,7.335729970141464e-09
Historical,Urban,118,OLS-GLM,-2.255899751382564,2.7246131918171756e-125,0.03036944363983375,2.2088667696862934e-95
Historical,Suburban,118,OLS-GLM,-1.3438373528783196,0.00024260336632732281,0.01693251824517155,0.003977799711160122
Historical,Rural,118,OLS-GLM,-2.716442389257058,1.4582406399745034e-41,0.04369289171690913,8.608891702162188e-45
Recent,Urban,118,OLS-GLM,-0.238657056528626,0.0381643759487025,0.0008995270283673768,0.6043058843976774
Recent,Suburban,118,OLS-GLM,0.4297773652745612,0.04934982898288095,-0.0008188605523375405,0.8203486639361263
Recent,Rural,118,OLS-GLM,0.7341955744126516,1.2698239565857607e-16,-0.011298705684153568,2.8746860921086824e-16
1 spill_type rurality n_months cov_type coef_post p_post coef_timepost p_timepost
2 Historical Urban 118 OLS-GLM -2.2558997513868926 -2.255899751382564 1.3476569456688608e-63 2.7246131918171756e-125 0.030369443639893377 0.03036944363983375 1.2996649901502465e-48 2.2088667696862934e-95
3 Historical Suburban 118 OLS-GLM -1.34383735287832 -1.3438373528783196 0.009457923117687337 0.00024260336632732281 0.016932518245171085 0.01693251824517155 0.0417093239079251 0.003977799711160122
4 Historical Rural 118 OLS-GLM -2.7164423892570597 -2.716442389257058 1.3022260138535194e-21 1.4582406399745034e-41 0.04369289171690502 0.04369289171690913 3.1047832219194077e-23 8.608891702162188e-45
5 Recent Urban 118 OLS-GLM -0.23865705652862768 -0.238657056528626 0.14267759889367287 0.0381643759487025 0.0008995270283667922 0.0008995270283673768 0.7140399407335487 0.6043058843976774
6 Recent Suburban 118 OLS-GLM 0.4297773652745585 0.4297773652745612 0.16457183794635 0.04934982898288095 -0.0008188605523384556 -0.0008188605523375405 0.8724230164238238 0.8203486639361263
7 Recent Rural 118 OLS-GLM 0.734195574412651 0.7341955744126516 4.848782193840399e-09 1.2698239565857607e-16 -0.011298705684153811 -0.011298705684153568 7.335729970141464e-09 2.8746860921086824e-16

View File

@@ -1,7 +1,7 @@
spill_type,rurality,n_months,status,cov_type,R_squared,cov_type_used,immediate_median,immediate_ci_lower,immediate_ci_upper,immediate_p_boot,slope_median,slope_ci_lower,slope_ci_upper,slope_p_boot
Historical,Urban,117,ok,HAC(3),0.4510030209910569,HAC(3),-0.6250991837929991,-0.9772868254796147,-0.2619678514805641,0.0040000000000000036,0.008677356602081509,0.0024123586979186433,0.01534362269873128,0.012
Historical,Suburban,65,ok,HAC(3),0.1452643863997323,HAC(3),-1.5555203555268773,-2.760016526399644,-0.37589988751216996,0.008000000000000007,0.018111983033016497,-0.002105555534072708,0.03884445206697719,0.084
Historical,Rural,105,ok,HAC(3),0.0788182219726172,HAC(3),-0.24590595010391308,-0.824718160817529,0.40663717560118645,0.45799999999999996,0.00013021988464623603,-0.0107828487359158,0.010256027360183254,0.976
Recent,Urban,118,ok,HAC(3),0.1959564116019398,HAC(3),-0.15628489133359408,-0.5468189876262599,0.26330563995054274,0.44799999999999995,0.001369074917704279,-0.005773664319305678,0.008682893452063814,0.7
Recent,Suburban,92,ok,HAC(3),0.0658293631915236,HAC(3),-0.23244391793278704,-1.2135798544269085,0.67739991550723,0.6359999999999999,-0.003999467175621145,-0.017363911188202664,0.010956067039010234,0.562
Recent,Rural,118,ok,HAC(3),0.1709315051206097,HAC(3),-0.02527235325752801,-0.36146457009829014,0.35820151045927684,0.8859999999999999,-0.002781214701541218,-0.008208128151727126,0.002389512920216333,0.27
Historical,Urban,117,ok,HAC(3),0.4510030209910569,HAC(3),-0.6143298365704635,-0.9701974488679479,-0.2576102437589131,0.0020000000000000018,0.008548526458438652,0.0025645936683214026,0.014992999515163894,0.008
Historical,Suburban,65,ok,HAC(3),0.1452643863997323,HAC(3),-1.5419172264856993,-2.8005057370759436,-0.5092818284564702,0.0020000000000000018,0.018288851239152915,-0.001413811154498385,0.04054252593164273,0.076
Historical,Rural,105,ok,HAC(3),0.0788182219726172,HAC(3),-0.2319822274291954,-0.8686730523534315,0.39757251088646645,0.44599999999999995,-6.973679570138947e-05,-0.011328809843695048,0.011024892423937206,0.98
Recent,Urban,118,ok,HAC(3),0.1959564116019398,HAC(3),-0.17454324356137912,-0.5863332553476475,0.2245678547101131,0.44599999999999995,0.0016865010996214614,-0.005893803703454753,0.009254460119298775,0.686
Recent,Suburban,92,ok,HAC(3),0.0658293631915236,HAC(3),-0.17958384840540031,-1.2130013501446437,0.7370245819198297,0.6759999999999999,-0.0047429405935390115,-0.01925760998354386,0.00966656492524187,0.528
Recent,Rural,118,ok,HAC(3),0.1709315051206097,HAC(3),-0.015990389127948444,-0.3694722611284897,0.34107009362805324,0.9039999999999999,-0.003043894243530523,-0.008093280725626546,0.002427039704067753,0.252
1 spill_type rurality n_months status cov_type R_squared cov_type_used immediate_median immediate_ci_lower immediate_ci_upper immediate_p_boot slope_median slope_ci_lower slope_ci_upper slope_p_boot
2 Historical Urban 117 ok HAC(3) 0.4510030209910569 HAC(3) -0.6250991837929991 -0.6143298365704635 -0.9772868254796147 -0.9701974488679479 -0.2619678514805641 -0.2576102437589131 0.0040000000000000036 0.0020000000000000018 0.008677356602081509 0.008548526458438652 0.0024123586979186433 0.0025645936683214026 0.01534362269873128 0.014992999515163894 0.012 0.008
3 Historical Suburban 65 ok HAC(3) 0.1452643863997323 HAC(3) -1.5555203555268773 -1.5419172264856993 -2.760016526399644 -2.8005057370759436 -0.37589988751216996 -0.5092818284564702 0.008000000000000007 0.0020000000000000018 0.018111983033016497 0.018288851239152915 -0.002105555534072708 -0.001413811154498385 0.03884445206697719 0.04054252593164273 0.084 0.076
4 Historical Rural 105 ok HAC(3) 0.0788182219726172 HAC(3) -0.24590595010391308 -0.2319822274291954 -0.824718160817529 -0.8686730523534315 0.40663717560118645 0.39757251088646645 0.45799999999999996 0.44599999999999995 0.00013021988464623603 -6.973679570138947e-05 -0.0107828487359158 -0.011328809843695048 0.010256027360183254 0.011024892423937206 0.976 0.98
5 Recent Urban 118 ok HAC(3) 0.1959564116019398 HAC(3) -0.15628489133359408 -0.17454324356137912 -0.5468189876262599 -0.5863332553476475 0.26330563995054274 0.2245678547101131 0.44799999999999995 0.44599999999999995 0.001369074917704279 0.0016865010996214614 -0.005773664319305678 -0.005893803703454753 0.008682893452063814 0.009254460119298775 0.7 0.686
6 Recent Suburban 92 ok HAC(3) 0.0658293631915236 HAC(3) -0.23244391793278704 -0.17958384840540031 -1.2135798544269085 -1.2130013501446437 0.67739991550723 0.7370245819198297 0.6359999999999999 0.6759999999999999 -0.003999467175621145 -0.0047429405935390115 -0.017363911188202664 -0.01925760998354386 0.010956067039010234 0.00966656492524187 0.562 0.528
7 Recent Rural 118 ok HAC(3) 0.1709315051206097 HAC(3) -0.02527235325752801 -0.015990389127948444 -0.36146457009829014 -0.3694722611284897 0.35820151045927684 0.34107009362805324 0.8859999999999999 0.9039999999999999 -0.002781214701541218 -0.003043894243530523 -0.008208128151727126 -0.008093280725626546 0.002389512920216333 0.002427039704067753 0.27 0.252

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
spill_type,rurality,median_days,ci_lower_days,ci_upper_days,median_hours
Historical,Rural,0.2764117602827311,0.15162950848434606,0.4062470235857321,6.6338822467855465
Historical,Suburban,0.36538461538461653,0.14574604189988757,0.5849992003838161,8.769230769230797
Historical,Urban,0.4586609329592761,0.4092283066452901,0.5158414737344518,11.007862391022627
Recent,Rural,0.2208484333698994,0.16234478809493721,0.280090515780138,5.300362400877585
Recent,Suburban,0.23802863254895285,0.09616929954473215,0.381120070210082,5.712687181174868
Recent,Urban,0.2985415486404179,0.22800245049959508,0.3745836583142008,7.164997167370029
Historical,Rural,0.2792941825199912,0.18920250896057408,0.36402752713236397,6.703060380479789
Historical,Suburban,0.3649248360786824,0.210704861666399,0.5258276027506784,8.758196065888377
Historical,Urban,0.459127653406465,0.42214597011939387,0.5004701859256199,11.01906368175516
Recent,Rural,0.21930069265228186,0.17925021985486714,0.26096825583475497,5.263216623654765
Recent,Suburban,0.23813833580165716,0.13572486424222685,0.33975885853765675,5.715320059239772
Recent,Urban,0.29845327415934986,0.24341382135127804,0.3515924814466669,7.162878579824397
1 spill_type rurality median_days ci_lower_days ci_upper_days median_hours
2 Historical Rural 0.2764117602827311 0.2792941825199912 0.15162950848434606 0.18920250896057408 0.4062470235857321 0.36402752713236397 6.6338822467855465 6.703060380479789
3 Historical Suburban 0.36538461538461653 0.3649248360786824 0.14574604189988757 0.210704861666399 0.5849992003838161 0.5258276027506784 8.769230769230797 8.758196065888377
4 Historical Urban 0.4586609329592761 0.459127653406465 0.4092283066452901 0.42214597011939387 0.5158414737344518 0.5004701859256199 11.007862391022627 11.01906368175516
5 Recent Rural 0.2208484333698994 0.21930069265228186 0.16234478809493721 0.17925021985486714 0.280090515780138 0.26096825583475497 5.300362400877585 5.263216623654765
6 Recent Suburban 0.23802863254895285 0.23813833580165716 0.09616929954473215 0.13572486424222685 0.381120070210082 0.33975885853765675 5.712687181174868 5.715320059239772
7 Recent Urban 0.2985415486404179 0.29845327415934986 0.22800245049959508 0.24341382135127804 0.3745836583142008 0.3515924814466669 7.164997167370029 7.162878579824397

View File

@@ -1,7 +1,7 @@
Period,rurality,median_abs_days,ci_lower_days,ci_upper_days,median_hours,median_pct
2020 and After,Rural,0.0741556691931361,0.004211424865189661,0.14743252321887296,1.7797360606352663,12.14421494676097
2020 and After,Suburban,0.14399257847758565,0.01829931802226303,0.26364122622271274,3.4558218834620558,34.39021282018639
2020 and After,Urban,0.2907137007004865,0.2412791155568189,0.3423369570028581,6.9771288168116765,84.50834690052037
Before 2020,Rural,0.019487413464827796,-0.10395835344078816,0.1311231585227802,0.4676979231558671,2.170352426399535
Before 2020,Suburban,0.018630280766201046,-0.2184466019417477,0.24982944109157806,0.4471267383888251,2.3447517860415865
Before 2020,Urban,0.130829377379724,0.052385515416715656,0.20981495104457498,3.139905057113376,16.265299903092888
2020 and After,Rural,0.07315732015423265,0.022000128646317785,0.1246457312649859,1.7557756837015837,11.967316896166922
2020 and After,Suburban,0.1425634339584798,0.05204426169224218,0.22851937284792515,3.4215224150035155,34.00743786702261
2020 and After,Urban,0.29364475502530796,0.2571924732032934,0.32893155220798037,7.047474120607391,85.39737138492738
Before 2020,Rural,0.014226206666607732,-0.07197236577726011,0.09882694939940774,0.3414289599985856,1.6015122067228986
Before 2020,Suburban,0.01656389399107938,-0.15140875098399656,0.1764792705326647,0.39753345578590515,2.1262938297360243
Before 2020,Urban,0.1314453872073093,0.07393383677505205,0.1853898439521118,3.1546892929754233,16.303629300809273
1 Period rurality median_abs_days ci_lower_days ci_upper_days median_hours median_pct
2 2020 and After Rural 0.0741556691931361 0.07315732015423265 0.004211424865189661 0.022000128646317785 0.14743252321887296 0.1246457312649859 1.7797360606352663 1.7557756837015837 12.14421494676097 11.967316896166922
3 2020 and After Suburban 0.14399257847758565 0.1425634339584798 0.01829931802226303 0.05204426169224218 0.26364122622271274 0.22851937284792515 3.4558218834620558 3.4215224150035155 34.39021282018639 34.00743786702261
4 2020 and After Urban 0.2907137007004865 0.29364475502530796 0.2412791155568189 0.2571924732032934 0.3423369570028581 0.32893155220798037 6.9771288168116765 7.047474120607391 84.50834690052037 85.39737138492738
5 Before 2020 Rural 0.019487413464827796 0.014226206666607732 -0.10395835344078816 -0.07197236577726011 0.1311231585227802 0.09882694939940774 0.4676979231558671 0.3414289599985856 2.170352426399535 1.6015122067228986
6 Before 2020 Suburban 0.018630280766201046 0.01656389399107938 -0.2184466019417477 -0.15140875098399656 0.24982944109157806 0.1764792705326647 0.4471267383888251 0.39753345578590515 2.3447517860415865 2.1262938297360243
7 Before 2020 Urban 0.130829377379724 0.1314453872073093 0.052385515416715656 0.07393383677505205 0.20981495104457498 0.1853898439521118 3.139905057113376 3.1546892929754233 16.265299903092888 16.303629300809273

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,13 @@
contrast_type,spill_type,Period,rurality,comparison,median,ci_lower,ci_upper,p_value
Period,Historical,,Rural,Before - After,0.2764117602827311,0.15162950848434606,0.4062470235857321,0.0
Period,Historical,,Suburban,Before - After,0.36538461538461653,0.14574604189988757,0.5849992003838161,0.001
Period,Historical,,Urban,Before - After,0.4586609329592761,0.4092283066452901,0.5158414737344518,0.0
Period,Recent,,Rural,Before - After,0.2208484333698994,0.16234478809493721,0.280090515780138,0.0
Period,Recent,,Suburban,Before - After,0.23802863254895285,0.09616929954473215,0.381120070210082,0.0
Period,Recent,,Urban,Before - After,0.2985415486404179,0.22800245049959508,0.3745836583142008,0.0
SpillType,,2020 and After,Rural,Recent - Historical,0.0741556691931361,0.004211424865189661,0.14743252321887296,0.038
SpillType,,2020 and After,Suburban,Recent - Historical,0.14399257847758565,0.01829931802226303,0.26364122622271274,0.021
SpillType,,2020 and After,Urban,Recent - Historical,0.2907137007004865,0.2412791155568189,0.3423369570028581,0.0
SpillType,,Before 2020,Rural,Recent - Historical,0.019487413464827796,-0.10395835344078816,0.1311231585227802,0.763
SpillType,,Before 2020,Suburban,Recent - Historical,0.018630280766201046,-0.2184466019417477,0.24982944109157806,0.879
SpillType,,Before 2020,Urban,Recent - Historical,0.130829377379724,0.052385515416715656,0.20981495104457498,0.0
Period,Historical,,Rural,Before - After,0.2792941825199912,0.18920250896057408,0.36402752713236397,0.0
Period,Historical,,Suburban,Before - After,0.3649248360786824,0.210704861666399,0.5258276027506784,0.0
Period,Historical,,Urban,Before - After,0.459127653406465,0.42214597011939387,0.5004701859256199,0.0
Period,Recent,,Rural,Before - After,0.21930069265228186,0.17925021985486714,0.26096825583475497,0.0
Period,Recent,,Suburban,Before - After,0.23813833580165716,0.13572486424222685,0.33975885853765675,0.0
Period,Recent,,Urban,Before - After,0.29845327415934986,0.24341382135127804,0.3515924814466669,0.0
SpillType,,2020 and After,Rural,Recent - Historical,0.07315732015423265,0.022000128646317785,0.1246457312649859,0.006
SpillType,,2020 and After,Suburban,Recent - Historical,0.1425634339584798,0.05204426169224218,0.22851937284792515,0.001
SpillType,,2020 and After,Urban,Recent - Historical,0.29364475502530796,0.2571924732032934,0.32893155220798037,0.0
SpillType,,Before 2020,Rural,Recent - Historical,0.014226206666607732,-0.07197236577726011,0.09882694939940774,0.734
SpillType,,Before 2020,Suburban,Recent - Historical,0.01656389399107938,-0.15140875098399656,0.1764792705326647,0.84
SpillType,,Before 2020,Urban,Recent - Historical,0.1314453872073093,0.07393383677505205,0.1853898439521118,0.0
1 contrast_type spill_type Period rurality comparison median ci_lower ci_upper p_value
2 Period Historical Rural Before - After 0.2764117602827311 0.2792941825199912 0.15162950848434606 0.18920250896057408 0.4062470235857321 0.36402752713236397 0.0
3 Period Historical Suburban Before - After 0.36538461538461653 0.3649248360786824 0.14574604189988757 0.210704861666399 0.5849992003838161 0.5258276027506784 0.001 0.0
4 Period Historical Urban Before - After 0.4586609329592761 0.459127653406465 0.4092283066452901 0.42214597011939387 0.5158414737344518 0.5004701859256199 0.0
5 Period Recent Rural Before - After 0.2208484333698994 0.21930069265228186 0.16234478809493721 0.17925021985486714 0.280090515780138 0.26096825583475497 0.0
6 Period Recent Suburban Before - After 0.23802863254895285 0.23813833580165716 0.09616929954473215 0.13572486424222685 0.381120070210082 0.33975885853765675 0.0
7 Period Recent Urban Before - After 0.2985415486404179 0.29845327415934986 0.22800245049959508 0.24341382135127804 0.3745836583142008 0.3515924814466669 0.0
8 SpillType 2020 and After Rural Recent - Historical 0.0741556691931361 0.07315732015423265 0.004211424865189661 0.022000128646317785 0.14743252321887296 0.1246457312649859 0.038 0.006
9 SpillType 2020 and After Suburban Recent - Historical 0.14399257847758565 0.1425634339584798 0.01829931802226303 0.05204426169224218 0.26364122622271274 0.22851937284792515 0.021 0.001
10 SpillType 2020 and After Urban Recent - Historical 0.2907137007004865 0.29364475502530796 0.2412791155568189 0.2571924732032934 0.3423369570028581 0.32893155220798037 0.0
11 SpillType Before 2020 Rural Recent - Historical 0.019487413464827796 0.014226206666607732 -0.10395835344078816 -0.07197236577726011 0.1311231585227802 0.09882694939940774 0.763 0.734
12 SpillType Before 2020 Suburban Recent - Historical 0.018630280766201046 0.01656389399107938 -0.2184466019417477 -0.15140875098399656 0.24982944109157806 0.1764792705326647 0.879 0.84
13 SpillType Before 2020 Urban Recent - Historical 0.130829377379724 0.1314453872073093 0.052385515416715656 0.07393383677505205 0.20981495104457498 0.1853898439521118 0.0

View File

@@ -1,13 +1,13 @@
spill_type,Period,rurality,pred_mean,ci_lower,ci_upper,n,pred_median_boot,ci_lower_boot,ci_upper_boot,pred_median_npboot,ci_lower_npboot,ci_upper_npboot
Historical,2020 and After,Rural,0.6093189964157697,0.5478743705834819,0.6776546948120998,558,0.6093189964157705,0.5448028673835126,0.6720430107526851,0.6096073547725431,0.5586004543160028,0.6646965087643066
Historical,2020 and After,Suburban,0.42011834319526453,0.3329283283724966,0.5301423977705431,169,0.42011834319526487,0.3254437869822484,0.5147928994082847,0.41875000000000007,0.32926639903045,0.5200136986301357
Historical,2020 and After,Urban,0.3444994290064705,0.3227699462514921,0.36769178160507127,2627,0.3444994290064708,0.3224210125618575,0.36810049486105806,0.3440305320467083,0.3252725558294595,0.3644760086525086
Historical,Before 2020,Rural,0.8881118881118876,0.7853397269730921,1.0043331550865073,286,0.8846153846153855,0.7797202797202769,0.9965909090909086,0.8872657733629041,0.8161251120071694,0.963976959044562
Historical,Before 2020,Suburban,0.7837837837837845,0.6059349205795946,1.0138333323565736,74,0.7837837837837832,0.5810810810810829,0.9868243243243267,0.7826086956521745,0.5796910755148731,0.9726119955572049
Historical,Before 2020,Urban,0.8045417680454156,0.7560010921988318,0.8561991023677035,1233,0.8037307380373095,0.7558799675587965,0.8548459042984564,0.8044515806561483,0.7656491145489733,0.8422833419823558
Recent,2020 and After,Rural,0.6839481555333987,0.6486978802574822,0.7211139325318346,2006,0.6829511465603179,0.647557328015953,0.718344965104685,0.6859175525360229,0.6563384862052262,0.7148843825984128
Recent,2020 and After,Suburban,0.5621468926553657,0.489224984417794,0.6459382472016476,354,0.5621468926553679,0.48870056497175085,0.6384887005649743,0.561529443882385,0.4901362984218071,0.631288507581804
Recent,2020 and After,Urban,0.636728147554129,0.5939439753667028,0.6825942356556498,1247,0.6351242983159581,0.5926222935044123,0.6808340016038464,0.6366835287354293,0.5991867409414826,0.6748372168058338
Recent,Before 2020,Rural,0.9033877038895861,0.8579117829215046,0.9512741983327778,1594,0.9037013801756578,0.8575909661229606,0.952321204516935,0.9030185434005366,0.8728050324527968,0.9383551968041549
Recent,Before 2020,Suburban,0.800970873786409,0.687621671804964,0.9330048294873011,206,0.8009708737864077,0.674757281553401,0.9223300970873809,0.8022616917965761,0.7058602941176474,0.8904968944099336
Recent,Before 2020,Urban,0.9354207436399179,0.8779639126262511,0.9966377376655905,1022,0.934442270058707,0.8767123287671218,0.9961105675146799,0.9346761236158347,0.8895441574912045,0.9809577616357241
Historical,2020 and After,Rural,0.6093189964157685,0.5651998386422391,0.6568820689775993,1116,0.6102150537634419,0.5636200716845869,0.656810035842294,0.6092919688120166,0.571689483934517,0.6476423213679935
Historical,2020 and After,Suburban,0.42011834319526564,0.3564011403776044,0.4952268730176765,338,0.41715976331360954,0.3550295857988165,0.49112426035502776,0.4203750453750451,0.3527337667210736,0.48596630062120166
Historical,2020 and After,Urban,0.34449942900647024,0.3289884305754048,0.36074173300930823,5254,0.3439284354777313,0.32813094784925795,0.3603016749143509,0.3452927456737533,0.3298515634484981,0.3587135421888017
Historical,Before 2020,Rural,0.8881118881118854,0.8141436277138147,0.9688004658594644,572,0.8898601398601386,0.8146416083916047,0.9685314685314674,0.8888888888888886,0.8363628188358396,0.9418859649122788
Historical,Before 2020,Suburban,0.7837837837837821,0.6533753451795489,0.9402206928294898,148,0.7837837837837851,0.6486486486486477,0.9324324324324287,0.7786259541984739,0.6499780701754369,0.9124173320922949
Historical,Before 2020,Urban,0.8045417680454152,0.7699068889663325,0.8407347249466527,2466,0.8033252230332523,0.7700628548256254,0.839821573398215,0.8042057857567823,0.7753651081091886,0.8338192437962373
Recent,2020 and After,Rural,0.6839481555333978,0.6588300067720765,0.7100239434288064,4012,0.6836989032901286,0.6580259222333001,0.7086303589232316,0.6840065533741847,0.6622297036277904,0.7038139854690473
Recent,2020 and After,Suburban,0.5621468926553672,0.5095445400887737,0.6201795997402488,708,0.5607344632768358,0.5070621468926572,0.618644067796611,0.5634483913380187,0.5142719780219798,0.6113440150399716
Recent,2020 and After,Urban,0.6367281475541288,0.6061685025702591,0.6688284398952602,2494,0.6375300721732182,0.6050320769847629,0.6696070569366496,0.637318078161549,0.6117763644963592,0.6648766747736713
Recent,Before 2020,Rural,0.9033877038895849,0.8709890182597942,0.936991542292295,3188,0.9027603513174434,0.8707575282308662,0.9350846925972415,0.9033740296165678,0.8794566490673464,0.9306380145278438
Recent,Before 2020,Suburban,0.8009708737864075,0.7190494526516675,0.8922256157601893,412,0.800970873786407,0.716019417475729,0.8907766990291225,0.8010204081632639,0.7388816699636662,0.8615265602941665
Recent,Before 2020,Urban,0.9354207436399201,0.8944171388431081,0.9783041151957946,2044,0.934931506849313,0.8933463796477465,0.978485812133073,0.9350196850393682,0.9050659124404135,0.9671188279855178
1 spill_type Period rurality pred_mean ci_lower ci_upper n pred_median_boot ci_lower_boot ci_upper_boot pred_median_npboot ci_lower_npboot ci_upper_npboot
2 Historical 2020 and After Rural 0.6093189964157697 0.6093189964157685 0.5478743705834819 0.5651998386422391 0.6776546948120998 0.6568820689775993 558 1116 0.6093189964157705 0.6102150537634419 0.5448028673835126 0.5636200716845869 0.6720430107526851 0.656810035842294 0.6096073547725431 0.6092919688120166 0.5586004543160028 0.571689483934517 0.6646965087643066 0.6476423213679935
3 Historical 2020 and After Suburban 0.42011834319526453 0.42011834319526564 0.3329283283724966 0.3564011403776044 0.5301423977705431 0.4952268730176765 169 338 0.42011834319526487 0.41715976331360954 0.3254437869822484 0.3550295857988165 0.5147928994082847 0.49112426035502776 0.41875000000000007 0.4203750453750451 0.32926639903045 0.3527337667210736 0.5200136986301357 0.48596630062120166
4 Historical 2020 and After Urban 0.3444994290064705 0.34449942900647024 0.3227699462514921 0.3289884305754048 0.36769178160507127 0.36074173300930823 2627 5254 0.3444994290064708 0.3439284354777313 0.3224210125618575 0.32813094784925795 0.36810049486105806 0.3603016749143509 0.3440305320467083 0.3452927456737533 0.3252725558294595 0.3298515634484981 0.3644760086525086 0.3587135421888017
5 Historical Before 2020 Rural 0.8881118881118876 0.8881118881118854 0.7853397269730921 0.8141436277138147 1.0043331550865073 0.9688004658594644 286 572 0.8846153846153855 0.8898601398601386 0.7797202797202769 0.8146416083916047 0.9965909090909086 0.9685314685314674 0.8872657733629041 0.8888888888888886 0.8161251120071694 0.8363628188358396 0.963976959044562 0.9418859649122788
6 Historical Before 2020 Suburban 0.7837837837837845 0.7837837837837821 0.6059349205795946 0.6533753451795489 1.0138333323565736 0.9402206928294898 74 148 0.7837837837837832 0.7837837837837851 0.5810810810810829 0.6486486486486477 0.9868243243243267 0.9324324324324287 0.7826086956521745 0.7786259541984739 0.5796910755148731 0.6499780701754369 0.9726119955572049 0.9124173320922949
7 Historical Before 2020 Urban 0.8045417680454156 0.8045417680454152 0.7560010921988318 0.7699068889663325 0.8561991023677035 0.8407347249466527 1233 2466 0.8037307380373095 0.8033252230332523 0.7558799675587965 0.7700628548256254 0.8548459042984564 0.839821573398215 0.8044515806561483 0.8042057857567823 0.7656491145489733 0.7753651081091886 0.8422833419823558 0.8338192437962373
8 Recent 2020 and After Rural 0.6839481555333987 0.6839481555333978 0.6486978802574822 0.6588300067720765 0.7211139325318346 0.7100239434288064 2006 4012 0.6829511465603179 0.6836989032901286 0.647557328015953 0.6580259222333001 0.718344965104685 0.7086303589232316 0.6859175525360229 0.6840065533741847 0.6563384862052262 0.6622297036277904 0.7148843825984128 0.7038139854690473
9 Recent 2020 and After Suburban 0.5621468926553657 0.5621468926553672 0.489224984417794 0.5095445400887737 0.6459382472016476 0.6201795997402488 354 708 0.5621468926553679 0.5607344632768358 0.48870056497175085 0.5070621468926572 0.6384887005649743 0.618644067796611 0.561529443882385 0.5634483913380187 0.4901362984218071 0.5142719780219798 0.631288507581804 0.6113440150399716
10 Recent 2020 and After Urban 0.636728147554129 0.6367281475541288 0.5939439753667028 0.6061685025702591 0.6825942356556498 0.6688284398952602 1247 2494 0.6351242983159581 0.6375300721732182 0.5926222935044123 0.6050320769847629 0.6808340016038464 0.6696070569366496 0.6366835287354293 0.637318078161549 0.5991867409414826 0.6117763644963592 0.6748372168058338 0.6648766747736713
11 Recent Before 2020 Rural 0.9033877038895861 0.9033877038895849 0.8579117829215046 0.8709890182597942 0.9512741983327778 0.936991542292295 1594 3188 0.9037013801756578 0.9027603513174434 0.8575909661229606 0.8707575282308662 0.952321204516935 0.9350846925972415 0.9030185434005366 0.9033740296165678 0.8728050324527968 0.8794566490673464 0.9383551968041549 0.9306380145278438
12 Recent Before 2020 Suburban 0.800970873786409 0.8009708737864075 0.687621671804964 0.7190494526516675 0.9330048294873011 0.8922256157601893 206 412 0.8009708737864077 0.800970873786407 0.674757281553401 0.716019417475729 0.9223300970873809 0.8907766990291225 0.8022616917965761 0.8010204081632639 0.7058602941176474 0.7388816699636662 0.8904968944099336 0.8615265602941665
13 Recent Before 2020 Urban 0.9354207436399179 0.9354207436399201 0.8779639126262511 0.8944171388431081 0.9966377376655905 0.9783041151957946 1022 2044 0.934442270058707 0.934931506849313 0.8767123287671218 0.8933463796477465 0.9961105675146799 0.978485812133073 0.9346761236158347 0.9350196850393682 0.8895441574912045 0.9050659124404135 0.9809577616357241 0.9671188279855178

View File

@@ -1,13 +1,13 @@
spill_type,Period,rurality,pred_mean,ci_lower,ci_upper,n,pred_median_boot,ci_lower_boot,ci_upper_boot
Historical,2020 and After,Rural,0.6093189964157697,0.5478743705834819,0.6776546948120998,558,0.6093189964157705,0.5448028673835126,0.6720430107526851
Historical,2020 and After,Suburban,0.42011834319526453,0.3329283283724966,0.5301423977705431,169,0.42011834319526487,0.3254437869822484,0.5147928994082847
Historical,2020 and After,Urban,0.3444994290064705,0.3227699462514921,0.36769178160507127,2627,0.3444994290064708,0.3224210125618575,0.36810049486105806
Historical,Before 2020,Rural,0.8881118881118876,0.7853397269730921,1.0043331550865073,286,0.8846153846153855,0.7797202797202769,0.9965909090909086
Historical,Before 2020,Suburban,0.7837837837837845,0.6059349205795946,1.0138333323565736,74,0.7837837837837832,0.5810810810810829,0.9868243243243267
Historical,Before 2020,Urban,0.8045417680454156,0.7560010921988318,0.8561991023677035,1233,0.8037307380373095,0.7558799675587965,0.8548459042984564
Recent,2020 and After,Rural,0.6839481555333987,0.6486978802574822,0.7211139325318346,2006,0.6829511465603179,0.647557328015953,0.718344965104685
Recent,2020 and After,Suburban,0.5621468926553657,0.489224984417794,0.6459382472016476,354,0.5621468926553679,0.48870056497175085,0.6384887005649743
Recent,2020 and After,Urban,0.636728147554129,0.5939439753667028,0.6825942356556498,1247,0.6351242983159581,0.5926222935044123,0.6808340016038464
Recent,Before 2020,Rural,0.9033877038895861,0.8579117829215046,0.9512741983327778,1594,0.9037013801756578,0.8575909661229606,0.952321204516935
Recent,Before 2020,Suburban,0.800970873786409,0.687621671804964,0.9330048294873011,206,0.8009708737864077,0.674757281553401,0.9223300970873809
Recent,Before 2020,Urban,0.9354207436399179,0.8779639126262511,0.9966377376655905,1022,0.934442270058707,0.8767123287671218,0.9961105675146799
Historical,2020 and After,Rural,0.6093189964157685,0.5651998386422391,0.6568820689775993,1116,0.6102150537634419,0.5636200716845869,0.656810035842294
Historical,2020 and After,Suburban,0.42011834319526564,0.3564011403776044,0.4952268730176765,338,0.41715976331360954,0.3550295857988165,0.49112426035502776
Historical,2020 and After,Urban,0.34449942900647024,0.3289884305754048,0.36074173300930823,5254,0.3439284354777313,0.32813094784925795,0.3603016749143509
Historical,Before 2020,Rural,0.8881118881118854,0.8141436277138147,0.9688004658594644,572,0.8898601398601386,0.8146416083916047,0.9685314685314674
Historical,Before 2020,Suburban,0.7837837837837821,0.6533753451795489,0.9402206928294898,148,0.7837837837837851,0.6486486486486477,0.9324324324324287
Historical,Before 2020,Urban,0.8045417680454152,0.7699068889663325,0.8407347249466527,2466,0.8033252230332523,0.7700628548256254,0.839821573398215
Recent,2020 and After,Rural,0.6839481555333978,0.6588300067720765,0.7100239434288064,4012,0.6836989032901286,0.6580259222333001,0.7086303589232316
Recent,2020 and After,Suburban,0.5621468926553672,0.5095445400887737,0.6201795997402488,708,0.5607344632768358,0.5070621468926572,0.618644067796611
Recent,2020 and After,Urban,0.6367281475541288,0.6061685025702591,0.6688284398952602,2494,0.6375300721732182,0.6050320769847629,0.6696070569366496
Recent,Before 2020,Rural,0.9033877038895849,0.8709890182597942,0.936991542292295,3188,0.9027603513174434,0.8707575282308662,0.9350846925972415
Recent,Before 2020,Suburban,0.8009708737864075,0.7190494526516675,0.8922256157601893,412,0.800970873786407,0.716019417475729,0.8907766990291225
Recent,Before 2020,Urban,0.9354207436399201,0.8944171388431081,0.9783041151957946,2044,0.934931506849313,0.8933463796477465,0.978485812133073
1 spill_type Period rurality pred_mean ci_lower ci_upper n pred_median_boot ci_lower_boot ci_upper_boot
2 Historical 2020 and After Rural 0.6093189964157697 0.6093189964157685 0.5478743705834819 0.5651998386422391 0.6776546948120998 0.6568820689775993 558 1116 0.6093189964157705 0.6102150537634419 0.5448028673835126 0.5636200716845869 0.6720430107526851 0.656810035842294
3 Historical 2020 and After Suburban 0.42011834319526453 0.42011834319526564 0.3329283283724966 0.3564011403776044 0.5301423977705431 0.4952268730176765 169 338 0.42011834319526487 0.41715976331360954 0.3254437869822484 0.3550295857988165 0.5147928994082847 0.49112426035502776
4 Historical 2020 and After Urban 0.3444994290064705 0.34449942900647024 0.3227699462514921 0.3289884305754048 0.36769178160507127 0.36074173300930823 2627 5254 0.3444994290064708 0.3439284354777313 0.3224210125618575 0.32813094784925795 0.36810049486105806 0.3603016749143509
5 Historical Before 2020 Rural 0.8881118881118876 0.8881118881118854 0.7853397269730921 0.8141436277138147 1.0043331550865073 0.9688004658594644 286 572 0.8846153846153855 0.8898601398601386 0.7797202797202769 0.8146416083916047 0.9965909090909086 0.9685314685314674
6 Historical Before 2020 Suburban 0.7837837837837845 0.7837837837837821 0.6059349205795946 0.6533753451795489 1.0138333323565736 0.9402206928294898 74 148 0.7837837837837832 0.7837837837837851 0.5810810810810829 0.6486486486486477 0.9868243243243267 0.9324324324324287
7 Historical Before 2020 Urban 0.8045417680454156 0.8045417680454152 0.7560010921988318 0.7699068889663325 0.8561991023677035 0.8407347249466527 1233 2466 0.8037307380373095 0.8033252230332523 0.7558799675587965 0.7700628548256254 0.8548459042984564 0.839821573398215
8 Recent 2020 and After Rural 0.6839481555333987 0.6839481555333978 0.6486978802574822 0.6588300067720765 0.7211139325318346 0.7100239434288064 2006 4012 0.6829511465603179 0.6836989032901286 0.647557328015953 0.6580259222333001 0.718344965104685 0.7086303589232316
9 Recent 2020 and After Suburban 0.5621468926553657 0.5621468926553672 0.489224984417794 0.5095445400887737 0.6459382472016476 0.6201795997402488 354 708 0.5621468926553679 0.5607344632768358 0.48870056497175085 0.5070621468926572 0.6384887005649743 0.618644067796611
10 Recent 2020 and After Urban 0.636728147554129 0.6367281475541288 0.5939439753667028 0.6061685025702591 0.6825942356556498 0.6688284398952602 1247 2494 0.6351242983159581 0.6375300721732182 0.5926222935044123 0.6050320769847629 0.6808340016038464 0.6696070569366496
11 Recent Before 2020 Rural 0.9033877038895861 0.9033877038895849 0.8579117829215046 0.8709890182597942 0.9512741983327778 0.936991542292295 1594 3188 0.9037013801756578 0.9027603513174434 0.8575909661229606 0.8707575282308662 0.952321204516935 0.9350846925972415
12 Recent Before 2020 Suburban 0.800970873786409 0.8009708737864075 0.687621671804964 0.7190494526516675 0.9330048294873011 0.8922256157601893 206 412 0.8009708737864077 0.800970873786407 0.674757281553401 0.716019417475729 0.9223300970873809 0.8907766990291225
13 Recent Before 2020 Urban 0.9354207436399179 0.9354207436399201 0.8779639126262511 0.8944171388431081 0.9966377376655905 0.9783041151957946 1022 2044 0.934442270058707 0.934931506849313 0.8767123287671218 0.8933463796477465 0.9961105675146799 0.978485812133073

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 122 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,8 @@
Variable,N,Percent
Spill Type: Recent,"20,702",62.35%
Spill Type: Historical,"12,500",37.65%
Period: 2020 and After,"19,546",58.87%
Period: Before 2020,"13,656",41.13%
Rurality: Rural,"14,826",44.65%
Rurality: Suburban,"2,644",7.96%
Rurality: Urban,"15,732",47.38%
1 Variable N Percent
2 Spill Type: Recent 20,702 62.35%
3 Spill Type: Historical 12,500 37.65%
4 Period: 2020 and After 19,546 58.87%
5 Period: Before 2020 13,656 41.13%
6 Rurality: Rural 14,826 44.65%
7 Rurality: Suburban 2,644 7.96%
8 Rurality: Urban 15,732 47.38%

View File

@@ -0,0 +1,3 @@
Period,N,Mean,SD,Median,Q1,Q3
2020 and After,"19,546",0.82,1.03,1.00,0.00,1.00
Before 2020,"13,656",1.22,1.12,1.00,0.00,2.00
1 Period N Mean SD Median Q1 Q3
2 2020 and After 19,546 0.82 1.03 1.00 0.00 1.00
3 Before 2020 13,656 1.22 1.12 1.00 0.00 2.00

View File

@@ -0,0 +1,4 @@
rurality,N,Mean,SD,Median,Q1,Q3
Rural,"14,826",1.13,1.12,1.00,0.00,2.00
Suburban,"2,644",1.18,1.25,1.00,0.00,2.00
Urban,"15,732",0.82,1.00,1.00,0.00,1.00
1 rurality N Mean SD Median Q1 Q3
2 Rural 14,826 1.13 1.12 1.00 0.00 2.00
3 Suburban 2,644 1.18 1.25 1.00 0.00 2.00
4 Urban 15,732 0.82 1.00 1.00 0.00 1.00

View File

@@ -0,0 +1,3 @@
Spill Type,N,Mean,SD,Median,Q1,Q3
Historical,"12,500",0.76,0.98,0.00,0.00,1.00
Recent,"20,702",1.12,1.12,1.00,0.00,2.00
1 Spill Type N Mean SD Median Q1 Q3
2 Historical 12,500 0.76 0.98 0.00 0.00 1.00
3 Recent 20,702 1.12 1.12 1.00 0.00 2.00

View File

@@ -0,0 +1,7 @@
Variable,N,Mean,SD,Median,Min,Max
Total Population,"33,202",4635.14,2230.11,4681.00,0.00,11173.00
Median Household Income,"33,202",-5904822.76,62883297.78,72717.00,-666666666.00,190417.00
Percent White,"33,200",83.51,8.48,85.92,28.59,98.71
Percent Hispanic,"33,200",22.82,13.06,18.38,0.96,79.06
Percent Poverty,"33,200",10.28,6.37,9.57,0.00,28.06
Unemployment Rate,"33,200",2.66,1.37,2.41,0.00,6.58
1 Variable N Mean SD Median Min Max
2 Total Population 33,202 4635.14 2230.11 4681.00 0.00 11173.00
3 Median Household Income 33,202 -5904822.76 62883297.78 72717.00 -666666666.00 190417.00
4 Percent White 33,200 83.51 8.48 85.92 28.59 98.71
5 Percent Hispanic 33,200 22.82 13.06 18.38 0.96 79.06
6 Percent Poverty 33,200 10.28 6.37 9.57 0.00 28.06
7 Unemployment Rate 33,200 2.66 1.37 2.41 0.00 6.58

View File

@@ -0,0 +1,21 @@
Characteristic,Statistic
,Value
Sample Size,"N = 33,202"
,
Report Delay (days),
Mean (SD),0.99 (1.09)
Median [IQR],"1.00 [0.00, 1.00]"
Range,"[0.00, 5.00]"
,
"Spill Type, n (%)",
Recent,"20,702 (62.35%)"
Historical,"12,500 (37.65%)"
,
"Policy Period, n (%)",
2020 and After,"19,546 (58.87%)"
Before 2020,"13,656 (41.13%)"
,
"Rurality, n (%)",
Rural,"14,826 (44.65%)"
Suburban,"2,644 (7.96%)"
Urban,"15,732 (47.38%)"
1 Characteristic Statistic
2 Value
3 Sample Size N = 33,202
4
5 Report Delay (days)
6 Mean (SD) 0.99 (1.09)
7 Median [IQR] 1.00 [0.00, 1.00]
8 Range [0.00, 5.00]
9
10 Spill Type, n (%)
11 Recent 20,702 (62.35%)
12 Historical 12,500 (37.65%)
13
14 Policy Period, n (%)
15 2020 and After 19,546 (58.87%)
16 Before 2020 13,656 (41.13%)
17
18 Rurality, n (%)
19 Rural 14,826 (44.65%)
20 Suburban 2,644 (7.96%)
21 Urban 15,732 (47.38%)

View File

@@ -0,0 +1,2 @@
Variable,N,Mean,SD,Median,Q1,Q3,Min,Max,IQR
Report Delay (days),"33,202",0.99,1.09,1.00,0.00,1.00,0.00,5.00,1.00
1 Variable N Mean SD Median Q1 Q3 Min Max IQR
2 Report Delay (days) 33,202 0.99 1.09 1.00 0.00 1.00 0.00 5.00 1.00

View File

@@ -0,0 +1,5 @@
Spill Type,Period,Urban,Suburban,Rural,Total
Historical,2020 and After,5254,338,1116,6708
Historical,Before 2020,2466,148,572,3186
Recent,2020 and After,2494,708,4012,7214
Recent,Before 2020,2044,412,3188,5644
1 Spill Type Period Urban Suburban Rural Total
2 Historical 2020 and After 5254 338 1116 6708
3 Historical Before 2020 2466 148 572 3186
4 Recent 2020 and After 2494 708 4012 7214
5 Recent Before 2020 2044 412 3188 5644

View File

@@ -0,0 +1,5 @@
Spill Type,Period,Urban,Suburban,Rural,Total
Historical,2020 and After,"5,254",338,"1,116","6,708"
Historical,Before 2020,"2,466",148,572,"3,186"
Recent,2020 and After,"2,494",708,"4,012","7,214"
Recent,Before 2020,"2,044",412,"3,188","5,644"
1 Spill Type Period Urban Suburban Rural Total
2 Historical 2020 and After 5,254 338 1,116 6,708
3 Historical Before 2020 2,466 148 572 3,186
4 Recent 2020 and After 2,494 708 4,012 7,214
5 Recent Before 2020 2,044 412 3,188 5,644

View File

@@ -0,0 +1,13 @@
Predictor,Estimate,Std. Error,z,p > |z|
Intercept,-0.4954,0.0383,-12.919,<0.001
Spill Type: Recent,0.1155,0.0428,2.697,0.0070
Period: Before 2020,0.3768,0.0586,6.424,<0.001
Rurality: Suburban,-0.3718,0.0923,-4.030,<0.001
Rurality: Urban,-0.5702,0.0450,-12.678,<0.001
Recent × Before 2020,-0.0985,0.0644,-1.529,0.1263
Recent × Suburban,0.1757,0.1067,1.646,0.0997
Recent × Urban,0.4987,0.0549,9.079,<0.001
Before 2020 × Suburban,0.2468,0.1382,1.786,0.0741
Before 2020 × Urban,0.4714,0.0670,7.031,<0.001
Recent × Before 2020 × Suburban,-0.1710,0.1592,-1.074,0.2827
Recent × Before 2020 × Urban,-0.3650,0.0797,-4.577,<0.001
1 Predictor Estimate Std. Error z p > |z|
2 Intercept -0.4954 0.0383 -12.919 <0.001
3 Spill Type: Recent 0.1155 0.0428 2.697 0.0070
4 Period: Before 2020 0.3768 0.0586 6.424 <0.001
5 Rurality: Suburban -0.3718 0.0923 -4.030 <0.001
6 Rurality: Urban -0.5702 0.0450 -12.678 <0.001
7 Recent × Before 2020 -0.0985 0.0644 -1.529 0.1263
8 Recent × Suburban 0.1757 0.1067 1.646 0.0997
9 Recent × Urban 0.4987 0.0549 9.079 <0.001
10 Before 2020 × Suburban 0.2468 0.1382 1.786 0.0741
11 Before 2020 × Urban 0.4714 0.0670 7.031 <0.001
12 Recent × Before 2020 × Suburban -0.1710 0.1592 -1.074 0.2827
13 Recent × Before 2020 × Urban -0.3650 0.0797 -4.577 <0.001

View File

@@ -0,0 +1,13 @@
Predictor,Rate Ratio,95% CI Lower,95% CI Upper,p > |z|
Intercept,0.6093,0.5652,0.6569,<0.001
Spill Type: Recent,1.1225,1.0321,1.2208,0.0070
Period: Before 2020,1.4575,1.2993,1.6351,<0.001
Rurality: Suburban,0.6895,0.5754,0.8262,<0.001
Rurality: Urban,0.5654,0.5177,0.6175,<0.001
Recent × Before 2020,0.9062,0.7987,1.0282,0.1263
Recent × Suburban,1.1921,0.9671,1.4694,0.0997
Recent × Urban,1.6466,1.4785,1.8338,<0.001
Before 2020 × Suburban,1.2800,0.9762,1.6782,0.0741
Before 2020 × Urban,1.6023,1.4050,1.8273,<0.001
Recent × Before 2020 × Suburban,0.8428,0.6168,1.1515,0.2827
Recent × Before 2020 × Urban,0.6942,0.5937,0.8116,<0.001
1 Predictor Rate Ratio 95% CI Lower 95% CI Upper p > |z|
2 Intercept 0.6093 0.5652 0.6569 <0.001
3 Spill Type: Recent 1.1225 1.0321 1.2208 0.0070
4 Period: Before 2020 1.4575 1.2993 1.6351 <0.001
5 Rurality: Suburban 0.6895 0.5754 0.8262 <0.001
6 Rurality: Urban 0.5654 0.5177 0.6175 <0.001
7 Recent × Before 2020 0.9062 0.7987 1.0282 0.1263
8 Recent × Suburban 1.1921 0.9671 1.4694 0.0997
9 Recent × Urban 1.6466 1.4785 1.8338 <0.001
10 Before 2020 × Suburban 1.2800 0.9762 1.6782 0.0741
11 Before 2020 × Urban 1.6023 1.4050 1.8273 <0.001
12 Recent × Before 2020 × Suburban 0.8428 0.6168 1.1515 0.2827
13 Recent × Before 2020 × Urban 0.6942 0.5937 0.8116 <0.001

View File

@@ -0,0 +1,7 @@
Period,Rurality,Δ (Pre → Post 2020) days,95% CI,p
2020 and After,Rural,0.07,"(0.00, 0.14)",0.049
2020 and After,Suburban,0.14,"(0.02, 0.26)",0.022
2020 and After,Urban,0.29,"(0.24, 0.34)",<0.001
Before 2020,Rural,0.01,"(-0.10, 0.12)",0.828
Before 2020,Suburban,0.02,"(-0.21, 0.25)",0.862
Before 2020,Urban,0.13,"(0.05, 0.21)",<0.001
1 Period Rurality Δ (Pre → Post 2020) days 95% CI p
2 2020 and After Rural 0.07 (0.00, 0.14) 0.049
3 2020 and After Suburban 0.14 (0.02, 0.26) 0.022
4 2020 and After Urban 0.29 (0.24, 0.34) <0.001
5 Before 2020 Rural 0.01 (-0.10, 0.12) 0.828
6 Before 2020 Suburban 0.02 (-0.21, 0.25) 0.862
7 Before 2020 Urban 0.13 (0.05, 0.21) <0.001

View File

@@ -0,0 +1,7 @@
Period,Rurality,Δ (hours),95% CI,p
2020 and After,Rural,1.75,"(0.01, 3.46)",0.049
2020 and After,Suburban,3.45,"(0.46, 6.34)",0.022
2020 and After,Urban,7.01,"(5.86, 8.22)",<0.001
Before 2020,Rural,0.30,"(-2.42, 2.98)",0.828
Before 2020,Suburban,0.46,"(-4.97, 5.94)",0.862
Before 2020,Urban,3.13,"(1.27, 5.00)",<0.001
1 Period Rurality Δ (hours) 95% CI p
2 2020 and After Rural 1.75 (0.01, 3.46) 0.049
3 2020 and After Suburban 3.45 (0.46, 6.34) 0.022
4 2020 and After Urban 7.01 (5.86, 8.22) <0.001
5 Before 2020 Rural 0.30 (-2.42, 2.98) 0.828
6 Before 2020 Suburban 0.46 (-4.97, 5.94) 0.862
7 Before 2020 Urban 3.13 (1.27, 5.00) <0.001

View File

@@ -0,0 +1,7 @@
Spill Type,Rurality,Level Change (β₁),β₁ 95% CI,Slope Change (β₂),β₂ 95% CI,p (level),p (slope)
Historical,Rural,-0.232,"(-0.869, 0.398)",-0.0001,"(-0.0113, 0.0110)",0.446,0.980
Historical,Suburban,-1.542,"(-2.801, -0.509)",0.0183,"(-0.0014, 0.0405)",0.002,0.076
Historical,Urban,-0.614,"(-0.970, -0.258)",0.0085,"(0.0026, 0.0150)",0.002,0.008
Recent,Rural,-0.016,"(-0.369, 0.341)",-0.0030,"(-0.0081, 0.0024)",0.904,0.252
Recent,Suburban,-0.180,"(-1.213, 0.737)",-0.0047,"(-0.0193, 0.0097)",0.676,0.528
Recent,Urban,-0.175,"(-0.586, 0.225)",0.0017,"(-0.0059, 0.0093)",0.446,0.686
1 Spill Type Rurality Level Change (β₁) β₁ 95% CI Slope Change (β₂) β₂ 95% CI p (level) p (slope)
2 Historical Rural -0.232 (-0.869, 0.398) -0.0001 (-0.0113, 0.0110) 0.446 0.980
3 Historical Suburban -1.542 (-2.801, -0.509) 0.0183 (-0.0014, 0.0405) 0.002 0.076
4 Historical Urban -0.614 (-0.970, -0.258) 0.0085 (0.0026, 0.0150) 0.002 0.008
5 Recent Rural -0.016 (-0.369, 0.341) -0.0030 (-0.0081, 0.0024) 0.904 0.252
6 Recent Suburban -0.180 (-1.213, 0.737) -0.0047 (-0.0193, 0.0097) 0.676 0.528
7 Recent Urban -0.175 (-0.586, 0.225) 0.0017 (-0.0059, 0.0093) 0.446 0.686

533
data_setup/add_ruca.ipynb Normal file
View File

@@ -0,0 +1,533 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "a79e3ddd",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Document #</th>\n",
" <th>Report</th>\n",
" <th>Operator</th>\n",
" <th>Operator #</th>\n",
" <th>Tracking #</th>\n",
" <th>Initial Report Date</th>\n",
" <th>Date of Discovery</th>\n",
" <th>Spill Type</th>\n",
" <th>Qtr Qtr</th>\n",
" <th>Section</th>\n",
" <th>...</th>\n",
" <th>total_population</th>\n",
" <th>white_population</th>\n",
" <th>hispanic_population</th>\n",
" <th>median_household_income</th>\n",
" <th>poverty_population</th>\n",
" <th>unemployed_population</th>\n",
" <th>percent_white</th>\n",
" <th>percent_hispanic</th>\n",
" <th>percent_poverty</th>\n",
" <th>unemployment_rate</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>400827079</td>\n",
" <td>S</td>\n",
" <td>NOBLE ENERGY INC</td>\n",
" <td>100322</td>\n",
" <td>400823757</td>\n",
" <td>04/10/2015</td>\n",
" <td>04/09/2015</td>\n",
" <td>Historical</td>\n",
" <td>NWNW</td>\n",
" <td>12</td>\n",
" <td>...</td>\n",
" <td>11173.0</td>\n",
" <td>9194.0</td>\n",
" <td>3065.0</td>\n",
" <td>83193.0</td>\n",
" <td>247.0</td>\n",
" <td>245.0</td>\n",
" <td>82.287658</td>\n",
" <td>27.432203</td>\n",
" <td>2.210686</td>\n",
" <td>2.192786</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>400827243</td>\n",
" <td>I</td>\n",
" <td>NOBLE ENERGY INC</td>\n",
" <td>100322</td>\n",
" <td>400827243</td>\n",
" <td>04/17/2015</td>\n",
" <td>04/17/2015</td>\n",
" <td>Historical</td>\n",
" <td>SESW</td>\n",
" <td>34</td>\n",
" <td>...</td>\n",
" <td>11173.0</td>\n",
" <td>9194.0</td>\n",
" <td>3065.0</td>\n",
" <td>83193.0</td>\n",
" <td>247.0</td>\n",
" <td>245.0</td>\n",
" <td>82.287658</td>\n",
" <td>27.432203</td>\n",
" <td>2.210686</td>\n",
" <td>2.192786</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>400827326</td>\n",
" <td>I</td>\n",
" <td>KINDER MORGAN CO2 CO LP</td>\n",
" <td>46685</td>\n",
" <td>400827326</td>\n",
" <td>04/18/2015</td>\n",
" <td>04/17/2015</td>\n",
" <td>Recent</td>\n",
" <td>NWSW</td>\n",
" <td>23</td>\n",
" <td>...</td>\n",
" <td>2459.0</td>\n",
" <td>2404.0</td>\n",
" <td>81.0</td>\n",
" <td>66683.0</td>\n",
" <td>330.0</td>\n",
" <td>26.0</td>\n",
" <td>97.763318</td>\n",
" <td>3.294022</td>\n",
" <td>13.420089</td>\n",
" <td>1.057340</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>400834096</td>\n",
" <td>I</td>\n",
" <td>SMITH OIL PROPERTIES INC</td>\n",
" <td>79905</td>\n",
" <td>400834096</td>\n",
" <td>04/30/2015</td>\n",
" <td>03/26/2015</td>\n",
" <td>Historical</td>\n",
" <td>NENW</td>\n",
" <td>4</td>\n",
" <td>...</td>\n",
" <td>7335.0</td>\n",
" <td>6302.0</td>\n",
" <td>2011.0</td>\n",
" <td>71440.0</td>\n",
" <td>831.0</td>\n",
" <td>166.0</td>\n",
" <td>85.916837</td>\n",
" <td>27.416496</td>\n",
" <td>11.329243</td>\n",
" <td>2.263122</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>400834131</td>\n",
" <td>I</td>\n",
" <td>LINN OPERATING INC</td>\n",
" <td>10516</td>\n",
" <td>400834131</td>\n",
" <td>05/01/2015</td>\n",
" <td>04/30/2015</td>\n",
" <td>Recent</td>\n",
" <td>NESW</td>\n",
" <td>15</td>\n",
" <td>...</td>\n",
" <td>7240.0</td>\n",
" <td>5646.0</td>\n",
" <td>1659.0</td>\n",
" <td>64573.0</td>\n",
" <td>693.0</td>\n",
" <td>240.0</td>\n",
" <td>77.983425</td>\n",
" <td>22.914365</td>\n",
" <td>9.571823</td>\n",
" <td>3.314917</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 118 columns</p>\n",
"</div>"
],
"text/plain": [
" Document # Report Operator Operator # Tracking # \\\n",
"0 400827079 S NOBLE ENERGY INC 100322 400823757 \n",
"1 400827243 I NOBLE ENERGY INC 100322 400827243 \n",
"2 400827326 I KINDER MORGAN CO2 CO LP 46685 400827326 \n",
"3 400834096 I SMITH OIL PROPERTIES INC 79905 400834096 \n",
"4 400834131 I LINN OPERATING INC 10516 400834131 \n",
"\n",
" Initial Report Date Date of Discovery Spill Type Qtr Qtr Section ... \\\n",
"0 04/10/2015 04/09/2015 Historical NWNW 12 ... \n",
"1 04/17/2015 04/17/2015 Historical SESW 34 ... \n",
"2 04/18/2015 04/17/2015 Recent NWSW 23 ... \n",
"3 04/30/2015 03/26/2015 Historical NENW 4 ... \n",
"4 05/01/2015 04/30/2015 Recent NESW 15 ... \n",
"\n",
" total_population white_population hispanic_population \\\n",
"0 11173.0 9194.0 3065.0 \n",
"1 11173.0 9194.0 3065.0 \n",
"2 2459.0 2404.0 81.0 \n",
"3 7335.0 6302.0 2011.0 \n",
"4 7240.0 5646.0 1659.0 \n",
"\n",
" median_household_income poverty_population unemployed_population \\\n",
"0 83193.0 247.0 245.0 \n",
"1 83193.0 247.0 245.0 \n",
"2 66683.0 330.0 26.0 \n",
"3 71440.0 831.0 166.0 \n",
"4 64573.0 693.0 240.0 \n",
"\n",
" percent_white percent_hispanic percent_poverty unemployment_rate \n",
"0 82.287658 27.432203 2.210686 2.192786 \n",
"1 82.287658 27.432203 2.210686 2.192786 \n",
"2 97.763318 3.294022 13.420089 1.057340 \n",
"3 85.916837 27.416496 11.329243 2.263122 \n",
"4 77.983425 22.914365 9.571823 3.314917 \n",
"\n",
"[5 rows x 118 columns]"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"from sqlalchemy import create_engine\n",
"import geopandas as gpd\n",
"from dotenv import load_dotenv\n",
"load_dotenv()\n",
"\n",
"import os\n",
"\n",
"# Database connection details from zshrc environment variables\n",
"db_name = 'colorado_spills'\n",
"user = os.getenv('DB_USER')\n",
"password = os.getenv('DB_PASSWORD')\n",
"host = os.getenv('DB_HOST')\n",
"port = os.getenv('DB_PORT')\n",
"\n",
"\n",
"# Create an engine to connect to the PostgreSQL database\n",
"engine = create_engine(f'postgresql+psycopg2://{user}:{password}@{host}:{port}/{db_name}')\n",
"\n",
"# Function to load data from a table\n",
"def load_table(table_name):\n",
" query = f'SELECT * FROM {table_name}'\n",
" df = pd.read_sql(query, engine)\n",
" return df\n",
"\n",
"# Load the spills data\n",
"spills_with_demographics = load_table('spills_with_demographics')\n",
"spills_with_demographics.head()\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "dba1c393",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"gdf_spills_with_demographics has been created.\n"
]
}
],
"source": [
"# create a GeoDataFrame with spills and demographics\n",
"gdf_spills_with_demographics = gpd.GeoDataFrame(\n",
" spills_with_demographics,\n",
" geometry=gpd.points_from_xy(spills_with_demographics.Longitude, spills_with_demographics.Latitude),\n",
" crs=\"EPSG:4326\"\n",
") \n",
"print(\"gdf_spills_with_demographics has been created.\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "317abe05",
"metadata": {},
"outputs": [],
"source": [
"# verify that the demographics data has been merged correctly\n",
"assert not spills_with_demographics['total_population'].isna().any(), \"Some spills are missing demographic data\"\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "73411f29",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"gdf_spills_with_demographics has been verified.\n"
]
}
],
"source": [
"# verify the GeoDataFrame\n",
"assert gdf_spills_with_demographics.geometry.notnull().all(), \"Some geometries are null in gdf_spills_with_demographics\"\n",
"assert gdf_spills_with_demographics.crs == \"EPSG:4326\", \"CRS of gdf_spills_with_demographics is not EPSG:4326\"\n",
"print(\"gdf_spills_with_demographics has been verified.\")\n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "3d0d0791",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting geoalchemy2\n",
" Downloading geoalchemy2-0.18.0-py3-none-any.whl.metadata (2.3 kB)\n",
"Requirement already satisfied: SQLAlchemy>=1.4 in /home/dadams/Repos/colorado_spills/.venv/lib/python3.13/site-packages (from geoalchemy2) (2.0.43)\n",
"Requirement already satisfied: packaging in /home/dadams/Repos/colorado_spills/.venv/lib/python3.13/site-packages (from geoalchemy2) (25.0)\n",
"Requirement already satisfied: greenlet>=1 in /home/dadams/Repos/colorado_spills/.venv/lib/python3.13/site-packages (from SQLAlchemy>=1.4->geoalchemy2) (3.2.4)\n",
"Requirement already satisfied: typing-extensions>=4.6.0 in /home/dadams/Repos/colorado_spills/.venv/lib/python3.13/site-packages (from SQLAlchemy>=1.4->geoalchemy2) (4.15.0)\n",
"Downloading geoalchemy2-0.18.0-py3-none-any.whl (81 kB)\n",
"Installing collected packages: geoalchemy2\n",
"Successfully installed geoalchemy2-0.18.0\n",
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"source": [
"%pip install geoalchemy2"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "d30657cf",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"gdf_spills_with_demographics has been created.\n"
]
}
],
"source": [
"# create a GeoDataFrame with spills and demographics\n",
"gdf_spills_with_demographics = gpd.GeoDataFrame(\n",
" spills_with_demographics,\n",
" geometry=gpd.points_from_xy(spills_with_demographics.Longitude, spills_with_demographics.Latitude),\n",
" crs=\"EPSG:4326\"\n",
") \n",
"print(\"gdf_spills_with_demographics has been created.\")"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "55ac288c",
"metadata": {},
"outputs": [],
"source": [
"# ...existing code...\n",
"# ...existing code...\n",
"from sqlalchemy import text\n",
"# ...existing code...\n",
"# Enable PostGIS extension (run this once)\n",
"with engine.connect() as conn:\n",
" conn.execute(text(\"CREATE EXTENSION IF NOT EXISTS postgis;\"))\n",
" conn.commit()\n",
"\n",
"# Now this should work\n",
"gdf_spills_with_demographics.to_postgis('gdf_spills_with_demographics', engine, if_exists='replace', index=False)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "4f9f93a6",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"gdf_spills_with_demographics has been saved to the database.\n",
"gdf_spills_with_demographics has been saved to a CSV file.\n",
"gdf_spills_with_demographics has been saved to a GeoJSON file.\n"
]
}
],
"source": [
"import os\n",
"import geoalchemy2\n",
"# Save the GeoDataFrame to a new table in the database\n",
"gdf_spills_with_demographics.to_postgis('gdf_spills_with_demographics', engine, if_exists='replace', index=False)\n",
"print(\"gdf_spills_with_demographics has been saved to the database.\")\n",
"# Save the GeoDataFrame to a CSV file\n",
"gdf_spills_with_demographics.to_csv('gdf_spills_with_demographics.csv', index=False)\n",
"print(\"gdf_spills_with_demographics has been saved to a CSV file.\")\n",
"# Save GeoDataFrame as a GeoJSON file\n",
"gdf_spills_with_demographics.to_file('gdf_spills_with_demographics.geojson', driver='GeoJSON')\n",
"print(\"gdf_spills_with_demographics has been saved to a GeoJSON file.\")\n"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "3713ba8d",
"metadata": {},
"outputs": [],
"source": [
"ruca_df = pd.read_csv(\n",
" '/home/dadams/CSU Fullerton Dropbox/David Adams/Research Projects/colorado_spills_ejproject/github/colorado_spills/data/RUCA-codes-2020-tract.csv', # update path\n",
" encoding='latin1',\n",
" dtype={'TractFIPS20': str}\n",
")\n",
"\n",
"# Keep and rename needed columns\n",
"ruca_df = ruca_df.rename(columns={\n",
" 'TractFIPS20': 'GEOID',\n",
" 'PrimaryRUCA': 'ruca_code',\n",
" 'PrimaryRUCADescription': 'ruca_description'\n",
"})[['GEOID', 'ruca_code', 'ruca_description']]\n",
"\n",
"# Ensure GEOID is 11-character string\n",
"ruca_df['GEOID'] = ruca_df['GEOID'].str.zfill(11)\n"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "9051abcb",
"metadata": {},
"outputs": [],
"source": [
"spills = pd.read_sql_table('gdf_spills_with_demographics', engine)\n",
"\n",
"# Make sure GEOID is also string-padded\n",
"spills['GEOID'] = spills['GEOID'].astype(str).str.zfill(11)\n"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "f5578b3b",
"metadata": {},
"outputs": [],
"source": [
"spills_with_ruca = spills.merge(ruca_df, on='GEOID', how='left')\n"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "343a6d52",
"metadata": {},
"outputs": [],
"source": [
"def classify_rurality(code):\n",
" if pd.isna(code):\n",
" return 'Unknown'\n",
" code = int(code)\n",
" if code <= 3:\n",
" return 'Urban'\n",
" elif 4 <= code <= 6:\n",
" return 'Suburban'\n",
" else:\n",
" return 'Rural'\n",
"\n",
"spills_with_ruca['rurality'] = spills_with_ruca['ruca_code'].apply(classify_rurality)\n"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "49b419cb",
"metadata": {},
"outputs": [],
"source": [
"from shapely import wkb\n",
"import geopandas as gpd\n",
"\n",
"# Convert WKBElement objects to Shapely\n",
"spills_with_ruca['geometry'] = spills_with_ruca['geometry'].apply(lambda g: wkb.loads(bytes(g.data)) if g else None)\n",
"\n",
"# Now safely create GeoDataFrame\n",
"spills_with_ruca = gpd.GeoDataFrame(spills_with_ruca, geometry='geometry', crs='EPSG:4326')\n"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "f78e96b2",
"metadata": {},
"outputs": [],
"source": [
"spills_with_ruca.to_postgis(\n",
" name='spills_with_ruca',\n",
" con=engine,\n",
" if_exists='replace',\n",
" index=False\n",
")\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long