clear all ***open dataset (codebook = see LIS template) use $mydata/prosoc/tmpabg su * ***select countries local coco " de dk it us " gen sselect = . foreach cntry in `coco' { replace sselect = 1 if iso2== "`cntry'" } keep if sselect ==1 ***from mid-1980s to todays keep if year>=1984 bysort iso2: egen miny=min(year) bysort iso2: egen maxy=max(year) keep if year == miny | year == maxy ***Work on the base of 1 individual per household for mid-aged population keep if relation ==1000 gen wgt=int(hpopwgt *nhhmem )+1 keep if age >=25 & age <=54 ***Kill negative incomes ... keep if dhi>=0 & dhi!=. ***suppress french colonies (ok, it is more complicated...) keep if iso2 !="fr" | year != 2010 | region_c<9 ***I like ccyyyy variable gen ccyyyy=iso2 + string(year) ***equivalized dhi hifactor and taxandtransfers (see lis definitions) gen eqdhi=((dhi)/sqrt(nhhmem )) gen eqhifactor=((hifactor)/sqrt(nhhmem )) gen eqtaxtrans=((dhi-hifactor)/sqrt(nhhmem )) ***will store result in a matrix mat U = J(1,13,.) levelsof ccyyyy, local(fifi) di `fifi' local i=0 foreach toto in `fifi' { local ii = `ii' + 1 qui { isograph eqhifactor [fw=wgt] if ccyyyy== "`toto'" mat B=r(isograph) mat C=B[1..13,2..2] mat D = C' mat li D matrix rownames D = "`toto' 1" mat U = U \ D isograph eqdhi [fw=wgt] if ccyyyy== "`toto'" mat B=r(isograph) mat C=B[1..13,2..2] mat D = C' matrix rownames D = "`toto' 2" mat U = U \ D fastgini eqhifactor [fw=wgt] if ccyyyy== "`toto'" scalar fg1=r(gini) fastgini eqdhi [fw=wgt] if ccyyyy== "`toto'" scalar fg2=r(gini) su eqhifactor [fw=wgt] if ccyyyy== "`toto'" ,d gen tmp1=eqhifactor / r(p50) if ccyyyy== "`toto'" gen tmpa=tmp1<.5 if ccyyyy== "`toto'" su tmpa [fw=wgt] if ccyyyy== "`toto'" scalar ftg1=r(mean) su eqdhi [fw=wgt] if ccyyyy== "`toto'" ,d gen tmp2=eqdhi / r(p50) if ccyyyy== "`toto'" gen tmpb=tmp2<.5 if ccyyyy== "`toto'" su tmpb [fw=wgt] if ccyyyy== "`toto'" scalar ftg2=r(mean) noi di `ii' " `toto' " " " fg1 " " fg2 " " ftg1 " " ftg2 drop tmp* } } scalar mr = rowsof(U) scalar mc = colsof(U) matrix iso=U[2..mr,1..mc] noi mat li iso