Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 65161

Error with user written program grc1leg. It produces 3 legends instead of 1 legend for combined 2 graphs!

$
0
0
Hi at all.

I try to use grc1leg with margins plot.


I have the strange error, that I get 3 in stead of 1 legend.

I tried to create an example, that closely follows my data, but I cannot manage with the auto dataset. But the idea is:

Code:
gen displ = 0 if displacement < = 100

replace displ = 1 if displacement > = 100

replace displ = 2 if displacement > = 200

label define displ 0 "Moederat" 1 "Medium" 2"Really high"

label values displ displ

gen expensive = 0 if price > 10000

replace expensive = 1 if price >= 10000


quietly: logit foreign c.headroom##c.weight##(1.expensive ib0.displ), ///

       noomitted noempty

  graph drop _all

quietly: margins, at(headroom=(2(0.5)4) weight=(2500) displ=(0 1 2)) over(expensive) 

marginsplot, by(expensive) scheme(s1color) name(m1) nodraw title("weight = 2.5") subtitle(, fcolor(white)) ///

 legend(cols(1) size(vsmall))  recast(line)

quietly: margins,  at(headroom =(2(0.5)4) weight=(3500)  displ=(0 1 2)) over(expensive) 

marginsplot, by(expensive) scheme(s1color) name(m2) nodraw title("weight = 3.5")subtitle(, fcolor(white)) recast(line)



grc1leg m1 m2, name(m3, replace) span legendfrom(m1)    ycommon      

graph display gme
The resulting error is in the attached picture. Array

Any suggestions how to overcome the problem are highly appreciated. Thanks!

Viewing all articles
Browse latest Browse all 65161

Trending Articles