From 7afb6948a499a3b00f3fa2ab3f1f2100a75dc358 Mon Sep 17 00:00:00 2001 From: Andy Eschbacher Date: Tue, 3 Jan 2017 10:34:06 -0500 Subject: [PATCH 1/3] adds caveats about usage --- doc/02_moran.md | 20 ++++++++++++++++---- doc/04_markov.md | 9 ++++++++- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/doc/02_moran.md b/doc/02_moran.md index e83c2f1..825838e 100644 --- a/doc/02_moran.md +++ b/doc/02_moran.md @@ -29,6 +29,12 @@ A table with the following columns. | vals | NUMERIC | Values from `'column_name'`. | +#### Notes + +* Rows will null values will be omitted from this analysis. To ensure they are added to the analysis, fill the null-valued cells with an appropriate value such as the mean of a column, the mean of the most recent two time steps, or use a `LEFT JOIN` to get null outputs from the analysis. +* Input query can only accept tables (datasets) in the users database account. Common table expressions (CTEs) do not work as an input unless specified in the `subquery` parameter. + + #### Example Usage ```sql @@ -37,8 +43,8 @@ SELECT aoi.quads, aoi.significance, c.num_cyclists_per_total_population -FROM CDB_AreasOfInterestLocal('SELECT * FROM commute_data' - 'num_cyclists_per_total_population') As aoi +FROM CDB_AreasOfInterestLocal('SELECT * FROM commute_data', + 'num_cyclists_per_total_population') As aoi JOIN commute_data As c ON c.cartodb_id = aoi.rowid; ``` @@ -105,6 +111,12 @@ A table with the following columns. | vals | NUMERIC | Values from `'column_name'`. | +#### Notes + +* Rows will null values will be omitted from this analysis. To ensure they are added to the analysis, fill the null-valued cells with an appropriate value such as the mean of a column, the mean of the most recent two time steps, or use a `LEFT JOIN` to get null outputs from the analysis. +* Input query can only accept tables (datasets) in the users database account. Common table expressions (CTEs) do not work as an input unless specified in the `subquery` parameter. + + #### Example Usage ```sql @@ -114,8 +126,8 @@ SELECT aoi.significance, c.cyclists_per_total_population FROM CDB_AreasOfInterestLocalRate('SELECT * FROM commute_data' - 'num_cyclists', - 'total_population') As aoi + 'num_cyclists', + 'total_population') As aoi JOIN commute_data As c ON c.cartodb_id = aoi.rowid; ``` diff --git a/doc/04_markov.md b/doc/04_markov.md index a45df59..90a17a8 100644 --- a/doc/04_markov.md +++ b/doc/04_markov.md @@ -8,7 +8,7 @@ This function takes time series data associated with geometries and outputs like | Name | Type | Description | |------|------|-------------| -| subquery | TEXT | SQL query that exposes the data to be analyzed (e.g., `SELECT * FROM real_estate_history`). This query must have the geometry column name `the_geom` and id column name `cartodb_id` unless otherwise specified in the input arguments | +| subquery | TEXT | SQL query that exposes the data to be analyzed (e.g., `SELECT * FROM real_estate_history`). This query must have the geometry column name `the_geom` and id column name `cartodb_id` unless otherwise specified in the input arguments. Tables in queries must exist in user's database (i.e., no CTEs at present) | | column_names | TEXT Array | Names of column that form the history of measurements for the geometries (e.g., `Array['y2011', 'y2012', 'y2013', 'y2014', 'y2015', 'y2016']`). | | num_classes (optional) | INT | Number of quantile classes to separate data into. | | weight type (optional) | TEXT | Type of weight to use when finding neighbors. Currently available options are 'knn' (default) and 'queen'. Read more about weight types in [PySAL's weights documentation](https://pysal.readthedocs.io/en/v1.11.0/users/tutorials/weights.html). | @@ -30,12 +30,19 @@ A table with the following columns. | rowid | NUMERIC | id of the row that corresponds to the `id_col` (by default `cartodb_id` of the input rows) | +#### Notes + +* Rows will null values will be omitted from this analysis. To ensure they are added to the analysis, fill the null-valued cells with an appropriate value such as the mean of a column, the mean of the most recent two time steps, etc. +* Input query can only accept tables (datasets) in the users database account. Common table expressions (CTEs) do not work as an input unless specified in the `subquery` parameter. + + #### Example Usage ```sql SELECT c.cartodb_id, c.the_geom, + c.the_geom_webmercator, m.trend, m.trend_up, m.trend_down, From 200c3da3cb0ff3c557a6a56aa5b685ba0360297c Mon Sep 17 00:00:00 2001 From: Andy Eschbacher Date: Tue, 9 Jan 2018 11:08:35 -0500 Subject: [PATCH 2/3] adds better intro and placement for notes --- doc/02_moran.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/doc/02_moran.md b/doc/02_moran.md index 18f4caf..04d90cb 100644 --- a/doc/02_moran.md +++ b/doc/02_moran.md @@ -1,5 +1,14 @@ ## Areas of Interest Functions +A family of analyses to uncover groupings of areas with consistently high or low values (clusters) and smaller areas with values unlike those around them (outliers). A cluster is labeled by an 'HH' (high value compared to the entire dataset in an area with other high values), or its opposite 'LL'. An outlier is labeled by an 'LH' (low value surrounded by high values) or an 'HL' (the opposite). Each cluster and outlier classification has an associated p-value, a measure of how significant the pattern of highs and lows is compared to a random distribution. + +These functions have two forms: local and global. The local versions classify every input geometry while the global function gives a rating of the overall clustering characteristics of the dataset. Both forms accept an optional denomiator (see the rate versions) if, for example, working with count data and a denominator is needed. + +### Notes + +* Rows with null values will be omitted from this analysis. To ensure they are added to the analysis, fill the null-valued cells with an appropriate value such as the mean of a column, the mean of the most recent two time steps, or use a `LEFT JOIN` to get null outputs from the analysis. +* Input query can only accept tables (datasets) in the users database account. Common table expressions (CTEs) do not work as an input unless specified within the `subquery` argument. + ### CDB_AreasOfInterestLocal(subquery text, column_name text) This function classifies your data as being part of a cluster, as an outlier, or not part of a pattern based the significance of a classification. The classification happens through an autocorrelation statistic called Local Moran's I. @@ -29,11 +38,6 @@ A table with the following columns. | vals | NUMERIC | Values from `'column_name'`. | -#### Notes - -* Rows will null values will be omitted from this analysis. To ensure they are added to the analysis, fill the null-valued cells with an appropriate value such as the mean of a column, the mean of the most recent two time steps, or use a `LEFT JOIN` to get null outputs from the analysis. -* Input query can only accept tables (datasets) in the users database account. Common table expressions (CTEs) do not work as an input unless specified in the `subquery` parameter. - #### Example Usage From 8bbfac0dbcb30549af432fe420407d83eb8a39b2 Mon Sep 17 00:00:00 2001 From: Andy Eschbacher Date: Tue, 9 Jan 2018 11:17:09 -0500 Subject: [PATCH 3/3] removes redundant notes section --- doc/02_moran.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/doc/02_moran.md b/doc/02_moran.md index 04d90cb..b72a245 100644 --- a/doc/02_moran.md +++ b/doc/02_moran.md @@ -121,12 +121,6 @@ A table with the following columns. | vals | NUMERIC | Values from `'column_name'`. | -#### Notes - -* Rows will null values will be omitted from this analysis. To ensure they are added to the analysis, fill the null-valued cells with an appropriate value such as the mean of a column, the mean of the most recent two time steps, or use a `LEFT JOIN` to get null outputs from the analysis. -* Input query can only accept tables (datasets) in the users database account. Common table expressions (CTEs) do not work as an input unless specified in the `subquery` parameter. - - #### Example Usage ```sql