Skip to content

Simple statistical functions that are useful for exploratory spatial data analysis (ESDA) on-the-fly in JavaScript

License

Notifications You must be signed in to change notification settings

coreydevinanderson/ESDA.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ESDA.js (beta repository)

A collection of different JavaScript functions (and helper functions) that are useful for exploratory spatial data analysis (ESDA) in a web application. This project is a work-in-progress. The long-term goal is to turn this into a functional module.

This module was inspired by the fact that many simple spatial analyses would otherwise require the use of middleware or would have to be precalculated and stored server side. The idea is to write a set of useful functions in JavaScript that can be executed quickly on-the-fly. One limitation of this approach is that computationally intensive functions (such as spatial randomization) may be too time consuming for large data sets on devices with limited computational power.


At the present time, the following functions are available:

An asterisk * indicates versions of functions that have been rewritten to account for null values. Two versions are being maintained (for the present time) because the functions that do not handle nulls are more concise, and may execute slighltly faster if you do not require null value handling.

Mean-center or standardize a 'DenseMatrix' or 2D 'Array':

  • adjusted.js
  • adjusted2.js*

Dependencies: math.js

Create bivariate classes (based on tertiles) to support a 3 x 3 color scheme for a bivariate choropleth map:

  • bchTerts.js
  • bchTerts2.js*

Dependencies: simple-statistics

Calculate cosine similarity between arrays:

  • cosSim.js

Dependencies: math.js

Calculate Euclidean distance between arrays:

  • distEuclidean.js

Dependencies: none

Create a pairwise Euclidean distance matrix from a 'DenseMatrix' or 2D 'Array':

  • EucDistMatrix.js

Dependencies: math.js

Hotspot Analysis (GetisOrd Gi and Gi*)

  • GetisOrdG_helpers.js
  • GetisOrdG_testdata.js
  • GetisOrdGi.js
  • GetisOrdGiStar.js
  • GetisOrdGiStarZ.js
  • GetisOrdGiZ.js
  • permuteGetisOrdGiStar.js

Dependencies: math.js

Local Moran's I

  • localMoranI_helpers.js
  • localMoranI_testdata.js
  • localMoranI.js
  • localMoranI_nulls.js
  • localMoranIZ.js

Dependecies: None.

Mahalanobis distances

  • Mahalanobis_helpers.js
  • Mahalanobis_testdata.js
  • Mahalanobis1.js
  • Mahalanobis2.js

Dependencies: math.js

MinMax transformation of an 'Array'

  • minMaxScaler.js

Dependencies: none.

Apply a rank transformation to an array:

  • percentileRank.js
  • percentileRank2.js

Dependencies: none


Other files:

  • testData.js contains test code and example calls for each function.
  • test.js contains a JSON object with county level SVI 2018 data (as percent ranks) for five indicators plus diabetes percentage.
  • data/diabetes_indicators.csv is a comma delimited file containing the same data as test.js

Maintainer/Developer: Corey Devin Anderson ([email protected])