ImageVerifierCode 换一换
格式:DOCX , 页数:10 ,大小:40.17KB ,
资源ID:11539327      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-11539327.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(用STATA做空间计量.docx)为本站会员(b****3)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

用STATA做空间计量.docx

1、用STATA做空间计量用STATA做空间计量How can I calculate Morans I in Stata?Note: The commands shown in this page are user-written Stata commands that must be downloaded. To install the package of spatial analysis tools, type findit spatgsa in the command window. Morans I is a measure of spatial autocorrelation-how

2、 related the values of a variable are based on the locations where they were measured. Using a set of user-written Stata commands, we can calculate Morans I in Stata. We will be using the spatwmat command to generate a matrix of weights based on the locations in our data and the spatgsa command to c

3、alculate Morans I or other spatial autocorrelation measures. Lets look at an example. Our dataset, ozone, contains ozone measurements from thirty-two locations in the Los Angeles area aggregated over one month. The dataset includes the station number (station), the latitude and longitude of the stat

4、ion (lat and lon), and the average of the highest eight hour daily averages (av8top). This data, and other spatial datasets, can be downloaded from the University of Illinoiss Spatial Analysis Lab. We can look at a summary of our location variables to see the range of locations under consideration.u

5、se http:/www.ats.ucla.edu/stat/stata/faq/ozone.dta, clearsummarize lat lon Variable | Obs Mean Std. Dev. Min Max-+- lat | 32 34.0146 .2228168 33.6275 34.69012 lon | 32 -117.7078 .5683853 -118.5347 -116.2339Based on the minimum and maximum values of these variables, we can calculate the greatest Eucl

6、idean distance we might measure between two points in our dataset.display sqrt(34.69012 - 33.6275)2 + (-116.2339 - -118.5347)2)2.5343326Knowing this maximum distance between two points in our data, we can generate a matrix based on the distances between points. In the spatwmat command, we name the w

7、eights matrix to be generated, indicate which of our variables are the x- and y-coordinate variables, and provide a range of distance values that are of interest in the band option. All of the distances are of interest in this example, so we create a band with an upper bound greater than our largest

8、 possible distance. If we did not care about distances greater than 2, we could indicate this in the band option. spatwmat, name(ozoneweights) xcoord(lon) ycoord(lat) band(0 3)The following matrix has been created:1. Inverse distance weights matrix ozoneweights Dimension: 32x32 Distance band: 0 d =

9、3 Friction parameter: 1 Minimum distance: 0.1 1st quartile distance: 0.4 Median distance: 0.6 3rd quartile distance: 1.0 Maximum distance: 2.4 Largest minimum distance: 0.50 Smallest maximum distance: 1.23 As described in the output, the command above generated a matrix with 32 rows and 32 columns b

10、ecause our data includes 32 locations. Each off-diagonal entry i, j in the matrix is equal to 1/(distance between point i and point j). Thus, the matrix entries for pairs of points that are close together are higher than for pairs of points that are far apart. If you wish to look at the matrix, you

11、can display it with the matrix list command. With our matrix of weights, we can now calculate Morans I. spatgsa av8top, weights(ozoneweights) moranMeasures of global spatial autocorrelationWeights matrix-Name: ozoneweightsType: Distance-based (inverse distance)Distance band: 0.0 d = 3.0Row-standardi

12、zed: No-Morans I- Variables | I E(I) sd(I) z p-value*-+- av8top | 0.248 -0.032 0.036 7.679 0.000-*1-tail testBased on these results, we can reject the null hypothesis that there is zero spatial autocorrelation present in the variable av8top at alpha = .05.VariationsBinary Matrix: If there exists som

13、e threshold distance d such that pairs with distances less than d are neighbors and pairs with distances greater than d are not, you can create a binary neighbors matrix with the spatwmat command (indicating bin and setting band to have an upper bound of d) and use this weights matrix for calculatin

14、g Morans I. We could do this for d = .75: spatwmat, name(ozoneweights) xcoord(lon) ycoord(lat) band(0 .75) binThe following matrix has been created:1. Distance-based binary weights matrix ozoneweights Dimension: 32x32 Distance band: 0 d = .75 Friction parameter: 1 Minimum distance: 0.1 1st quartile

