Skip to content

Lack of a check for data coherence in Moran() #3848

Closed
@ScriBanana

Description

@ScriBanana

Hi,

Describe the bug
If a value list longer than the weight matrix dimensions is given to the moran function, it skews the result, as no check for that exists.

To Reproduce

  • Load Moran Index.gaml from the library.
  • Optional : run the model and change the parameter to checkerboard pattern to check that the value of Moran I is indeed -1.
  • Add one or more values to the vals list, e.g. by adding something like vals <+ 100.0; before line 49.
  • Run the model with checkerboard. No error is thrown, yet an I value different of -1 is given (about -0.008 in the example above).

Expected behavior
An error to be returned whenever the sizes of the inputs of the function are the same (length of the list and width and height of the weight matrix).

Proposed fix
Add a check in the moranIndex function that vals.size() must be equal to weightMatrix.numCols * weightMatrix.numRows.

Desktop (please complete the following information):

  • OS: Linux (any)
  • GAMA version: bfa98eb

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions