Announcement

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

  • Spatial weight matrix for panel regression

    Hi All,

    This is my sample panel data set and I am using spatial panel regression.

    [----------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int(PSUNO year) double(_CX _CY) float(mrate Shreduc8)
    1001 2008 87.224498 27.381614     93.75        .5
    1001 2010 87.224498 27.381614  42.55319        .5
    1002 2008 87.176285 27.419805  48.78049         1
    1002 2010 87.176285 27.419805  348.8372  .8666667
    1003 2008 87.211783 27.373134 14.084507         1
    1003 2010 87.211783 27.373134        20         1
    1005 2008 87.921324  26.90297 66.666664        .5
    1005 2010 87.921324  26.90297       125  .3333333
    1007 2008 87.320397 26.986749  71.42857        .6
    1007 2010 87.320397 26.986749 35.714287        .5
    1009 2008 86.681116  26.72125  69.76744  .3333333
    1009 2010 86.681116  26.72125  76.92308        .8
    1012 2008 86.691288 26.788099  40.40404        .5
    1012 2010 86.691288 26.788099  50.84746  .6666667
    1016 2008 87.663386  26.61772     93.75  .8888889
    1016 2010 87.663386  26.61772  76.92308        .4
    1017 2008 87.707675 26.676637 32.967033         1
    1017 2010 87.707675 26.676637  96.15385        .6
    1022 2008 88.056049 26.558981 14.705882         1
    1022 2010 88.056049 26.558981  42.55319         1
    1025 2008 88.122829 26.674098 144.44444 .53846157
    1025 2010 88.122829 26.674098  74.07407       .75
    end
    ------------------ copy up to and including the previous line ------------------

    Listed 22 out of 998 observations]

    I have used following command to create cross sectional spatial weight matrix:

    [spwmatrix gecon _CY _CX, wn(knn4) knn(4) rowstand xport(knn4, txt) replace
    clear all
    insheet using "knn4.txt", delimiter(" ")
    list, table clean noheader
    save KNN4.dta, replace
    outsheet using KNN4.txt, delimiter(" ") nonames nolabel replace
    drop in 1
    spmat import KNN4 using KNN4.txt, replace normalize(row)
    spmat export KNN4 using KNN4.txt, replace
    spmat save KNN4 using KNN4.spmat, replace]
    [/CODE]

    After creating weight matrix I have tried to run spatial panel regression and its returns following conformability error.
    [spregxt mrate Shreeduc8, nc(#) wmfile(KNN4) model(sdmxt) run(xtfe) stand]
    [*** Standardized Weight Matrix (W): (998x998) : NC=499 NT=2 (Normalized)
    conformability error]

    I am wondering what is wrong with my weight matrix.

    Thanks for your help.

    Hari

  • #2
    I'm also facing a similar error.

    Comment

    Working...
    X