以下是引用eblog在2008-8-24 9:53:00的发言:
再配上试用数据就更完美了
* 处理命令
*- 伪造一份非平行的面板数据
xtarsim y x eta, n(200) t(10) g(0) b(.8) r(.2) sn(9) seed(1234)
sum
replace tvar = tvar+1990
drop if x > 8 /* unblanced */
replace y = . if abs(y) < 0.08 /* y 包含缺漏值 */
replace x = . if abs(x) < 0.03 /* x 包含缺漏值 */
tsset ivar tvar
xtdes /*转换前的数据结果*/
*- 使用 xtbalance 命令进行转换
xtbalance, range(1991 2000) miss(_all)
* ==========结果===================
. clear
. ssc install xtarsim
checking xtarsim consistency and verifying not already installed...
all files already exist and are up to date.
.
. *- 伪造一份非平行的面板数据
. xtarsim y x eta, n(200) t(10) g(0) b(.8) r(.2) sn(9) seed(1234)
. sum
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
ivar | 2000 100.5 57.74874 1 200
tvar | 2000 5.5 2.873 1 10
y | 2000 -.2178288 3.324586 -10.44931 10.21746
x | 2000 -.143428 3.783924 -13.00195 11.69052
eta | 2000 -.1048423 .9430213 -3.450946 2.096194
. replace tvar = tvar+1990
(2000 real changes made)
. drop if x > 8 /* unblanced */
(27 observations deleted)
. replace y = . if abs(y) < 0.08 /* y 包含缺漏值 */
(36 real changes made, 36 to missing)
. replace x = . if abs(x) < 0.03 /* x 包含缺漏值 */
(8 real changes made, 8 to missing)
. tsset ivar tvar
panel variable: ivar (unbalanced)
time variable: tvar, 1991 to 2000, but with gaps
. xtdes /*转换前的数据结果*/
ivar: 1, 2, ..., 200 n = 200
tvar: 1991, 1992, ..., 2000 T = 10
Delta(tvar) = 1; (2000-1991)+1 = 10
(ivar*tvar uniquely identifies each observation)
Distribution of T_i: min 5% 25% 50% 75% 95% max
8 9 10 10 10 10 10
Freq. Percent Cum. | Pattern
---------------------------+------------
176 88.00 88.00 | 1111111111
6 3.00 91.00 | 111111111.
3 1.50 92.50 | .111111111
3 1.50 94.00 | 1111.11111
3 1.50 95.50 | 111111.111
2 1.00 96.50 | 1.11111111
2 1.00 97.50 | 111.111111
1 0.50 98.00 | 1..1111111
1 0.50 98.50 | 11..111111
3 1.50 100.00 | (other patterns)
---------------------------+------------
200 100.00 | XXXXXXXXXX
.
. *- 使用 xtbalance 命令进行转换
. xtbalance, range(1991 2000) miss(_all)
(44 observations deleted due to missing)
(519 observations deleted due to discontinues)
.
. xtdes /*转换后的数据结果*/
ivar: 1, 2, ..., 200 n = 141
tvar: 1991, 1992, ..., 2000 T = 10
Delta(tvar) = 1; (2000-1991)+1 = 10
(ivar*tvar uniquely identifies each observation)
Distribution of T_i: min 5% 25% 50% 75% 95% max
10 10 10 10 10 10 10
Freq. Percent Cum. | Pattern
---------------------------+------------
141 100.00 100.00 | 1111111111
---------------------------+------------
141 100.00 | XXXXXXXXXX

[em05]
[此贴子已经被作者于2009-3-29 10:39:14编辑过]
eblog 金币 +3 金钱 +25 魅力 +15 经验 +25 好文章 2008-8-28 13:59:48