Announcement

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

  • Creating equally sized contiguity and idistance matrices

    Hello everyone,

    I am having a problem when creating the spatial weighting matrices. My dependant variable is TransactionPrice (averaged) and the independent variables are distances to various amenities within Hong Kong (averages too). A section of the data is as follows:

    input double(_CX _CY Transactio MTR_Distan Public_Hou EV_Distanc URA_DIST) float _ID
    113.9345800000001 22.282470000000046 862.836363636 824.628421633 148.240345165 800.997461171 19600.4120175 1
    113.93639000000007 22.280550000000062 952.3 868.661747702 132.70744553 829.59234017 19590.4621557 2
    113.94356540000001 22.319290160000037 4408.234375 426.280901987 2333.29741139 139.059228819 17546.5927684 3

    The commands I have used to get to the matrix forming section are as follows;
    • spshape2dta Transactions_NEW
    • use Transactions_NEW
    • spset _ID, modify replace
    • spset, modify coordsys(latlong, kilometers)
    • gen _ID = _n
    • save, replace
    • spmatrix create contiguity W
      • (Response - weighting matrix in W contains 256 islands)
    • spmatrix create idistance M
    • spmatrix dir
    The table below is the result:

    Weighting matrix name N x N Type Normalization
    ------------------------------------------------------------------------
    M 381 x 381 idistance spectral
    W 627 x 627 contiguity spectral


    When creating the contiguity and idistance matrices, the (N x N) figures are vastly different. This is a problem when trying to run the spregress command as the following error is displayed:

    "_IDs in weighting matrix M do not match _IDs in weighting matrix W
    There are places in one matrix that are not in the other."

    The command used to do the spatial regression was:
    spregress Transactio MTR_Distan Public_Hou EV_Distanc URA_DIST, gs2sls dvarlag(W) ivarlag(W: MTR_Distan Public_Hou EV_Distanc URA_DIST ) errorlag(M)

    The following conformity error is repeatedly displayed:
    _IDs in weighting matrix M do not match _IDs in weighting matrix W
    There are places in one matrix that are not in the other.
    r(503);


    Please may someone assist me in getting these (N x N) figures to equal one another and for the regression to work. I feel that this is a problem with my data but cannot find much help online.

    Thank you in advance!
Working...
X