楼主: liufang0129
5350 8

[数据管理求助] 用stata编辑空间邻接矩阵的顺序问题。 [推广有奖]

  • 0关注
  • 1粉丝

硕士生

58%

还不是VIP/贵宾

-

威望
0
论坛币
1 个
通用积分
0
学术水平
0 点
热心指数
1 点
信用等级
0 点
经验
1539 点
帖子
72
精华
0
在线时间
212 小时
注册时间
2009-6-4
最后登录
2021-5-11

楼主
liufang0129 发表于 2016-1-7 20:21:59 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

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

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

多谢多谢!

二维码

扫码加我 拉你入群

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

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

关键词:Stata 邻接矩阵 tata 数据文件 空间分析 encode 空间

沙发
ph5uck 发表于 2018-1-24 22:45:33
请问你解决了吗?

藤椅
tanxiaoyan123 发表于 2018-9-27 23:04:49
请问你最后怎么解决的,qq:1092221956,急求,谢谢

板凳
macc891207 学生认证  发表于 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

报纸
vivian416712 发表于 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.

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

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

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2026-1-2 10:32