15、distance: 0.4 Median distance: 0.6 3rd quartile distance: 1.0 Maximum distance: 2.4 Largest minimum distance: 0.50 Smallest maximum distance: 1.23spatgsa av8top, weights(ozoneweights) moranMeasures of global spatial autocorrelationWeights matrix-Name: ozoneweightsType: Distance-based (binary)Distanc

16、e band: 0.0 d = 0.75Row-standardized: No-Morans I- Variables | I E(I) sd(I) z p-value*-+- av8top | 0.188 -0.032 0.033 6.762 0.000-*1-tail testIn this example, the binary formulation of distance yields a similar result. We can reject the null hypothesis that there is zero spatial autocorrelation pres

17、ent in the variable av8top at alpha = .05. Using an existing matrix: If you have calculated a weights matrix according to some other metric than those available in spatwmat and wish to use it in calculating Morans I, spatwmat allows you to read in a Stata dataset of the required dimensions and forma

18、t it as a distance matrix that can be used by spatgsa. If altweights.dta is a dataset with 32 columns and 32 rows, it could be converted to a weighted matrix aweights to be used in spatgsa analyzing av8top:spatwmat using C:altweights.dta, name(aweights)How do I generate a variogram for spatial data

19、in Stata? When analyzing geospatial data, describing the spatial pattern of a measured variable is of great importance. User written Stata commands allow you to explore such patterns. This page will use the variog and variog2 command. To install this, type findit variog in your command window. The v

20、ariog command allows you to calculate and graph a variogram for regularly spaced one-dimensional data. The variog2 command allows you to calculate and graph a variogram for two-dimensional data without constraints on spacing. In both cases, the variogram illustrates how differences in a measured var

21、iable Z vary as the distances between the points at which Z is measured increase. Lets look at an example. Our dataset contains ozone measurements from thirty-two locations in the Los Angeles area aggregated over one month. The dataset includes the station number (station), the latitude and longitud

22、e of the station (lat and lon), and the average of the highest eight hour daily averages (av8top). This data, and other spatial datasets, can be downloaded from the GeoDa Center for Geospatial Analysis and Computation. use http:/www.ats.ucla.edu/stat/stata/faq/ozone, clearclist in 1/5 station av8top

23、 lat lon 1. 60 7.225806 34.13583 -117.9236 2. 69 5.899194 34.17611 -118.3153 3. 72 4.052885 33.82361 -118.1875 4. 74 7.181452 34.19944 -118.5347 5. 75 6.076613 34.06694 -117.7514For the sake of an example, lets imagine that instead of specific latitude and longitude locations, the stations are evenl

24、y spaced along a single latitude. If we assume the observations are in the order in which the stations appear, we can use the variog command. In the command, we indicate the measured outcome and we will opt for the calculated values to be listed. By default, a plot of the semi-variogram will be gene

25、rated. variog av8top, list +-+ | Lag Semi-variance # of pairs | |-| | 1 2.328506 31 | | 2 2.615086 30 | | 3 2.629862 29 | | 4 2.983584 28 | | 5 3.415026 27 | |-| | 6 2.923007 26 | | 7 4.104437 25 | | 8 3.378503 24 | | 9 3.531528 23 | | 10 4.49281 22 | |-| | 11 5.22965 21 | | 12 6.657857 20 | | 13 6.

26、5462 19 | | 14 6.126221 18 | | 15 6.556983 17 | |-| | 16 6.451519 16 | +-+ Next, lets generate a variogram using the latitude and longitude of the stations. For this, we will use the variog2 command. While the lag distance in variog was assumed to be the distance between each evenly spaced observati

27、on, variog2 requires the user to specify the lag distance. Lets look at a summary of our coordinates to get a sense of the distances existing in our data. summarize lat lon Variable | Obs Mean Std. Dev. Min Max-+- lat | 32 34.0146 .2228168 33.6275 34.69012 lon | 32 -117.7078 .5683853 -118.5347 -116.

28、2339Based on this, we can calculate the maximum possible distance we might see in our data.dis sqrt(33.6275 - 34.69012)2 + (-118.5347 - -116.2339)2)2.5343326As a starting point, we can choose a lag distance of .1 and we can examine distances up to 12 lags apart. We want to choose a lag distance that yields enough pairs in each lag to generate a variance that we trust. We might aim to have at least 15 pairs in each lag.variog2 av8top lat lon, width(.1) lags(12) list +-+ | Lag Semi-variance # of pairs | |-| | 1 4.729442 6 | | 2 1.8984

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2