Announcement

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

  • How to run LM- tes to check of Spatial Auto-correlation in panel data?

    Hello Dears

    I had run LM- tes to check of Spatial Auto-correlation in panel data but i got an error massage

    I followed this steeps :

    . use "G:\major\PhD\DATA\DATAfinal\datapaper2\data 4-12-2019.dta", clear

    . xtset id year
    panel variable: id (strongly balanced)
    time variable: year, 1992 to 2018
    delta: 1 unit

    . spatwmat using G:\major\PhD\DATA\DATAfinal\datapaper2\w1.dta, name(W)


    The following matrix has been created:

    1. Imported non-binary weights matrix W
    Dimension: 57x57



    . regress lpm10 lfdipc lgdppc lencpc lecbpc lecffpc,

    Source | SS df MS Number of obs = 1,539
    -------------+---------------------------------- F(5, 1533) = 42.98
    Model | 151.987114 5 30.3974228 Prob > F = 0.0000
    Residual | 1084.13059 1,533 .707195428 R-squared = 0.1230
    -------------+---------------------------------- Adj R-squared = 0.1201
    Total | 1236.11771 1,538 .803717624 Root MSE = .84095

    ------------------------------------------------------------------------------
    lpm10 | Coef. Std. Err. t P>|t| [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    lfdipc | -.0220951 .0248719 -0.89 0.374 -.0708817 .0266914
    lgdppc | .0550906 .0861201 0.64 0.522 -.113835 .2240163
    lencpc | -.6031066 .1194508 -5.05 0.000 -.8374108 -.3688023
    lecbpc | .8812698 .0875119 10.07 0.000 .709614 1.052926
    lecffpc | .0367151 .0726866 0.51 0.614 -.1058607 .1792908
    _cons | 3.087118 .3380565 9.13 0.000 2.424016 3.75022
    ------------------------------------------------------------------------------

    when I ren this command i got this massage:

    . spatdiag, weights(W)
    Matrix W is 57x57, regression has been carried out on 1539 obs.
    To run -spatdiag- weights matrix dimension must equal N. of obs

    pleas could u help me to solve this problem?
    Thanks in advance

  • #2
    Hello Abdo Ali, I want to ask if you have solved this problem. I am also having a similar issue.

    Please how did you solve it.

    I look forward to hearing from you

    Comment


    • #3
      That occurs because your weight matrix has different dimensions than your panel data. To solve this, you should restrict your spatdiag command by year. You could try what follows.

      Code:
      forvalues i=1992/2018 {
      preserve
      keep if year==`i'
      regress lpm10 lfdipc lgdppc lencpc lecbpc lecffpc
      spatdiag,weights(W)
      restore
      }
      You may want to read Stata's spmatrix help document, pages 108 and on: Here

      Comment

      Working...
      X