一、生成空间权重矩阵
1.Create a row-standardized binary spatial weights matrix assuming spherical coordinates and a distance cut-off of 10 miles(生成行标准化的二元空间权重矩阵)
. use 31_provinces_longitude&latitude,clear
.spwmatrix gecon latitude longitude, wn(wbin) wtype(bin) db(0 550) r(3958.761) row
.clear
.svmat wbin
.save wbin
2.Generate an inverse distance squared spatial weights matrix using projected latitudes and longitudes(生成距离倒数空间权重矩阵)
. use 31_provinces_longitude&latitude,clear
. spwmatrix gecon latitude longitude, wname(winvsq) wtype(inv) alpha(1) dband(0 100) cart
. clear
. svmat winvsq
. save winvsq
二、计算Moran's I
(一)计算全域Moran's I
1.使用距离倒数空间权重矩阵
. use winv.dta,clear
. spatwmat using winv.dta,name(winv) standardize
. use 31_provinces_core_variable_chn.dta,clear
. spatgsa pcrgdp_2002 pcrgdp_2003 pcrgdp_2004 pcrgdp_2005 pcrgdp_2006 pcrgdp_2007 pcrgdp_2008 pcrgdp_2009 pcrgdp_2010 pcrgdp_2011 pcrgdp_2012 pcrgdp_2013 pcrgdp_2014 pcrgdp_2015 pcrgdp_2016 ,weights(winv) moran(见图1)
. spatgsa bcs_2002 bcs_2003 bcs_2004 bcs_2005 bcs_2006 bcs_2007 bcs_2008 bcs_2009 bcs_2010 bcs_2011 bcs_2012 bcs_2013 bcs_2014 bcs_2015 bcs_2016 ,weights(winv) moran
. spatgsa ti_2002 ti_2003 ti_2004 ti_2005 ti_2006 ti_2007 ti_2008 ti_2009 ti_2010 ti_2011 ti_2012 ti_2013 ti_2014 ti_2015 ti_2016 ,weights(winv) moran
. spatgsa ts_2002 ts_2003 ts_2004 ts_2005 ts_2006 ts_2007 ts_2008 ts_2009 ts_2010 ts_2011 ts_2012 ts_2013 ts_2014 ts_2015 ts_2016 ,weights(winv) moran
2.使用二元空间权重矩阵
. use wbin.dta,clear
. spatwmat using wbin.dta,name(wbin) standardize
. use 31_provinces_core_variable_chn.dta,clear
. spatgsa pcrgdp_2002 pcrgdp_2003 pcrgdp_2004 pcrgdp_2005 pcrgdp_2006 pcrgdp_2007 pcrgdp_2008 pcrgdp_2009 pcrgdp_2010 pcrgdp_2011 pcrgdp_2012 pcrgdp_2013 pcrgdp_2014 pcrgdp_2015 pcrgdp_2016 ,weights(wbin) moran(见图2)
. spatgsa bcs_2002 bcs_2003 bcs_2004 bcs_2005 bcs_2006 bcs_2007 bcs_2008 bcs_2009 bcs_2010 bcs_2011 bcs_2012 bcs_2013 bcs_2014 bcs_2015 bcs_2016 ,weights(wbin) moran(计算效果不好)
. spatgsa ti_2002 ti_2003 ti_2004 ti_2005 ti_2006 ti_2007 ti_2008 ti_2009 ti_2010 ti_2011 ti_2012 ti_2013 ti_2014 ti_2015 ti_2016 ,weights(wbin) moran
. spatgsa ts_2002 ts_2003 ts_2004 ts_2005 ts_2006 ts_2007 ts_2008 ts_2009 ts_2010 ts_2011 ts_2012 ts_2013 ts_2014 ts_2015 ts_2016 ,weights(wbin) moran(计算效果不好)
(二)计算局域Moran's I
. use winv.dta,clear
. spatwmat using wbin.dta,name(winv) standardize
. use 31_provinces_core_variable_chn.dta,clear
. spatlsa pcrgdp_2002, w(winv) moran twotail(见图3)
三、画Moran’s I散点图
(一)二元空间权重矩阵(0-1空间权重矩阵)
. use wbin.dta,clear
. spatwmat using wbin.dta,name(wbin) standardize
. use 31_provinces_core_variable_chn.dta,clear
. spatlsa pcrgdp_2002,weights(wbin) moran graph(moran) symbol(id) id(prvn)(见图4)
. spatlsa pcrgdp_2002,weights(wbin) moran graph(moran) symbol(id) id(prvn) twotail
(二)距离倒数矩阵
. use winv.dta,clear
. spatwmat using winv.dta,name(winv) standardize
. use 31_provinces_core_variable_chn.dta,clear
. spatlsa pcrgdp_2002,weights(winv) moran graph(moran) symbol(id) id(prvn)(见图5)
. spatlsa pcrgdp_2002,weights(winv) moran graph(moran) symbol(id) id(prvn) twotail
THE END!
欢迎分享!欢迎转发!
励志与成功在统计学意义上存在显著的正相关关系,是引致成功空间溢出效应的关键因素之一!
THE WORLD IN YOUR HEART, AND TIE THE HEART TO THE BIG DIPPER!