全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
10702 5
2007-09-21

arlionn的说法输入

xtdata y x1-x7,fe

给出的结果是

no; data in memory would be lost
r(4);
请问大家这是为什么?有人遇到这种情况么?我用stata8.0/9.0/10.0都是这样!

但是输入

xtdata,fe clear

就可以

请问这和xtdata y x1-x7,fe命令等价么?

请达人指点!

二维码

扫码加我 拉你入群

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

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

全部回复
2007-9-21 18:04:00

Option"clear" specifies that the data may be converted even though the dataset has changed since it was last saved on disk

[此贴子已经被作者于2007-9-21 18:04:17编辑过]

二维码

扫码加我 拉你入群

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

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

2007-9-21 18:37:00

可是如果不选clear,结果就是no; data in memory would be lost
我用xtdata,fe clear后

看了下数据,好像没变化

二维码

扫码加我 拉你入群

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

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

2007-9-21 19:08:00
没有出现你说的这种情况
二维码

扫码加我 拉你入群

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

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

2007-9-22 15:25:00
以下是引用shaoshuai521在2007-9-21 16:48:00的发言:

arlionn的说法输入

xtdata y x1-x7,fe

给出的结果是

no; data in memory would be lost
r(4);
请问大家这是为什么?有人遇到这种情况么?我用stata8.0/9.0/10.0都是这样!

但是输入

xtdata,fe clear

就可以

请问这和xtdata y x1-x7,fe命令等价么?

请达人指点!


对比起,这是我的一个疏忽。使用xtdata时要注意两个问题:

1. 多数情况下,都需要附加 clear 选项,否则会出现上面的错误信息;

