sysuse nlsw88, clear
g coef=.
g t=tenure*12
qui forv i=30 (1) 100 {
reg wage grade if t<`i', r
replace coef=_b[grade] in `i'
}
g maxt=_n in 30/100
line coef maxt
tabdisp maxt, c(coef)
Saturday, October 24, 2009
Graphs in panels by Maarten L. Buis
sysuse auto, clear
recode rep78 1/2=3
egen byvar = group(foreign rep78)
label define byvar 1 "Average" 2 "Good" 3 "Excelent" ///
4 " " 5 " " 6 " "
label value byvar byvar
scatter price mpg , ///
by(byvar, ///
r2title(Car type, orientation(rvertical)) ///
t1title(Repair Record 1978, size(medsmall))) ///
name(col, replace)
.col.plotregion1.r1title[3]._set_orientation rvertical
.col.plotregion1.r1title[3].text = {}
.col.plotregion1.r1title[3].text.Arrpush Domestic
.col.plotregion1.r1title[6].text = {}
.col.plotregion1.r1title[6].text.Arrpush Foreign
graph display
recode rep78 1/2=3
egen byvar = group(foreign rep78)
label define byvar 1 "Average" 2 "Good" 3 "Excelent" ///
4 " " 5 " " 6 " "
label value byvar byvar
scatter price mpg , ///
by(byvar, ///
r2title(Car type, orientation(rvertical)) ///
t1title(Repair Record 1978, size(medsmall))) ///
name(col, replace)
.col.plotregion1.r1title[3]._set_orientation rvertical
.col.plotregion1.r1title[3].text = {}
.col.plotregion1.r1title[3].text.Arrpush Domestic
.col.plotregion1.r1title[6].text = {}
.col.plotregion1.r1title[6].text.Arrpush Foreign
graph display
Saturday, October 17, 2009
Graph: Heat map
Statalist Fri, 16 Oct 2009
by Austin Nichols
sysuse nlsw88, clear
g g=max(grade,8)
la var g "Years of education"
ren married m
collapse wage, by(g m)
g w=round(wage,.01)
su wage, meanonly
g c=round((wage-r(min))/(r(max)-r(min))*255)
qui levelsof c, loc(cs)
loc g
foreach c of loc cs {
loc g `g'||sc m g if c==`c', ms(S) msize(ehuge) mc("`c' 100 100")
}
loc g `g'||sc m g, ms(i) mlab(w) mlabp(0)
loc g `g' leg(off) yla(-.75 " " 0 "N" 1 "Y" 1.75 " ", notick)
loc g `g' xla(7 " " 8/18 19 " ", notick)
tw `g' scheme(s1mono) ti(Wage heat map) xsize(8) ysize(5)
**********************
Same code (with a different color palette)
sysuse nlsw88, clear
g g=max(grade,8)
la var g "Years of education"
ren married m
collapse wage, by(g m)
g w=round(wage,.01)
su wage, meanonly
g c=round((wage-r(min))/(r(max)-r(min))*255)
qui levelsof c, loc(cs)
loc g
foreach c of loc cs {
loc c1=120+round(`c'/2)
loc c2=255-round(`c'/2)
loc m mc("`c2' `c2' `c1'")
loc g `g'||sc m g if c==`c', ms(S) msize(ehuge) `m'
}
loc g `g'||sc m g, ms(i) mlab(w) mlabp(0)
loc g `g' leg(off) yla(-.75 " " 0 "N" 1 "Y" 1.75 " ", notick)
loc g `g' xla(7 " " 8/18 19 " ", notick)
tw `g' scheme(s1mono) ti(Wage heat map) xsize(8) ysize(5)
by Austin Nichols
sysuse nlsw88, clear
g g=max(grade,8)
la var g "Years of education"
ren married m
collapse wage, by(g m)
g w=round(wage,.01)
su wage, meanonly
g c=round((wage-r(min))/(r(max)-r(min))*255)
qui levelsof c, loc(cs)
loc g
foreach c of loc cs {
loc g `g'||sc m g if c==`c', ms(S) msize(ehuge) mc("`c' 100 100")
}
loc g `g'||sc m g, ms(i) mlab(w) mlabp(0)
loc g `g' leg(off) yla(-.75 " " 0 "N" 1 "Y" 1.75 " ", notick)
loc g `g' xla(7 " " 8/18 19 " ", notick)
tw `g' scheme(s1mono) ti(Wage heat map) xsize(8) ysize(5)
**********************
Same code (with a different color palette)
sysuse nlsw88, clear
g g=max(grade,8)
la var g "Years of education"
ren married m
collapse wage, by(g m)
g w=round(wage,.01)
su wage, meanonly
g c=round((wage-r(min))/(r(max)-r(min))*255)
qui levelsof c, loc(cs)
loc g
foreach c of loc cs {
loc c1=120+round(`c'/2)
loc c2=255-round(`c'/2)
loc m mc("`c2' `c2' `c1'")
loc g `g'||sc m g if c==`c', ms(S) msize(ehuge) `m'
}
loc g `g'||sc m g, ms(i) mlab(w) mlabp(0)
loc g `g' leg(off) yla(-.75 " " 0 "N" 1 "Y" 1.75 " ", notick)
loc g `g' xla(7 " " 8/18 19 " ", notick)
tw `g' scheme(s1mono) ti(Wage heat map) xsize(8) ysize(5)
Thursday, October 15, 2009
Table of summary statistics by subgroups
eststo clear
sysuse auto, clear
eststo regression: reg price weight mpg
quietly bysort foreign: eststo: estpost summarize price weight mpg
esttab est*, label nodepvar cells( mean(fmt(2)) sd(par fmt(2)) )
or
eststo clear
sysuse auto, clear
eststo regression: reg price weight mpg
quietly bysort foreign: eststo, prefix(descr): estpost summarize price weight mpg
esttab descr*, label nodepvar cells( mean(fmt(2)) sd(par fmt(2)) )
sysuse auto, clear
eststo regression: reg price weight mpg
quietly bysort foreign: eststo: estpost summarize price weight mpg
esttab est*, label nodepvar cells( mean(fmt(2)) sd(par fmt(2)) )
or
eststo clear
sysuse auto, clear
eststo regression: reg price weight mpg
quietly bysort foreign: eststo, prefix(descr): estpost summarize price weight mpg
esttab descr*, label nodepvar cells( mean(fmt(2)) sd(par fmt(2)) )
Subscribe to:
Posts (Atom)