Dear Statalisters, thanks in advance for your help. I am aware that this topic has been already discussed in the past (and ucla has a page about it) but I am trying to modify the code excluding the outliers without succeeding on that.
The code provided on ucla is the follow:
use http://www.ats.ucla.edu/stat/data/hsb2, clear
sort prog
by prog: egen med = median(read)
by prog: egen lqt = pctile(read), p(25)
by prog: egen uqt = pctile(read), p(75)
by prog: egen iqr = iqr(read)
by prog: egen mean = mean(read)
twoway rbar lqt med prog, fcolor(gs12) lcolor(black) barw(.5) || ///
rbar med uqt prog, fcolor(gs12) lcolor(black) barw(.5) || ///
rspike lqt ls prog, lcolor(black) || ///
rspike uqt us prog, lcolor(black) || ///
rcap ls ls prog, msize(*6) lcolor(black) || ///
rcap us us prog, msize(*6) pstyle(p1) || ///
scatter outliers prog, mcolor(black) || ///
scatter mean prog, msymbol(Oh) msize(*2) fcolor(gs12) mcolor(black) ///
legend(off) xlabel( 1 "general" 2 "academic" 3 "vocational") ///
ytitle(reading score) graphregion(fcolor(gs15))
If I replace with my variables in it it works just fine but I failed in all the attempts to exclude the outliers. Could you please help me with this? Many thanks in advance, Raffaele
The code provided on ucla is the follow:
use http://www.ats.ucla.edu/stat/data/hsb2, clear
sort prog
by prog: egen med = median(read)
by prog: egen lqt = pctile(read), p(25)
by prog: egen uqt = pctile(read), p(75)
by prog: egen iqr = iqr(read)
by prog: egen mean = mean(read)
twoway rbar lqt med prog, fcolor(gs12) lcolor(black) barw(.5) || ///
rbar med uqt prog, fcolor(gs12) lcolor(black) barw(.5) || ///
rspike lqt ls prog, lcolor(black) || ///
rspike uqt us prog, lcolor(black) || ///
rcap ls ls prog, msize(*6) lcolor(black) || ///
rcap us us prog, msize(*6) pstyle(p1) || ///
scatter outliers prog, mcolor(black) || ///
scatter mean prog, msymbol(Oh) msize(*2) fcolor(gs12) mcolor(black) ///
legend(off) xlabel( 1 "general" 2 "academic" 3 "vocational") ///
ytitle(reading score) graphregion(fcolor(gs15))
If I replace with my variables in it it works just fine but I failed in all the attempts to exclude the outliers. Could you please help me with this? Many thanks in advance, Raffaele
Comment