Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Moran's I with more than 800 observations

    Hi all,

    I was advised to perform the following tests on a spatial regression:

    spwmatrix gecon latitude longitude, wname(weightsnames) wtype(inv) alpha(2) dband(0 50) eignvar(eignvar) row replace
    spatgsa var, w(weightsnames) moran
    reg var vars
    spatdiag, weights(weightsnames)


    Yet, my dataset is made of over 250,000 observations and the commands incur into the limit of 800 rows or columns for matrices in Stata.


    Specifically, when I try to create the matrix with all the observations, it says:
    J(): 3900 unable to allocate real <tmp>[257224,257224]
    spwmatrix_CalcSPweightM(): - function returned error
    <istmt>: - function returned error

    When I do it with less observations, for example 10,000, it does creates the matrix, but then, when running spatgsa, it returns another error saying:

    unable to allocate matrix;
    You have attempted to create a matrix with too many rows or columns or attempted to fit a model with too many variables.

    You are using Stata/BE which supports matrices with up to 800 rows or columns. See limits for how many more rows and columns Stata/SE and
    Stata/MP can support.

    If you are using factor variables and included an interaction that has lots of missing cells, try set emptycells drop to reduce the
    required matrix size; see help set emptycells.

    If you are using factor variables, you might have accidentally treated a continuous variable as a categorical, resulting in lots of
    categories. Use the c. operator on such variables.



    I thought I could try to create it manually in Mata and tried to set up the matrix:

    mata:
    X = st_data(., "X")
    Y = st_data(., "Y")
    n = rows(X)
    W = J(n, n, 0)
    end

    But it gave the error:
    J(): 3900 unable to allocate real <tmp>[257224,257224]
    <istmt>: - function returned error

    It doesn't give the same error when I reduce the number of observations, for example to 50,000.



    Does anyone have ideas on how to perform these tests on my dataset?

    Any help will be deeply appreciated!

  • #2
    I think the matsize is restricted to 65,534.

    Comment


    • #3
      In Mata, the Stata edition does not restrict the matrix size, so the limitation is the memory of the computer. The weight matrix is Mata will all contain 8-byte double-precision values, so the memory needed would be something like 8* (250e6)^2, which would be about 500 GB. That's going to take an impressive server...

      Comment


      • #4
        Whoops, should be 8 * (250e3)^2 = 500 GB.

        Comment

        Working...
        X