【问题标题】:Combining quantile regression plots组合分位数回归图
【发布时间】:2016-06-03 16:15:36
【问题描述】:

我在 Stata 中生成多个分位数回归图,然后我想将其与 community-contributed 命令 grc1leg 结合使用。与内置命令 graph combine 相比,此命令使用单个常见图例组合图形。

但是,当我运行我的代码时,我总是遇到以下错误:

Graph.graphs[1].legend.draw_view.set_false: class type not found
r(4018);

如果我将其他图表与grc1leg 结合起来,则不会发生这种情况。

下面是一个可重现的例子:

*load data
sysuse auto, clear
*Qreg 1
qreg price weight length foreign, quantile (0.5) 
grqreg foreign,  ci ols olsci graphregion(color(white)) 
graph save "H:\graph1.gph", replace
*Qreg 2
qreg price weight length foreign, quantile (0.5) 
grqreg foreign,  ci ols olsci graphregion(color(white)) 
graph save "H:\graph2.gph", replace

/* Combining graphs */
*grc1leg is a user written command that needs to be installed first
net install grc1leg, replace

cd H:\
graph combine graph1.gph graph2.gph 
grc1leg graph1.gph graph2.gph 

请注意,此示例中的 grqreg 也是 community-contributed 命令。

有什么建议可以解决这个问题吗?

我在之前的帖子中读到,grc1leg 会因为用户在两者之间使用图形编辑器或单词 key 出现在图形中而感到不安。这里也不是。

【问题讨论】:

    标签: graph stata


    【解决方案1】:

    grc1leg 命令在这里不起作用,因为grqreg 已经在内部组合了图形。因此,所需的图类类型被销毁。

    强制前者工作的唯一方法是在后者的源代码中更改以下行:

    *-> combine all graphs;
    
    if ("`nodraw'"=="nodraw") {;
        grc1leg `graphlist', nodraw `options';
     // graph combine `graphlist', nodraw `options';
    };
    
    if ("`nodraw'"=="") {;
        grc1leg `graphlist', `options';
     // graph combine `graphlist', `options';
    };
    

    也就是说,您需要使用grc1leg 来组合内部生成的各个图。

    完成此操作并重新加载 grqreg 后,以下内容将按预期工作:

    sysuse auto, clear
    
    qreg price weight length foreign, quantile (0.5) 
    grqreg foreign, ci ols olsci graphregion(color(white)) name(g1, replace) 
    
    qreg price weight length foreign, quantile (0.5) 
    grqreg foreign, ci ols olsci graphregion(color(white)) name(g2, replace) 
    
    grc1leg g1 g2, name(g3, replace)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-20
      • 1970-01-01
      • 2011-05-20
      • 2020-12-24
      • 2013-08-13
      • 1970-01-01
      • 2012-11-28
      • 2011-09-07
      相关资源
      最近更新 更多