0
votes

I use qreg in Stata to run a quantile regression, then I want to graph a quantile regression plot for one coefficient using grqreg. I can produce a graph without any issues as long as I don't try to title it. When I put my title in "variable - dataset" I get the error message:

Number of titles different from number of variables

Some example code outlining the problem is below:

*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)

Any help is greatly appreciated. Thank you!

1
I've edited the title. It's clear that the title() option of grqreg works as its author intended and documented. So, the problem is not that the program misinterprets a command; it is that you want something different from that behaviour.Nick Cox
Thanks for the edit!Christoph

1 Answers

0
votes

grqreg is a user-written command from SSC and must be installed before your code can be attempted. On Statalist you'd be expected to explain that and there's no reason for lower standards here.

You're correct that the title() option is programmed to peel off one word for each graph used, but although that is idiosyncratic, the option is documented in the help for grqreg as working in that way. Trying to force a multiple word title even with " " to bind won't work as the option is declared title(string) which means that the string delimiters are stripped on input. You could try to subvert that by hacking at the code to insist on title(string asis). However, that doesn't seem worth the bother as there is a much easier work-around.

The option t1title() is available to you. If getting the style and/or position the same as title() would do normally is important to you, then add suboptions as needed.

* 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) )