全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
5247 8
2016-01-07

用stata在做空间分析的时候,需要编辑一个空间邻接矩阵,比如我做的是我国各个省份的,这个矩阵的编辑顺序是什么?是不是要跟另外一个数据文件中的数据顺序完全一样?我觉得是不是不需要?还有一个问题是,编辑过程中,横行和列行的名称怎么命名?因为列行用过的名称横行好像是不能再用的。难道列行用的各省的名称,横行就只能用1、2、3来命名?那在使用过程中,stata能识别吗?

不知道有没有说清楚。刚开始学习空间方法,比较迷糊!

多谢多谢!

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2018-1-24 22:45:33
请问你解决了吗?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2018-9-27 23:04:49
请问你最后怎么解决的,qq:1092221956,急求,谢谢
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2019-10-7 01:29:34
空间矩阵应该和数据的id排序一致,提供一份排序代码

import excel "K:\计量作业\科技金融空间计量\01矩阵.xlsx", sheet("Sheet1") firstrow clear
encode 地区,generate(id)
sort id
drop 地区 id
xpose, varname clear
sort _varname
order _varname
levelsof _varname,local(name)
local i=1
foreach w in `name' {
        rename v`i' `w'
        local i=`i'+1
}
save 01矩阵.dta
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2021-9-26 14:22:59
不确定你说的是不是这个问题,但希望有用:

在进行spmatrix,stata官方文档里有:

To create the file listed below, we typed
. spmatrix create idistance Idist
. spmatrix export Idist using small.txt
(matrix Idist saved in file small.txt)
We did this after keeping four observations so that we would have a small file to show you.
The resulting file is
. type small.txt
4
20029 0 .225898983673981 .259698923068494 .746562405514367
33003 .225898983673981 0 .123515701241913 .187089086384635
41021 .259698923068494 .123515701241913 0 .264715523882705
48227 .746562405514367 .187089086384635 .264715523882705 0
The file records a 4 × 4 spatial weighting matrix. Real examples would record much larger matrices.
N × N matrices are recorded in N + 1 lines.
The first line states that N = 4. The matrix is 4 × 4.
The second and subsequent lines each record N + 1 values with spaces between them. The first
value, 20029, is the ID (FIPS) value corresponding to the first row of the weighting matrix.
The
remaining N values on the line are the first row of the matrix.
The remaining lines are repeats for the second row, third row, and so on. The first value is an
ID value and the rest are that ID’s row of the matrix.
It is a simple and easy-to-read file.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2021-11-3 22:19:09
macc891207 发表于 2019-10-7 01:29
空间矩阵应该和数据的id排序一致,提供一份排序代码

import excel "K:\计量作业\科技金融空间计量\01矩阵 ...
亲,这个命令能用,但是怎么根据我的数据Id排除特定的顺序啊
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群