stata应用课程 作图
stata应用课程 作图
Zilin Wang
Types of Stata Graphs
• Twoway plot
– Including scatterplots, line plots, fit plots, fit plots
with confidence intervals, area plots, bar plots,
range plots, and distribution plots.
• Scatterplot matrices
• Bar charts
• Box plots
• Pie charts
Types of Stata Graphs
scheme vg s2c
scheme vg s2m
Schemes
scheme vg s1c
scheme vg s1m
Options
This paper introduces a new long-run data set based on archival data from
historical waves of the Survey of Consumer Finances. Studying the joint
distribution of household income and wealth, we expose the central importance
of portfolio composition and asset prices for wealth dynamics in postwar
America. Asset prices shift the wealth distribution because of systematic
differences in household portfolios along the wealth distribution. Middle-class
portfolios are dominated by housing, while rich households predominantly own
business equity. Differential changes in equity and house prices shaped wealth
dynamics in postwar America and decoupled the income and wealth distribution
over extended periods.
Population shares of age groups
.3 .3
.2 .2
.1 .1
0 0
50
53
56
59
62
65
68
71
74
77
80
83
86
89
50
53
56
59
62
65
68
71
74
77
80
83
86
89
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
Population shares of college households,
and black households
College Black
.5 .5
Census share Census share
SCF+ share without adjustment SCF+ share without adjustment
SCF+ share with adjustment SCF+ share with adjustment
.4 .4
.3 .3
.2 .2
.1 .1
0 0
50
53
56
59
62
65
68
71
74
77
80
83
86
89
50
53
56
59
62
65
68
71
74
77
80
83
86
89
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
Population shares of college households,
and black households
.5
Census share
SCF+ share without adjustment
SCF+ share with adjustment
.4
.3
.2
.1
0
50
53
56
59
62
65
68
71
74
77
80
83
86
89
19
19
19
19
19
19
19
19
19
19
19
19
19
19
twoway connected CScollege yearmerge if (mod(yearmerge, 10) == 0), ///
msym(s) msize(medlarge) mfc(gs0) mlc(gs0) || ///
scatter share_college_oldwgt yearmerge if myear_ind == 1, msym(o) msize(large) mfc(red) mlc(red) || ///
scatter share_college_wgt yearmerge if myear_ind == 1, msym(d) msize(medlarge) mfc(blue) mlc(blue) ///
plotregion(color(white)) graphregion(color(white)) bgcolor(white) ///
xscale(r(1950 1990)) xlabel(1950(3)1990, angle(45)) yscale(r(0 0.5)) ///
ylabel(`ylab', angle(0)) xtitle("") ytitle("") ///
legend(ring(0) position(10) col(1) lab(1 "Census share") lab(2 "SCF+ share without adjustment") ///
lab(3 "SCF+ share with adjustment")) name("comp_census_`var'", replace)
graph export "${sav_dir}/comp_census_`var'.eps", replace
Comparison of income and wealth from
SCF1, NIPA, and FA data
Income Wealth
90 100 110 120 130 140 150
NIPA FA
75
50
50
40
1950 1960 1970 1980 1990 2000 2010 1950 1960 1970 1980 1990 2000 2010
Comparison of income and wealth from
SCF1, NIPA, and FA data
80
70
60
50
40
twoway ///
connected SCFtinc_I year, msize(large) mcolor(gs0) || ///
line NIPAtinc_I year, lpattern("--") lwidth(thick) lcolor(blue)/*
*/ legend(bplacement(nw) ring(0) col(1) order(2 1) symxsize(8) lab(1 "SCF+") lab(2 "NIPA"))
xscale(r(1950 2014)) xlabel(1950(10)2014) xtitle("") /*
*/ yscale(r(40 150)) ylabel(40(10)150) ytitle("") /*
*/ name("TINC_indexed", replace) scheme(s2mono) graphregion(color(white)) bgcolor(white)
graph export "${sav_dir}/SCF_NIPA_income_indexed.eps", replace
Gini coefficients for income and wealth
with 90% confidence bands
Income Wealth
.6 .95
.9
.55
.85
.5
.8
.45
.75
.4
.7
.35 .65
1950 1955 1960 1965 1970 1975 1980 1985 1990 1995 2000 2005 2010 2015 1950 1955 1960 1965 1970 1975 1980 1985 1990 1995 2000 2005 2010 2015
Gini coefficients for income and wealth
with 90% confidence bands
.6
.55
.5
.45
.4
.35
1950 1955 1960 1965 1970 1975 1980 1985 1990 1995 2000 2005 2010 2015
#delimit;
graph twoway
(rarea gini_tinc_lb gini_tinc_ub year, fcolor(eltblue) lcolor(eltblue) )
(connected gini_tinc yearmerge, mc(blue) msym(O) msize(large) lc(blue) lwidth(thick)),
xscale(r(1950 2016)) xlabel(1950(5)2015, labsize(medium)) xsize(6.5) xtitle("")
ytitle("",size(medlarge)) ylabel(0.35(0.05)0.6,angle(0) labsize(medium)) legend(off)
graphregion(color(white)) plotregion(margin(zero)) name("gini_tinc_CIs", replace)
;#delimit cr
graph export "${sav_dir}/gini_tinc_CIs.eps", replace
Percentile ratios for income and wealth
Income Wealth
2.5
3.5
5
50−25 ratio (left axis) 50−25 ratio (left axis)
12
75−50 ratio (right axis) 75−50 ratio (right axis)
11
90−50 ratio (right axis) 90−50 ratio (left axis)
10
4
2
9
2.5
3
7
2
1.5
2
1.5
5
4
1
1
1950 1960 1970 1980 1990 2000 2010 1950 1960 1970 1980 1990 2000 2010
Percentile ratios for income and wealth
2.5
3.5
50−25 ratio (left axis)
75−50 ratio (right axis)
90−50 ratio (right axis)
3
2
2.5
2
1.5
1.5
1
1
1950 1960 1970 1980 1990 2000 2010
twoway ///
line p5025income yearmerge , lwidth(thick) lpattern("l") lc(blue) xscale(r(1949 2017))
xlabel(1950(10)2010) xtitle("") || ///
line p7550income yearmerge , yaxis(2) lwidth(thick) lpattern("--") lc(red) || ///
line p9050income yearmerge , yaxis(2) lwidth(thick) lpattern("_") lc(black) /*
*/ yscale(r(1 2.5) axis(1)) yscale(r(1 3.5) axis(2)) ylabel(1(0.5)2.5, axis(1)) ylabel(1(0.5)3.5, axis(2))/*
*/ scheme(s2mono) graphregion(color(white)) bgcolor(white) ytitle("", axis(1)) ytitle("", axis(2)) /*
*/ legend(bplacement(nw) ring(0) col(1) lab(1 "50-25 ratio (left axis)") lab(2 "75-50 ratio (right axis)")
lab(3 "90-50 ratio (right axis)")) name("bottomincome", replace)
graph export "${sav_dir}/QuantileRatiosBottom90income.eps", replace
0 .1 .2 .3 .4
19
50
19
53
19
56
19
59
19
62
19
65
19
68
19
71
19
83
19
wealthy HtM
89
19
92
19
95
19
98
20
01
20
poor HtM 04
20
07
20
households (HtM)
10
20
13
20
16
Shares of poor and wealthy hand-to-mouth
Shares of poor and wealthy hand-to-mouth
households (HtM)
.4
.3
.2
.1
0
50
53
56
59
62
65
68
71
83
89
92
95
98
01
04
07
10
13
16
19
19
19
19
19
19
19
19
19
19
19
19
19
20
20
20
20
20
20
wealthy HtM poor HtM
3
2.5
2
2
1.5
1.5
1
1
.5
.5
0
0
1950 1955 1960 1965 1970 1975 1980 1985 1990 1995 2000 2005 2010 2015 1950 1955 1960 1965 1970 1975 1980 1985 1990 1995 2000 2005 2010 2015
0% − 50% 50% − 90% Top 10% 0% − 50% 50% − 90% Top 10%
Income and wealth growth for different
groups along the wealth distribution
2.5
2
1.5
1
.5
0
1950 1955 1960 1965 1970 1975 1980 1985 1990 1995 2000 2005 2010 2015
5 10 15 20 25 30 35 40 45 50 55 60
Assets: Debt: Assets: Debt:
housing + non−fin. assets housing debt housing + non−fin. assets housing debt
12
x 10,000
2 4
0
−2
−10 −5 0
−4
−6
1950 1960 1970 1980 1990 2000 2010 1950 1960 1970 1980 1990 2000 2010
Heterogeneity in household portfolios for
different groups along the wealth distribution
100
Assets: Debt: Assets: Debt:
housing + non−fin. assets housing debt housing + non−fin. assets housing debt
480
80
400
60
240 320
x 10,000
x 10,000
40
160
20
80
0
0
−20
1950 1960 1970 1980 1990 2000 2010 1950 1960 1970 1980 1990 2000 2010
Heterogeneity in household portfolios for
different groups along the wealth distribution
100
Assets: Debt:
housing + non−fin. assets housing debt
stocks + business non−housing debt
bonds + liquid and oth. fin. assets
80 60
x 10,000
40 20
0
−20