May 28, 2014

Calculate coefficient alpha by country

use "ZA5900_v1-0-0.dta", replace

renvars, lower // Switch variable names to lower case

kountry v4, from(iso3n) to(iso2c)  // Generate country abbreviation variable
encode _ISO2C_, gen(country)

fre v51-v54 // Work-family conflict items

// Factor analysis yields one-dimensional solution:
factor v51-v54, pcf


// Calculate Cronbach's alpha for each country of the sample:

preserve

statsby alpha_ = r(alpha) ///
      , by(country) clear total: /// -total- adds row for total sample
    alpha v51-v54

replace country = 25 if country == .  // Label row for total sample
label define country 25 "All", modify // Label row for total sample    
    
sort alpha_         // Make list 
list, sep(0)

  // Create graph
egen order_ = rank(-alpha_), unique
labmask order_, value(country) decode

twoway (dot alpha_ order_) ///
       , yline(.70) ///
      xlab(1/25, valuelabels ang(v)) xtitle("Country") ///
   ylabel(, format(%6.2f)) ytitle("Cronbach's alpha of work{c 150}family conflict scale") ///
   note("{it: Note:} Horizontal line denotes conventional cut-off value for Cronbach's alpha", span)

restore