全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
11661 5
2014-11-25
这两天做quantile regression+绘图的时候遇到这样的问题:
我的代码是这样的:
. set more off
. save tempcf, replace emptyok  
file tempcf.dta saved
.
. forvalues q = 0.05(0.05)0.95 {
  2.   quietly rifreg lgw parent age $Educ $Work $health if work == 1 & female==1, quantile(`q') w(0.06)
  3.   matrix B=e(b)
  4.   svmat double B, name(coef)
  5.   gen quant=`q'
  6.   keep quant coef*
  7.   keep if _n==1  
  8.   append using tempcf
  9.   save tempcf, replace
10.  }

然后报错:
(14859 observations deleted)
(label d40 already defined)
(label d38 already defined)
(label d37 already defined)
(label d28 already defined)
(label d26 already defined)
(label d25 already defined)

file tempcf.dta saved
new variables cannot be uniquely named or already defined
r(110);

我检查了,原来并没有coef* 或者quant变量在我的varlist里面,
但是我找不到already defined 的变量是那个QAQ

求助~~

二维码

扫码加我 拉你入群

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

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

全部回复
2014-11-27 20:46:52
可以用capture drop命令删除
二维码

扫码加我 拉你入群

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

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

2014-12-6 10:00:23
ermutuxia 发表于 2014-11-27 20:46
可以用capture drop命令删除
我drop了所有的label还是会报错QAQ
二维码

扫码加我 拉你入群

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

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

2014-12-6 10:43:20
天使键小黑 发表于 2014-12-6 10:00
我drop了所有的label还是会报错QAQ
不只是label的问题

new variables cannot be uniquely named or already defined

你的新变量不能唯一的命名或者说你的新变量已经被定义了

建议你再好好检查下自己的变量,des下,再仔细阅读下自己的code,排查原因。没有人比你更了解自己的东东了,加油~!
二维码

扫码加我 拉你入群

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

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

2015-11-8 15:48:07
set more off
save tempcf, replace emptyok  

*** adjust the parameters of the forvalues command to estimate the quantiles of choice
*** in this example, the estimation is done at every fifth centile
*** you can remove quietly if you want to see the rif-regression results
forvalues q = 0.05(0.05)0.95 {
  use usmen0305_two, clear
  quietly rifreg lwage union educ exp expsq, quantile(`q') w(0.06)
  matrix B=e(b)
  svmat double B, name(coef)
  gen quant=`q'
  keep quant coef*
  keep if _n==1  
  append using tempcf
  save tempcf, replace
}

use tempcf, clear
sort quant
label var quant "Quantile"
*** choose the coefficient(s) that you want to graph, here coef1 is the coefficient of union coverage
graph twoway (connected coef1 quant if quant>0.0 & quant<1.0  ) /*
   */, xlabel(0.0 0.2 0.4 0.6 0.8 1.0) title("Union Premium") ytitle(" ") /*
   */  yline(0.0, lw(thin) lc(black)) saving(unionpr1,replace)

graph export unionpr1.wmf, replace
这是原文,tempcf是用于存储回归结果了,在循环的时候却要一次次调用回归所需要的数据文件。你的回归根本没有调用。在循环一次后你的语句就死掉了,因为此时的数据已经转化为tempcf,没有你用来回归的变量了亲。。不要以为作者写的语句是废话。。。
二维码

扫码加我 拉你入群

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

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

2016-10-21 00:04:59
I MEET THE SAME PROBLEM
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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