2. 建议将转换操作相关的命令都放在 preserve restore 配对命令中,以防止对原始数据的修改(对于具有喜欢保存数据恶习`的朋友这一点尤为重要!)

下面我举例说明这个命令的使用:

[-下载效果更好的范例-]

156738.pdf
大小:(18.54 KB)

 马上下载

156739.rar
大小:(4.33 KB)

 马上下载

本附件包括:

  • Stata Log File Browser Page.htm

* ====================== The codes =====================

*--> Goals for this notes:
* 1. show that the dataset before and after xtdata transform are different
* 2. show how to use xtdata command by tesing the higher order correlation of panel data

use "D:\stata9\ado\Examples\XTFiles\grunfeld.dta", clear

tsset company year /*declare Panel-variable and Time-variable*/
drop time

* -> The data will be changed after using `xtdata' command
* the original dataset
list in 1/5
* the transformed data
* FE
preserve
xtdata mvalue invest kstock year, fe clear
list in 1/5
restore
* RE
preserve
qui xtreg mvalue invest kstock, re theta
local theta = e(theta)
xtdata mvalue invest kstock year, re clear ratio(`theta')
list in 1/5
restore

*-> An example for using `xtdata' command
* abar: 高阶序列相关,for both re and fe
*-> for Fe model
preserve /*由于xtdata命令会删除原有变量*/
xtreg mvalue invest kstock ,fe
xtdata mvalue invest kstock year, fe clear
reg mvalue invest kstock
abar, lags(2) /*the arab command can only be used after reg, ivreg,ivreg2 command*/
restore

*=====================================================

* ====================== The results =====================

. do "C:\DOCUME~1\new\LOCALS~1\Temp\STD00000000.tmp"

. *--> Goals for this notes:
. * 1. show that the dataset before and after xtdata transform are different
. * 2. show how to use xtdata command by tesing the higher order correlation of panel data
.
. use "D:\stata9\ado\Examples\XTFiles\grunfeld.dta", clear

.
. tsset company year /*declare Panel-variable and Time-variable*/
panel variable: company (strongly balanced)
time variable: year, 1935 to 1954

. drop time

.
. * -> The data will be changed after using `xtdata' command
. * the original dataset
. list in 1/5

+-------------------------------------------+
| company year invest mvalue kstock |
|-------------------------------------------|
1. | 1 1935 317.6 3078.5 2.8 |
2. | 1 1936 391.8 4661.7 52.6 |
3. | 1 1937 410.6 5387.1 156.9 |
4. | 1 1938 257.7 2792.2 209.2 |
5. | 1 1939 330.8 4313.2 203.4 |
+-------------------------------------------+

. * the transformed data
. * FE
. preserve

. xtdata mvalue invest kstock year, fe clear

. list in 1/5

+----------------------------------------------------+
| company year invest mvalue kstock |
|----------------------------------------------------|
1. | 1 1935 -144.4617 -173.6639 -369.6179 |
2. | 1 1936 -70.26176 1409.536 -319.8179 |
3. | 1 1937 -51.46175 2134.936 -215.5179 |
4. | 1 1938 -204.3617 -459.964 -163.2179 |
5. | 1 1939 -131.2618 1061.036 -169.0179 |
+----------------------------------------------------+

. restore

. * RE
. preserve

. qui xtreg mvalue invest kstock, re theta

. local theta = e(theta)

. xtdata mvalue invest kstock year, re clear ratio(`theta')
(theta=0.7565)

. list in 1/5

+-------------------------------------------------------------------+
| company year invest mvalue kstock constant |
|-------------------------------------------------------------------|
1. | 1 463.9634 -142.3741 -200.1035 -487.7485 .2434885 |
2. | 1 464.9634 -68.17412 1383.097 -437.9485 .2434885 |
3. | 1 465.9634 -49.3741 2108.497 -333.6485 .2434885 |
4. | 1 466.9634 -202.2741 -486.4035 -281.3485 .2434885 |
5. | 1 467.9634 -129.1741 1034.597 -287.1485 .2434885 |
+-------------------------------------------------------------------+

. restore

.
. *-> An example for using `xtdata' command
. * abar: 高阶序列相关,for both re and fe
. *-> for Fe model
. preserve /*由于xtdata命令会删除原有变量*/

. xtreg mvalue invest kstock ,fe

Fixed-effects (within) regression Number of obs = 200
Group variable (i): company Number of groups = 10

R-sq: within = 0.4117 Obs per group: min = 20
between = 0.8078 avg = 20.0
overall = 0.7388 max = 20

F(2,188) = 65.78
corr(u_i, Xb) = 0.6955 Prob > F = 0.0000

------------------------------------------------------------------------------
mvalue | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
invest | 2.856166 .3075147 9.29 0.000 2.249543 3.462789
kstock | -.5078673 .1403662 -3.62 0.000 -.7847625 -.2309721
_cons | 804.9802 32.43177 24.82 0.000 741.0033 868.9571
-------------+----------------------------------------------------------------
sigma_u | 905.81517
sigma_e | 268.73329
rho | .91910377 (fraction of variance due to u_i)
------------------------------------------------------------------------------
F test that all u_i=0: F(9, 188) = 113.76 Prob > F = 0.0000

. xtdata mvalue invest kstock year, fe clear

. reg mvalue invest kstock

Source | SS df MS Number of obs = 200
-------------+------------------------------ F( 2, 197) = 68.93
Model | 9500910.96 2 4750455.48 Prob > F = 0.0000
Residual | 13576904.9 197 68918.2991 R-squared = 0.4117
-------------+------------------------------ Adj R-squared = 0.4057
Total | 23077815.9 199 115968.924 Root MSE = 262.52

------------------------------------------------------------------------------
mvalue | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
invest | 2.856166 .3004081 9.51 0.000 2.263737 3.448594
kstock | -.5078673 .1371224 -3.70 0.000 -.7782835 -.2374511
_cons | 804.9802 31.68228 25.41 0.000 742.5002 867.4602
------------------------------------------------------------------------------

. abar, lags(2) /*the arab command can only be used after reg, ivreg,ivreg2 command*/
Arellano-Bond test for AR(1): z = 3.30 Pr > z = 0.0010
Arellano-Bond test for AR(2): z = -0.33 Pr > z = 0.7397

. restore

*=====================================================



[此贴子已经被作者于2007-9-22 16:26:50编辑过]

二维码

扫码加我 拉你入群

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

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

2013-10-16 17:01:49
shaoshuai521 发表于 2007-9-21 18:37
可是如果不选clear,结果就是no; data in memory would be lost我用xtdata,fe clear后
看了下数据,好像没变 ...
您好,在xtdada命令后用list显示出来的数据与原数据有变化了,但是请问如何保存下来再进行helm处理呢?谢谢指点!
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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