use S003A S002 X001 C041 C039 C038 C037 if inlist(S002, 4, 5) ///
using WVS_Longitudinal_1981-2014_stata_v_2014_11_25.dta, clear
// Declare missing values
mvdecode C041 C039 C038 C037, mv(-5 -4 -3 -2 -1)
// Factor analysis
factor C041 C039 C038 C037, pcf
alpha C041 C039 C038 C037, item
local alph = round(`r(alpha)', .01)
// Prepare variables
scores nonworkethic = mean(C041 C039 C038 C037), nv(3)
generate workethic = 5 - nonworkethic
gen male = (X001 == 1) if X001 != -2
drop nonworkethic X001
// Create descriptive plot
foreach var of varlist C041 C039 C038 C037 {
recode `var' (1 = 4 "Strongly agree") ///
(2 = 3 "Agree") ///
(3 = 2 "Neither agree nor disagree") ///
(4 = 1 "Disagree") ///
(5 = 0 "Strongly disagree"), gen(`var'_rec)
numlabel `var'_rec, add mask("# ")
twoway histogram `var'_rec, discrete horizontal yla(0/4, valuelabel) percent ///
title("`: variable label `var''") ///
ytitle("") ///
name(`var', replace) nodraw
drop `var'_rec
}
graph combine C041 C039 C038 C037, col(2) row(2) altshrink title("Work ethic is measured as the average of four items:") ///
caption("In a PCA, all items load on one dimension; explained variance = 49%, Cronbach's alpha = `alph'", span) note("{it:Source:} WVS 1999-2009, pooled", span) name(figure1, replace)
drop C041 C039 C038 C037
// Calculate country differences
preserve
statsby mean_ = _b[_cons] ///
loci = (_b[_cons] - 1.96 * _se[_cons]) ///
hici = (_b[_cons] + 1.96 * _se[_cons]) ///
, by(S003A) clear: ///
regress workethic
// Sort coefficients by size
egen order_ = rank(mean_), unique
labmask order_, value(S003A) decode
// Plot
twoway (rcap mean_ mean_ order_, horizontal) ///
(rspike loci hici order_, horizontal) ///
, legend(off) ylabel(1/63, valuelabels ang(h) labsize(*.8)) ///
xlabel(0 (1) 4, grid format(%6.1f)) name(all, replace) ///
xmtick(0 (.5) 4) ///
ytitle("") xtitle("Work ethic across countries") ///
title("{bf:A}", justification(left) bexpand span) ///
xscale(alt) ysize(10) nodraw
restore
// Country differences--men only
preserve
statsby mean_ = _b[_cons] ///
loci = (_b[_cons] - 1.96 * _se[_cons]) ///
hici = (_b[_cons] + 1.96 * _se[_cons]) ///
, by(S003A) clear: ///
regress workethic if male == 1
// Sort coefficients by size
egen order_ = rank(mean_), unique
labmask order_, value(S003A) decode
// Plot
twoway (rcap mean_ mean_ order_, horizontal) ///
(rspike loci hici order_, horizontal) ///
, legend(off) ylabel(1/63, valuelabels ang(h) labsize(*.8)) ///
xlabel(0 (1) 4, grid format(%6.1f)) name(men, replace) ///
xmtick(0 (.5) 4) ///
ytitle("") xtitle("Men's work ethic across countries") ///
title("{bf:B}", justification(left) bexpand span) ///
xscale(alt) ysize(10) nodraw
restore
// Calculate gender gap
preserve
statsby mean_ = _b[male] ///
loci = (_b[male] - 1.96 * _se[male]) ///
hici = (_b[male] + 1.96 * _se[male]) ///
, by(S003A) clear: ///
regress workethic male
// Sort coefficients by size
egen order_ = rank(mean_), unique
labmask order_, value(S003A) decode
// Plot
twoway (rcap mean_ mean_ order_, horizontal) ///
(rspike loci hici order_, horizontal) ///
, legend(off) ylabel(1/63, valuelabels ang(h) labsize(*.8)) ///
xlabel(-.25 (.25) .5, grid format(%6.2f)) name(gendergap, replace) ///
xmtick(-.25 (.1) .5) ///
text(63 .5 "Men" "higher", place(sw)) ///
text( 1 -.25 "Women" "higher", place(ne)) ///
ytitle("") xtitle("Gender gap in work ethic") ///
title("{bf:C}", justification(left) bexpand span) ///
xscale(alt) ysize(10) nodraw
restore
graph combine all men gendergap, note(" " "{it:Source:} WVS 1999-2009, pooled", span) col(3) ysize(12) xsize(18) altshrink ///
title("Work ethic in cross-national comparison", span) name(figure2, replace)
Showing posts with label numlabel. Show all posts
Showing posts with label numlabel. Show all posts
May 25, 2017
Random graphs (96): Categorical variables
Mar 10, 2016
Random graphs (62): Histograms
qui summarize challenging
local m = round(r(mean), .1)
local sd = round(r(mean), .1)
local n = r(N)
numlabel challenging, add mask("# ")
twoway histogram challenging, discrete yla(, valuelabel) horizontal gap(20) ///
freq ytitle("") start(1) xlabel(0/4, grid) ///
title("How" "{bf:challenging}" "was this paper?", span) ///
xsize(3) note("Mean = `m', {it:SD} = `sd', {it:N} = `n'", span) ///
name(challenging, replace)
qui summarize interesting
local m = round(r(mean), .1)
local sd = round(r(mean), .1)
local n = r(N)
numlabel interesting, add mask("# ")
twoway histogram interesting, discrete yla(, valuelabel) gap(20) horizontal ///
freq ytitle("") start(1) xlabel(0/4, grid) ///
title("How" "{bf:interesting}" "was this paper?", span) ///
xsize(3) note("Mean = `m', {it:SD} = `sd', {it:N} = `n'", span) ///
name(interesting, replace)
qui summarize recommendable
local m = round(r(mean), .1)
local sd = round(r(mean), .1)
local n = r(N)
numlabel recommendable, add mask("# ")
twoway histogram recommendable, discrete yla(, valuelabel) gap(20) horizontal ///
freq ytitle("") start(1) xlabel(0/4, grid) ///
title("How likely are you to" "{bf:recommend}" "this paper to a friend?", span) ///
xsize(3) note("Mean = `m', {it:SD} = `sd', {it:N} = `n'", span) ///
name(recommendable, replace)
graph combine challenging interesting recommendable, row(1)
Labels:
graph combine,
local,
numlabel,
Random graphs,
twoway histogram
Feb 14, 2016
Random graphs (58): Descriptives of a categorical variable
numlabel health, add mask("[#] ")
twoway histogram health, discrete yla(, valuelabel) gap(20) horizontal percent
numlabel health, remove mask("[#] ")
Subscribe to:
Posts (Atom)



