分位数回归图(grqreg)将具有多个单词的标题解释为与多个​​图形相关联

时间:2016-05-11 09:49:33

标签: stata

我在Stata中使用qreg来运行分位数回归,然后我想使用grqreg绘制一个系数的分位数回归图。只要我不尝试标题,我就可以生成没有任何问题的图表。 当我将标题放入" 变量 - 数据集"我收到错误消息:

  

与变量数量不同的标题数量

概述问题的一些示例代码如下:

*setup
webuse auto, clear
keep price mpg headroom foreign
compress
*running quantile regression
qreg price mpg headroom foreign
*creating a quantile regression plot for the binary variable foreign
grqreg foreign, ci ols olsci graphregion(color(white))

*so far everything works and is uncontroversial
*now i quietly re-run the quantile regression 
quietly: qreg price mpg headroom foreign
*and try to put a title on this graph with multiple words
*none of the below work
*grqreg always seems to think that each word in the title relates to a variable
grqreg foreign, ci ols olsci title(this is a title using multiple words)
grqreg foreign, ci ols olsci title("this is a title using multiple words")
grqreg foreign, ci ols olsci title('this is a title using multiple words')
grqreg foreign, ci ols olsci title((this is a title using multiple words))

*one worded title 
quietly: qreg price mpg headroom foreign
grqreg foreign, ci ols olsci title(this_is_a_title_with_one_word)

非常感谢任何帮助。谢谢!

1 个答案:

答案 0 :(得分:0)

grqreg是来自SSC的用户编写的命令,必须先安装,然后才能尝试代码。在Statalist,您需要解释这一点,并且没有理由在此处降低标准。

你是正确的title()选项被编程为为每个使用的图表剥离一个单词,但是虽然这是特殊的,但是grqreg的帮助中记录了该选项。办法。即使用" "绑定也试图强制使用多个单词标题将不起作用,因为该选项被声明为title(string),这意味着字符串分隔符在输入时被剥离。您可以尝试通过黑客攻击代码来破坏title(string asis)。然而,这似乎不值得烦,因为有一个更容易的解决方法。

您可以使用选项t1title()。如果获得与title()相同的样式和/或位置通常对您很重要,那么根据需要添加子选项。

* setup
webuse auto, clear
keep price mpg headroom foreign
compress

* running quantile regression
qreg price mpg headroom foreign

* creating a quantile regression plot for the binary variable foreign
* must install previously with -ssc inst grqreg- 
grqreg foreign, ci ols olsci graphregion(color(white))

* so far everything works and is uncontroversial
* now I quietly re-run the quantile regression 
quietly: qreg price mpg headroom foreign
*and try to put a title on this graph with multiple words

* t1title() is a work-around for title()
* grqreg foreign, ci ols olsci t1title(this is a title using multiple words)
grqreg foreign, ci ols olsci t1title(this is a title using multiple words, size(large) )