Announcement

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

  • Testing for Spatial Autocorrelation in panel data

    Hello folks,

    I'm in the process of estimating the effects different measures of diversity have had on the growth of employment and income amongst Irish regions over the period 2008-2012. For reference my N=27 and T=5.

    I wish to check for spatial autocorrelation within the model – I understand how to carry this out when estimating the model under OLS but not for a panel estimation. Again for my own ease I collapsed the panel and variables to means and estimated Moran’s I that way. From this and mapping the data – spatial autocorrelation appears to be present, but I’m sure this is not the correct way to measure it?

    From searching online I'm unable to find any new references to testing for spatial autocorrelation for panel data. The closest reference I found was from Gordon Hughes http://www.stata.com/statalist/archi.../msg00860.html in 2011. He states,

    I have been developing a set of Stata routines specifically designed to estimate various specifications of spatial panel models. They are extended versions of procedures originally published as Matlab routines which I have translated to Mata. I intend to carry out some additional testing and error-checking over the next month, so that they should be ready for more general use in the fall.
    Perhaps these commands have been developed to test for spatial autocorrelation in panel models? I'm aware of the xsmle command http://www.stata.com/statalist/archi.../msg00860.html. However, one of the requirements for such is a The n x n matrix of spatial weights . However, matsize issues seem to occur when developing a matrix for a panel data estimation. Any information would be most welcome. Regards, Sean
    Last edited by Sean O'Connor; 01 Feb 2016, 04:27.

  • #2
    Just on a bump on this. What is the standard method to test for spatial autocorrelation in panel data? Average of the periods?

    Comment


    • #3
      Hello everybody,

      I do actually have the same question as Sean... How do I test for spatial autocorrelation in panel datasets and figure out which model to use, either spatial error or spatial lag model?
      I know that there is this ANKETEST but it did not work with my data. I get an error message:

      anketest, wname(SpWei_rook_panel) model(ols) wfrom(Stata)

      classdef _b_stat() in use
      (nothing dropped)
      (160 lines skipped)
      (error occurred while loading anketest.ado)
      r(310);


      Another question I have regarding lag dependence: How do I know if I should use a first, second or more order lagged dependent variables?
      splagvar houseval, wname(spweight1) wfrom(Mata) ind(income population education) order(#)

      Thank you!
      Last edited by Bastian Longer; 13 Jan 2017, 02:37.

      Comment


      • #4
        I'm also interested in this. Any solution?

        Comment


        • #5
          Dear All,


          The user-written spregxt command has extensive possibilities for spatial analysis, including all possible post-estimation tests.

          For the purpose of testing resuduals after a fixed effect regression estimation one could do, for instance:

          spregxt y x1 x2 x3, nc(# of cross-sectional units) model(ols) run(xtfe) wmfile(the weights DTA file) stand[if you want your weights row-standardized] lmspac

          This would give a range of statistics (Moran's I, Geary's C, Getis-Ord G*) for residuals and a bunch of other tests.

          Hope it helps.



          Sincerely,
          Anastasia

          Comment


          • #6
            Hi all,
            I share this question about testing for Moran's I in panel data, but want to ask it again now that Stata has released the Sp commands in Stata 15. I appreciate Anastasia's user-written suggestion, but am hopeful there is a way to do it using Stata's native commands. The Stata Spatial Autoregressive Models Reference Manual only offers a cross-sectional suggestion of:
            Code:
            estat moran, errorlag(W)
            When I run that syntax following a fixed effects panel model, I get this error message:
            estat moran not valid
            Any advice would be welcomed. Thank you!
            Brenden

            Comment


            • #7
              Dear all,

              I also have the same question as Sean and Brenden, but I suspect it has some generic source and will therefore start with this. Stata's spxtregress postestimation command does not have a command for predicting residuals. Typing
              Code:
              spxtregress dev_fallow dev_SPEI6, fe dvarlag(W)
              works, but the following postestimation command
              Code:
              predict res_model1, residual
              is not supported. Is there some reason why spxtregress does not support this command? While I manage to generate residuals by running the analysis on panel-demeaned variables and then subtracting predicted values from the panel-demeaned dependent variable, I am not fully confident that these are correct and the fact that getting residuals - one of the most useful postestimation commands in general - is not supported makes me think that this is not a slip on behalf of stata's developers. Is it rather due to some other more fundamental issue? I am therefore asking the same question, as Sean and Brenden, but also whether anyone knows whether Stata is working on developing postestimation commands for Stata's spxtregress that (i) predicts residuals in pamel models; (ii) allows for testing Moran's I and other tests of spatial dependence in the residuals of panel models; and (iii) testing different spatial panel models against each other? Furthermore, and related, does anyone know if stata will include pooled models that are not fixed nor random effects in their spxtregress models? This would be helpful for comparisons. Stata's handling of temporal issues has been very successful, and I hope/wish that spatial issues will also be further developed in stata's native packages.

              Best,
              Ole Magnus

              Comment


              • #8
                Originally posted by Sean O'Connor View Post
                Just on a bump on this. What is the standard method to test for spatial autocorrelation in panel data? Average of the periods?
                According to Beenstock & Felsenstein (The Econometric Analysis of Non-Stationary Spatial Panel Data, 2019, pg. 58), yes. But then you have test that average. In the pic below, V2 is the variance of this average. Haven't found a command on Stata that allows you to do this with a matrix created using spmatrix (as opposed to spwmat).


                Screen Shot 2020-11-03 at 9.38.57 PM.png

                Comment


                • #9
                  Dear all,
                  xtmoran command now available in STATA for testing for spatial autocorrelation in panel model as follows;
                  use panel.dta

                  . xtset id year

                  . xtmoran y, wname(w.dta)

                  . xtmoran y, wname(w.dta) morani(2012 2013 2014 2015)

                  . xtmoran y, wname(w.dta) morani(2012 2013 2014 2015) graph

                  . xtmoran y, wname(w.dta) morani(2012 2013 2014 2015) graph symbol(name)

                  Comment


                  • #10
                    Dear all,
                    xtmoran command now available in STATA for testing for spatial autocorrelation in panel model as follows;
                    use panel.dta

                    . xtset id year

                    . xtmoran y, wname(w.dta)

                    . xtmoran y, wname(w.dta) morani(2012 2013 2014 2015)

                    . xtmoran y, wname(w.dta) morani(2012 2013 2014 2015) graph

                    . xtmoran y, wname(w.dta) morani(2012 2013 2014 2015) graph symbol(name)

                    Comment


                    • #11
                      XTMORAN: Stata module to calculate Moran's I and Moran's Ii statistics for panel data and displaying a Moran scatterplot

                      Comment


                      • #12
                        I'm exploiting district level unbalanced panel data I generated a weight matrix 'w' using spwmatrix. Now I want to use xtmoran.
                        Prior to that w.dta should be there. I could not find the appropriate command.
                        Can you please advise how to export 'w' as a dta file?

                        Comment


                        • #13
                          I am also struggling withe the same issue as you, Souryabrata Mohapatra

                          Comment


                          • #14
                            I think #12 shifted to https://www.statalist.org/forums/for...-weight-matrix.

                            Comment

                            Working...
                            X