set more off clear all cls // Directory setup gl maindir "/Users/mauriciotorresferro/Dropbox/RAs/Global_Income_Dynamics_ALL" /*------------------------------------------------------------------------------ - Paste the names of the subfolders where the main data files and moments are stored. - The various subfolders containing the data files are in $maindir/data. - For example, all data related to inequality can be found in $maindir/data/Inequality. ------------------------------------------------------------------------------*/ // Where the Volatility data is stored (do not modify) gl voladata = "Volatility_data" // Where the figures are stored ("Figures") (do not modify) gl outfolder = "Figures" gl folderfile = "$maindir/${outfolder}" // Years, from 1983 to 2016 gl yrfirst = 1983 // First year in the dataset gl yrlast = 2016 // Last year in the dataset // Recession years in Canada gl receyears = "1986,1989,1990,1991,2001,2003,2008,2009,2015,2016" // Some common charactristics of the plots gl xtitlesize = "medium" gl ytitlesize = "medium" gl xlabsize = "medium" gl ylabsize = "medium" gl titlesize = "large" gl subtitlesize = "medium" gl formatfile = "pdf" gl fontface = "Times New Roman" gl marksize = "medium" gl legesize = "medium" *=============================================================================== /* *=======================* * 3. Volatility Figures * *=======================* /* ---------------------------------------------------------- fig5B_coef This file produces figures for the evolution of moment-based coefficient of excess kurtosis of annual (researn1F) and five-year (researn5F) growth in log earnings residuals. ------------------------------------------------------------- */ VARIABLE LIST: - researn1F - researn5F */ * CHOOSE WHICH VARIABLES YOU WANT TO PLOT: researn1F researn5F local earn_meas_list = "researn1F researn5F" * CHOOSE THE COLORS FOR WOMEN and MEN: blue green red navy blue maroon forest_green purple gray orange local colors = "red blue" * CHOOSE THE SYMBOLS: O + S x D o local labsym = "O S" * CHOOSE IF THE LEGEND IS ACTIVE OR NOT: on off local lgactive = "on" * CHOOSE THE POSITION AND LEGEND FORMAT local cols = "1" // Number of columns local posi = "11" // Position (1:Top-right; 5:Bottom-right; 7:Bottom-left; 11:Top-left) * CHOOSE IF THE LIMITS FOR THE Y-AXIS ARE FIXED: yes no local ylimsfix = "no" * COMBINE ALL FIGURES INTO A SINGLE PDF: no yes local combinepdf = "no" local figname = "" // (do not modify) *=============================================================================== foreach var of local earn_meas_list{ graph set window fontface "${fontface}" global vari = "`var'" * Read data insheet using "$maindir/data/${voladata}/L_${vari}_male_sumstat.csv", case clear replace kurt${vari} = kurt${vari} - 3 //Excess keep year male kurt${vari} reshape wide kurt${vari}, i(year) j(male) *Define which variables are plotted local varilist = "kurt${vari}0 kurt${vari}1" *Defime the time variable local timevar = "year" if "${vari}" == "researn1F"{ *What are the x-axis limits local lyear = ${yrfirst} local ryear = ${yrlast} *Define labels local labtitle = "{&Delta}{sup:1}{&epsilon}{sub:it}" *limits of y-axis if "`ylimsfix'" == "no"{ local ylimlo = "" local ylimup = "" local ylimdf = "" } if "`ylimsfix'" == "yes"{ local ylimlo = 7 local ylimup = 13.2 local ylimdf = 1 } } if "${vari}" == "researn5F"{ *What are the x-axis limits local lyear = ${yrfirst} + 3 local ryear = ${yrlast} - 2 replace year = year + 3 *Define labels local labtitle = "{&Delta}{sup:5}{&epsilon}{sub:it}" * limits of y-axis if "`ylimsfix'" == "no"{ local ylimlo = "" local ylimup = "" local ylimdf = "" } if "`ylimsfix'" == "yes"{ local ylimlo = 3.5 local ylimup = 8.5 local ylimdf = 1 } } *Define Title, Subtitle, and axis labels local xtitle = "" local ytitle = "Coef. of Excess Kurtosis of `labtitle'" local title = "Coefficient of Excess Kurtosis of `labtitle'" local subtitle = "" *Define name and output file local namefile = "fig5B_${vari}_coef" *Limits of x-axis local xmin = `lyear' local xmax = `ryear' local xdis = 3 *Define labels local lab1 = "Women" local lab2 = "Men" local lab3 = "" local lab4 = "" local lab5 = "" local lab6 = "" local lab7 = "" local lab8 = "" local lab9 = "" *Limits of y-axis local ymin = "`ylimlo'" local ymax = "`ylimup'" local ydis = "`ylimdf'" if "`ymin'" == ""{ local ylbls = "" } else{ local ylbls = "`ymin'(`ydis')`ymax'" } *Define the color scheme local cframe = "" local mcframe = "" foreach co of local colors{ local cframe = "`cframe'"+" "+"`co'" local mcframe = "`mcframe'"+" "+"`co'*0.25" } *Some global defined local xtitlesize = "${xtitlesize}" // Size of xtitle font local ytitlesize = "${ytitlesize}" // Size of ytitle font local xlabsize = "${xlabsize}" local ylabsize = "${ylabsize}" local titlesize = "${titlesize}" // Size of title font local subtitlesize = "${subtitlesize}" // Size of subtiotle font local formatfile = "${formatfile}" // format of saved file local folderfile = "${folderfile}" // folder where the plot is saved local marksize = "${marksize}" // Marker size local legesize = "${legesize}" // Marker size *What are the recession years gen rece = inlist(year,${receyears}) tsset year *Plot if "`combinepdf'" == "no"{ tw (bar rece year if `timevar' >= `xmin' & `timevar' <= `xmax', ylabel(,nogrid axis(1)) c(l) color(gray*0.5) yscale(off)) /// (connected `varilist' `timevar' if `timevar' >= `xmin' & `timevar' <= `xmax', /// Plot lcolor(`cframe') /// Line color lpattern(solid longdash dash dash_dot solid longdash dash dash_dot solid longdash dash dash_dot) /// Line pattern msymbol(`labsym') /// Marker msize("`marksize'" "`marksize'" "`marksize'" "`marksize'" "`marksize'" "`marksize'" "`marksize'" "`marksize'" "`marksize'" ) /// Marker size mfcolor(`mcframe') /// Fill color mlcolor(`cframe') /// Marker line color yaxis(2) yscale(alt axis(2)) ytitle(`ytitle', axis(2) size(`ytitlesize')) ylabel(`ylbls', labsize(`ylabsize') grid axis(2))) /// , /// yaxis optins xtitle("") xtitle(`xtitle',size(`xtitlesize')) xlabel(`xmin'(`xdis')`xmax',grid labsize(`xlabsize')) /// xaxis options legend(`lgactive' size(`legesize') col(`cols') symxsize(7.0) ring(0) position(`posi') /// order(2 "`lab1'" 3 "`lab2'" 4 "`lab3'" 5 "`lab4'" 6 "`lab5'" 7 "`lab6'" 8 "`lab7'" 9 "`lab8'" 10 "`lab9'") /// region(color(none) lcolor(white))) graphregion(color(white)) /// Legend options graphregion(color(white) ) /// Graph region define plotregion(lcolor(black)) /// Plot regione define title(`title', color(black) size(`titlesize')) subtitle(`subtitle', color(black) size(`subtitlesize')) // Title and subtitle cap noisily: graph export `folderfile'/`namefile'.`formatfile', replace } if "`combinepdf'" == "yes"{ tw (bar rece year if `timevar' >= `xmin' & `timevar' <= `xmax', ylabel(,nogrid axis(1)) c(l) color(gray*0.5) yscale(off)) /// (connected `varilist' `timevar' if `timevar' >= `xmin' & `timevar' <= `xmax', /// Plot lcolor(`cframe') /// Line color lpattern(solid longdash dash dash_dot solid longdash dash dash_dot solid longdash dash dash_dot) /// Line pattern msymbol(`labsym') /// Marker msize("`marksize'" "`marksize'" "`marksize'" "`marksize'" "`marksize'" "`marksize'" "`marksize'" "`marksize'" "`marksize'" ) /// Marker size mfcolor(`mcframe') /// Fill color mlcolor(`cframe') /// Marker line color yaxis(2) yscale(alt axis(2)) ytitle(`ytitle', axis(2) size(`ytitlesize')) ylabel(`ylbls', labsize(`ylabsize') grid axis(2))) /// , /// yaxis optins xtitle("") xtitle(`xtitle',size(`xtitlesize')) xlabel(`xmin'(`xdis')`xmax',grid labsize(`xlabsize')) /// xaxis options legend(`lgactive' size(`legesize') col(`cols') symxsize(7.0) ring(0) position(`posi') /// order(2 "`lab1'" 3 "`lab2'" 4 "`lab3'" 5 "`lab4'" 6 "`lab5'" 7 "`lab6'" 8 "`lab7'" 9 "`lab8'" 10 "`lab9'") /// region(color(none) lcolor(white))) graphregion(color(white)) /// Legend options graphregion(color(white) ) /// Graph region define plotregion(lcolor(black)) /// Plot regione define title(`title', color(black) size(`titlesize')) subtitle(`subtitle', color(black) size(`subtitlesize')) // Title and subtitle cap noisily: graph export `folderfile'/`namefile'.png, replace } local figname = "`figname'" + " " + "`namefile'" } if "`combinepdf'" == "yes" { putpdf begin, land margin(all, 0cm) foreach fig of local figname { putpdf paragraph, halign(center) putpdf image `folderfile'/`fig'.png putpdf pagebreak erase `folderfile'/`fig'.png } putpdf save `folderfile'/fig5B_coef.pdf, replace nomsg }