12 NY: School-Level Overall Achievement
Code
= 'ny' state
Code
= gpd.read_parquet(f"../data/{state}_schools.parquet")
schools = schools.to_crs(schools.estimate_utm_crs())
schools = schools.dropna(subset=['avg_score', 'learning_rate', 'learning_trend']) schools
Code
schools.avg_score.describe()
count 655.000000
mean -0.121712
std 1.465864
min -4.107735
25% -0.982906
50% -0.042146
75% 0.875317
max 3.475817
Name: avg_score, dtype: float64
Code
schools.avg_score.hist()
But the distribution of achievement is not geographically even, which can be seen by plotting the average achievement score as a choropleth map, where each school is colored according to its score
Code
schools.explore("avg_score",
="quantiles",
scheme=8,
k="PRGn",
cmap="Stamen Toner Lite",
tiles={"radius": 7},
marker_kwds=["NAME", "avg_score"],
tooltip )
Make this Notebook Trusted to load map: File -> Trust Notebook
12.1 Exporatory Spatial Data Analysis - “Global” Scale
Code
= weights.KNN.from_dataframe(schools, k=8)
w_school = esda.Moran(schools.avg_score.values, w_school, permutations=99999)
moran
print(f"School-level Moran's I coefficient: {np.round(moran.I,3)}")
print(f"p-value of Moran's I: {np.round(moran.p_sim, 5)}")
School-level Moran's I coefficient: 0.539
p-value of Moran's I: 1e-05
Code
esplt.plot_moran(moran)
(<Figure size 1000x400 with 2 Axes>,
array([<AxesSubplot:title={'center':'Reference Distribution'}, xlabel='Moran I: 0.54', ylabel='Density'>,
<AxesSubplot:title={'center':'Moran Scatterplot (0.54)'}, xlabel='Attribute', ylabel='Spatial Lag'>],
dtype=object))
12.1.1 School-Level Achievement Trends
Code
= esda.Moran(schools.learning_trend.values, w_school, permutations=99999)
moran_trend
print(f"School-level Moran's I coefficient (trend): {np.round(moran_trend.I,3)}")
print(f"p-value of Moran's I (trend): {np.round(moran_trend.p_sim, 5)}")
School-level Moran's I coefficient (trend): 0.184
p-value of Moran's I (trend): 1e-05
Code
esplt.plot_moran(moran_trend)
(<Figure size 1000x400 with 2 Axes>,
array([<AxesSubplot:title={'center':'Reference Distribution'}, xlabel='Moran I: 0.18', ylabel='Density'>,
<AxesSubplot:title={'center':'Moran Scatterplot (0.18)'}, xlabel='Attribute', ylabel='Spatial Lag'>],
dtype=object))
12.2 Exporatory Spatial Data Analysis - “Local” Scale
12.2.1 Average Achievement
Code
= esda.Moran_Local(schools.dropna(subset=['avg_score']).avg_score.values, w_school)
lisa_school_avg
'avg_score') esplt.plot_local_autocorrelation(lisa_school_avg, schools,
(<Figure size 1500x400 with 3 Axes>,
array([<AxesSubplot:title={'center':'Moran Local Scatterplot'}, xlabel='Attribute', ylabel='Spatial Lag'>,
<AxesSubplot:>, <AxesSubplot:>], dtype=object))
Code
explore_local_moran(
lisa_school_avg,
schools,"avg_score",
=0.01,
crit_value={
explore_kwargs"marker_kwds": {"radius": 7},
"tooltip": ["NAME", "avg_score"],
"tiles": "Stamen Toner Lite",
}, )
Make this Notebook Trusted to load map: File -> Trust Notebook
12.2.2 Achievement Trend
Repeating the analysis for trends in school-level achievement reveals many of the same patterns, however in this case the value for Moran’s I is much lower.
Code
= esda.Moran_Local(schools.dropna(subset=['learning_trend']).learning_trend.values, w_school) lisa_school_trend
Code
explore_local_moran(
lisa_school_trend,
schools,"avg_score",
=0.01,
crit_value={
explore_kwargs"marker_kwds": {"radius": 7},
"tooltip": ["NAME", "avg_score"],
"tiles": "Stamen Toner Lite",
}, )
Make this Notebook Trusted to load map: File -> Trust Notebook