> For the complete documentation index, see [llms.txt](https://xunli.gitbook.io/postgeoda/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xunli.gitbook.io/postgeoda/3.-lisa/3.5-local-quantile-lisa.md).

# 3.5 Quantile LISA

Quantile LISA ([2019](https://geodacenter.github.io/workbook/6d_local_discrete/lab6d.html#ref-Anselin:19b)) is quantile local spatial autocorrelation that applies local join count statistics to quantiles of a continuous variable by converting the continuous variable to a binary variable that takes the value of 1 for a specific quantile. For more information, please read <https://geodacenter.github.io/workbook/6d_local_discrete/lab6d.html#quantile-lisa>

## quantile\_lisa()

{% hint style="info" %}
quantile\_lisa() is a PostgreSQL WINDOW function. Please call it  with an OVER clause.
{% endhint %}

### Synopsis

Short version:

```sql
float[] quantile_lisa(integer k, integer q, numeric val,  bytea weights)
```

Full version:

```sql
float[] quantile_lisa(integer k, integer q, numeric val,  bytea weights,
    integer permutations, 
    character varying permutation_method,
    float significance_cutoff, 
    integer cpu_threads, 
    integer seed)
```

### Arguments

| Name                 | Type              | Description                                                                                                |
| -------------------- | ----------------- | ---------------------------------------------------------------------------------------------------------- |
| k                    | integer           | the number of quantiles                                                                                    |
| q                    | integer           | the index of which quantile is used in local join count statistics                                         |
| val                  | *numeric*         | the numeric column that contains the values for LISA statistics                                            |
| weights              | bytea             | the bytea column that stores the spatial weights information                                               |
| permutations         | integer           | the number of permutations for the LISA computation. Default: 999.                                         |
| permutation\_method  | character varying | the permutation method used for the LISA computation. Options are 'complete', 'lookup'. Default: 'lookup'. |
| significance\_cutoff | float             | the cutoff value for significance p-values to filter not-significant clusters. Default: 0.05.              |
| cpu\_threads         | integer           | the number of CPU threads used for parallel LISA computation. Default: 6.                                  |
| seed                 | integer           | the seed for random number generator used in LISA statistics. Default: 123456789.                          |

### Return

| Type     | Description                                                                                          |
| -------- | ---------------------------------------------------------------------------------------------------- |
| float\[] | an array contains 3 values, which are {'local join count',  'pseudo-p value', 'number of neighbors'} |

{% hint style="info" %}
The results of local join count do NOT have 'category indicator'.
{% endhint %}

### Examples

Apply quantile lisa statistics on the variable "hr60" (homicide rate 1960), the 1st quantile of 10 quantiles, using queen contiguity weights "queen\_w":

```sql
SELECT quantile_lisa(10, 1, hr60, queen_w) OVER() FROM natregimes;

 local_quantilelisa 
--------------------
 {0,-1,3}
 {0,-1,3}
 {0,-1,4}
 {0,-1,7}
 {0,-1,4}
 {0,-1,3}
 {0,-1,4}
 {0,-1,9}
 {1,0.492,3}
 {0,-1,3}
 ...
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://xunli.gitbook.io/postgeoda/3.-lisa/3.5-local-quantile-lisa.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
