grqreg与分类变量

时间:2018-03-04 13:38:24

标签: graph error-handling regression stata quantile

我正在使用SSC命令-grqreg-来绘制我方程的分位数回归图。我已经能够成功地绘制单个方程;但是,我现在正试图分开样本并单独估算。代码和错误如下:

enter image description here

我认为发生此错误是因为在拆分模型时,没有对其中一个内容指标的观察。我应该如何解决这个问题?即使varlist排除了指标变量,也会发生错误。

1 个答案:

答案 0 :(得分:1)

这很笨重,但您只需先删除省略的变量:

sysuse auto, clear
fvunab rhs: weight length i.f* i.rep* 
xi: qreg price `rhs' if foreign == 1

/* remove any variables prefixed with o. and the constant */
matrix list e(b)
local rhs2: colnames e(b)
di "`coefs'"
local rhs2 =  ustrregexra("`rhs2'","o\._I[a-zA-Z_0-9]+ ","") 
local rhs2 =  ustrregexra("`rhs2'","_cons","") 

/* Fit the model again with non-omitted variable set */
qreg price `rhs2' if foreign == 1
grqreg, cons ci ols olsci

请注意,在不同的论坛上cross-posting时告诉别人是否礼貌。

相关问题