Mar 24, 2016

Random graphs (66): Dot plots with confidence intervals

clear
input str50 variable str4 data icc lb ub
"Overall" DE .46 .40 .53
"Overall" SE .49 .49 .50
"Overall" PSID .57 .55 .6
"Low father education" DE .42 .34 .5
"Low father education" SE .44 .43 .45
"Low father education" PSID .42 .31 .53
"High father education" DE .4 .29 .53
"High father education" SE .47 .46 .47
"High father education" PSID .58 .55 .62
"Low mother education" DE .45 .38 .53
"Low mother education" SE .45 .44 .46
"Low mother education" PSID .56 .53 .59
"High mother education" DE .33 .21  .48
"High mother education" SE .45 .44 .46
"High mother education" PSID .56 .53 .59 
"Low parental occupation" DE .51 .43 .60
"Low parental occupation" SE .43 .42 .44
"Low parental occupation" PSID .59 .51 .67
"High parental occupation" DE .30 .21 .41
"High parental occupation" SE .39 .37 .40
"High parental occupation" PSID .54 .51 .57
"No migrant background" DE .40 .33 .49 
"No migrant background" SE .48 .48 .49
"No migrant background" PSID .57 .53 .61
"Migrant background" DE .48 .35 .61
"Migrant background" SE .54 .52 .55
"Migrant background" PSID .56 .44 .68
"Family size 2-3 children" DE .48 .41 .54
"Family size 2-3 children" SE .48 .47 .48
"Family size 2-3 children" PSID . . .
"Family size 4 and more children" DE .31 .12 .61
"Family size 4 and more children" SE .55 .54 .56
"Family size 4 and more children" PSID . . .
end

generate indicator =  1 if variable == "Overall"                  & data == "DE"
replace  indicator =  2 if variable == "Overall"                  & data == "SE"
replace  indicator =  3 if variable == "Overall"                  & data == "PSID"
replace  indicator =  4 if variable == "Low father education"     & data == "DE"
replace  indicator =  5 if variable == "Low father education"     & data == "SE"
replace  indicator =  6 if variable == "Low father education"     & data == "PSID"
replace  indicator =  7 if variable == "High father education"    & data == "DE"
replace  indicator =  8 if variable == "High father education"    & data == "SE"
replace  indicator =  9 if variable == "High father education"    & data == "PSID"
replace  indicator = 10 if variable == "Low mother education"     & data == "DE"
replace  indicator = 11 if variable == "Low mother education"     & data == "SE"
replace  indicator = 12 if variable == "Low mother education"     & data == "PSID"
replace  indicator = 13 if variable == "High mother education"    & data == "DE"
replace  indicator = 14 if variable == "High mother education"    & data == "SE"
replace  indicator = 15 if variable == "High mother education"    & data == "PSID"
replace  indicator = 16 if variable == "Low parental occupation"  & data == "DE"
replace  indicator = 17 if variable == "Low parental occupation"  & data == "SE"
replace  indicator = 18 if variable == "Low parental occupation"  & data == "PSID"
replace  indicator = 19 if variable == "High parental occupation" & data == "DE"
replace  indicator = 20 if variable == "High parental occupation" & data == "SE"
replace  indicator = 21 if variable == "High parental occupation" & data == "PSID"
replace  indicator = 22 if variable == "No migrant background" & data == "DE"
replace  indicator = 23 if variable == "No migrant background" & data == "SE"
replace  indicator = 24 if variable == "No migrant background" & data == "PSID"
replace  indicator = 25 if variable == "Migrant background" & data == "DE"
replace  indicator = 26 if variable == "Migrant background" & data == "SE"
replace  indicator = 27 if variable == "Migrant background" & data == "PSID"
replace  indicator = 28 if variable == "Family size 2-3 children" & data == "DE"
replace  indicator = 29 if variable == "Family size 2-3 children" & data == "SE"
replace  indicator = 30 if variable == "Family size 2-3 children" & data == "PSID"
replace  indicator = 31 if variable == "Family size 4 and more children" & data == "DE"
replace  indicator = 32 if variable == "Family size 4 and more children" & data == "SE"
replace  indicator = 33 if variable == "Family size 4 and more children" & data == "PSID"

label define indicator 1 "Overall" ///
                       4 "Low father education" ///
                       7 "High father education" ///
                      10 "Low mother education" ///
                      13 "High mother education" ///
                      16 "Low parental occupation" ///
                      19 "High parental occupation" ///
                      22 "No migrant background" ///
                      25 "Migrant background" ///
                      28 "Family size 2-3 children" ///
                      31 "Family size 4 and more children"
label val indicator indicator
  
twoway (dot icc indicator if data == "DE", horizontal msymbol(o)) ///
       (rspike ub lb indicator if data == "DE", horizontal) ///
       (dot icc indicator if data == "SE", horizontal msymbol(t)) ///
       (rspike ub lb indicator if data == "SE", horizontal) ///
       (dot icc indicator if data == "PSID", horizontal msymbol(s)) ///
       (rspike ub lb indicator if data == "PSID", horizontal) ///
      , legend(order(1 "Germany" 3 "Sweden" 5 "United States (PSID)") pos(2)) ///
        yscale(reverse) ylabel(1 (3) 31, val) ///
        xscale(alt) ytitle("") xtitle("Sibling correlations in cognitive skills") ///
        note("{it:Note:} Germany: {it:N} = 1,989 individuals in 1,431 families" ///
             "Sweden: {it:N} = 652,940 individuals in 536,224 families" ///
             "United States: {it:N} = 2,868 individuals in 1,968 families" , span)