unzipfile output961465243413697143.zip, replace
use ESS1-6e01_1_F1.dta, clear
// Label waves
label define essround 1 "2002" 2 "2004" 3 "2006" 4 "2008" 5 "2010" 6 "2012"
label val essround essround
// Keep only countries that contribute six observations
egen pickone = tag(cntry essround)
tab cntry essround if pickone // Look at no. of waves per country
egen numrounds = total(pickone), by(cntry) // Calculate no. of waves per country
keep if numrounds == 6
// Identify migrants
generate migrant = 1 if (brncntr == 2) & !missing(brncntr)
replace migrant = 2 if (brncntr == 1 & (facntr == 2 | mocntr == 2)) & !missing(brncntr, facntr, mocntr)
replace migrant = 0 if (brncntr == 1 & facntr == 1 & mocntr == 1) & !missing(brncntr, facntr, mocntr)
label define migrant 0 "Native" 1 "First-generation migrant" 2 "Second-generation migrant"
label value migrant migrant
// Generate country identifier
kountry cntry, from(iso2c)
rename NAMES_STD country
replace country = "Slovenia" if country == "si"
// By country, year, and migrant status
collapse (mean) imbgeco imueclt imwbcnt [pweight = dweight], by(country essround migrant)
drop if migrant == .
sort country migrant essround
twoway (connected imbgeco essround if migrant == 0, ///
by(country, note(" " "{it:Source:} European Social Survey, rounds 1{c 150}6, weighted data", span size(*.8)))) ///
(connected imbgeco essround if migrant == 1) ///
(connected imbgeco essround if migrant == 2) ///
, xlabel(1/6, val ang(v)) ytitle("Immigration good for economy") ysize(8) xtitle("") name(imbgecocym, replace) ///
legend(order(1 "Natives" ///
2 "First-gen." ///
3 "Second-gen.") ring(0) row(1))
Showing posts with label unzipfile. Show all posts
Showing posts with label unzipfile. Show all posts
May 4, 2016
Random graphs (80): Line plots using the -by- option
Labels:
collapse,
egen,
European Social Survey,
kountry,
Random graphs,
twoway connected,
unzipfile,
weight
Apr 4, 2016
Random graphs (70): Bar graphs for interaction plots
unzipfile "output7717034280080927434.zip", replace
use ESS1-6e01_0_F1, clear
*use cntry essround stfjbot wkhct using ESS1-6e01_0_F1, clear
// Select Round 5
keep if inlist(essround, 5)
// Fix country variable
encode cntry, gen(country)
// Satisfaction with WLB
rename stfjbot swlb
// Contracted working hours
recode wkhct ( 0/20 = 1 "Marginal part-time") ///
( 21/34.75 = 2 "Substantial part-time") ///
(35/220 = 0 "Full-time") ///
, gen(parttime)
label var parttime "Working hours"
// Professional status
generate professional = .
replace professional = (iscoco >= 1000 & iscoco <= 2999)
label var professional "Professional status"
label define professional 0 "Non-prof." 1 "Professional"
label val professional professional
// Sex
recode gndr ( 2 = 1 "Female") ///
( 1 = 0 "Male") ///
(.a = .a "No answer") ///
, gen(female) label(female)
label var female "Gender"
// Select cases: Those in paid work and with a partner
keep if partner == 1 & mnactic == 1
// Are part-time workers more satisfied with their WLB than full-time employees?
qui regress swlb i.parttime i.country, cluster(country)
estimates store m1
// Hypothesis 1b: The effect is stronger for marginal PT than substantial PT.
qui test 1.parttime == 2.parttime
local F = round(r(F), .001)
local p = round(r(p), .001)
local r = r(df)
qui margins, at(parttime=(0 1 2))
marginsplot, recast(bar) ///
title("SWLB difference between full-time and part-time workers", size(large)) ///
plotopts(fcolor(gs14) lcolor(black)) ytitle("Predicted SWLB") ylabel(6 (.5) 7.5, format(%6.1f) grid) ///
name(noint, replace) xtitle("") ysize(3) ///
note(" " ///
"Marginal and substantial part-time" ///
"differs significantly:" ///
"{it:F}(`r', `r(df_r)') = `F', {it:p} = `p'", ///
pos(11) ring(0) bmargin(small)) ///
nodraw
// Are professional part-time workers less satisfied than non-professional part-time workers?
qui regress swlb i.parttime##i.professional i.country, cluster(country)
estimates store m2
qui margins, at(parttime=(0 1 2) professional=(0 1))
marginsplot, recast(bar) xdimension(professional) ///
bydimension(parttime) byopts(row(1) noiyaxes imargin(zero) ///
title("Interaction part-time status and professional status")) ///
subtitle(, pos(6)) /// // Place label of by dimensions below plot
plotopts(fcolor(gs14) lcolor(black)) ytitle("Predicted SWLB") ylabel(6 (.5) 7.5, format(%6.1f)) ///
name(int1, replace) xtitle("") ysize(3) nodraw
// Are women working part-time more satisfied with their SWLB than part-time working men?
qui regress swlb i.parttime##i.female i.country, cluster(country)
estimates store m3
qui margins, at(parttime=(0 1 2) female=(0 1))
marginsplot, recast(bar) xdimension(female) ///
bydimension(parttime) byopts(row(1) noiyaxes imargin(zero) ///
title("Interaction part-time status and gender")) ///
subtitle(, pos(6)) /// // Place label of by dimensions below plot
plotopts(fcolor(gs14) lcolor(black)) ytitle("Predicted SWLB") ylabel(6 (.5) 7.5, format(%6.1f)) ///
name(int2, replace) xtitle("") ysize(3) nodraw
// Output table and figure
esttab m1 m2 m3 using test.tex, compress replace se label nomtitles ///
indicate(Country dummies = *country) ///
varwidth(30) interaction(" X ") ///
title(Regression table\label{tab1}) ///
booktabs
graph combine noint int1 int2, col(1) ysize(9) ///
note("95% CI's based on cluster-robust standard errors")
Feb 26, 2016
Generating a country–year variable
unzipfile "output7717034280080927434.zip", replace
use cntry essround happy using ESS1-6e01_0_F1, clear
// Generate country-year variable
levelsof cntry, local(levels1)
levelsof essround, local(levels2)
gen cyear = ""
foreach country of local levels1 {
foreach round of local levels2 {
replace cyear = "`country'" + "`round'" if cntry == "`country'" & essround == `round'
di "`country'" "`round'"
}
}
label var cyear "Country-Year"
// Fit three-level model
mixed happy || cntry: || cyear:
estat icc
capture drop u1* u0*
predict u1 u0, reffects
predict u1se u0se, reses
// Plot country-level variation
preserve
egen pickone = tag(cntry)
keep if pickone
egen order_ = rank(-u1), unique
labmask order_, value(cntry)
gen high = u1 + (1.96 * u1se)
gen low = u1 - (1.96 * u1se)
twoway (rcap u1 u1 order_, dsymbol(x)) ///
(rspike high low order_) , ///
yline(0) xlabel(1/32, val ang(v)) ///
xtitle("") ///
ytitle("Country-level residuals") ///
legend(off) ///
name(cntry, replace)
restore
// Plot country-year level variation
preserve
egen pickone = tag(cyear)
keep if pickone
egen order_ = rank(-u0), unique
labmask order_, value(cyear)
gen high = u0 + (1.96 * u0se)
gen low = u0 - (1.96 * u0se)
twoway (rcap u0 u0 order_, dsymbol(x) horizontal) ///
(rspike high low order_, horizontal) , ///
xline(0) ylabel(none) ///
xscale(alt) ///
ytitle("") ///
xtitle("Country{c 150}year-level residuals") ///
legend(off) ///
name(cyear, replace) ysize(8)
restore
Subscribe to:
Posts (Atom)




