Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: New version of -spmlreg- and -spwmatrix- available on SSC


From   "P. Wilner Jeanty" <[email protected]>
To   [email protected]
Subject   st: New version of -spmlreg- and -spwmatrix- available on SSC
Date   Wed, 19 Mar 2014 12:35:53 -0400

Thanks to Kit Baum, -spmlreg- and -spwmatrix- have been updated on SSC.

Here are some features of the new version of -spwmatrix-:

1) Users can now import into Stata spatial weights created in both
ArcGIS and GeoDa. For example, you might want to generate a Delaunay
Triangle spatial weights matrix in ArcGIS and import it into Stata to
conduct the spatial analysis. The help file for -spwmatrix- contains
links to ArcGIS resource center that would show how to create a
spatial weights matrix and prepare it for import.

2) Spatial weights created and imported in Stata can be exported for
use in Matlab and R by specifying the -xport()- option like
xport(wghtmatrixname, dat).

3) Created and imported spatial weights can be used with the -spivreg-
command by Drukker et al. using either the -external- or -mataf-
option. For instance, if you specify the -external- option, you can
create an -spmat- object to be used with -spivreg- by coding:

. spmat putmatrix newspwgt spwgt, id(idvarname)

In the code above, spwgt is the name of the spatial weights matrix
previously created by -spwmatrix- and newspwght is the name of the
-spmat- object to be created for use with -spivreg- (or -spreg-,-
xsmle- for that matter). -idvarname- is the name of your id variable.
If you don't have one, you can create it by coding:

. gen idvarname=_n

4) Using the -xtw(#)- option, users can now generate spatial weights
for a balanced panel dataset. For example, you might want to generate
spatial weights for use with -splagvar- in order to generate spatially
lagged variables in a panel data context. Below are some suggestions
how to do that.

a) Sort your data by year and areal unit - crucial in spatial panel
data analysis

. sort year panelid

b) Generate the spatial weights matrix for a single year. It does not
matter which year you choose from your dataset since you will have the
same results. For example, you could type:

. spwmatrix gecon latitude longitude if year==2000, wname(spw_panel)
wtype(inv) alpha(2) row mataf xtw(20) dband(0,1000)  // just an
example

The key option here is xtw(20), where 20 is the number of years in your dataset.

c) Now give a call to -splagvar- to generate spatially lagged variables.

. splagvar depvar, wname(spw_panel) wfrom(Mata) ind(indepvars)
other_options // Here I use -wfrom(Mata)- since I specified the
-mataf- option when creating the weights matrix.



© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index