Skip to content

Documentation v1.0.0


Documentation / @openassistant/geoda / lisa

Variable: lisa

const lisa: OpenAssistantTool<LisaFunctionArgs, LisaLlmResult, LisaAdditionalData, LisaFunctionContext>

Defined in: src/lisa/tool.ts:119

lisa Tool

This tool applies Local Indicators of Spatial Association (LISA) statistics to identify local clusters and spatial outliers. It helps detect areas where similar values cluster together or where outliers exist in the spatial distribution.

LISA Methods

The LISA method can be one of the following types:

  • localMoran: Local Moran's I statistic for detecting clusters and outliers
  • localGeary: Local Geary's C statistic for detecting spatial heterogeneity
  • localG: Local Getis-Ord G statistic for detecting hot and cold spots
  • localGStar: Local Getis-Ord G* statistic (includes the observation itself)
  • quantileLisa: Quantile-based LISA analysis

Parameters

  • datasetName: Name of the dataset containing the variable
  • variableName: Name of the numerical variable to analyze
  • method: LISA method to use (see above)
  • weightsID: ID of spatial weights matrix (optional, will use cached weights if available)
  • permutation: Number of permutations for significance testing (default: 999)
  • significanceThreshold: Significance threshold for filtering results (default: 0.05)
  • k: Number of quantiles for quantile LISA (required for quantileLisa method)
  • quantile: Quantile value for quantile LISA (required for quantileLisa method)

Example user prompts:

  • "Are young population clustering over the zipcode areas?"
  • "Can you perform a local Moran's I analysis on the population data?"
  • "What are the local clusters in the population data?"
  • "How many significant clusters are there in the population data?"

Example

typescript
import { lisa } from "@openassistant/geoda";
import { convertToVercelAiTool } from "@openassistant/utils";

const lisaTool = {
  ...lisa,
  context: {
    getValues: async (datasetName: string, variableName: string) => {
      // Implementation to retrieve values from your data source
      return [100, 200, 150, 300, 250, 180, 220, 190, 280, 210];
    },
  },
};

const result = await generateText({
  model: openai('gpt-4.1', { apiKey: key }),
  prompt: 'Can you perform a local Moran analysis on the population data?',
  tools: { lisa: convertToVercelAiTool(lisaTool) },
});

INFO

The LISA tool should always be used with the spatialWeights tool. The LLM models know how to use the spatialWeights tool for the LISA analysis.

Released under the MIT License.