* DISCLAIMER: The following code is provided as is and should be used at your own risk. * No user support is available. * Andrew Jones, November 2006 * This program relates to the material described in Chapter 2 of the book * Jones, A.M., Rice, N., Bago d'Uva, T. & Balia, S. (2007) * "Applied Health Economics", London: Routledge {ISBN: 9780415397728} * PRELIMINARIES clear set trace off set more off set mem 120m use "bhps.dta" , clear capture log close log using "BHPS-Ex1.log", replace describe summ * SET INDIVIDUAL (i) AND TIME (t) INDEXES iis pid tis wavenum sort pid wavenum *DEFINE GLOBAL FOR VARIABLE LISTS #delimit ; global xvars " widowed nvrmar divsep deghdeg hndalev ocse hhsize nch04 nch511 nch1218 age age2 age3 age4 yr9293 yr9394 yr9495 yr9596 yr9697 yr9798 lninc mlninc mwid mnvrmar mdivsep mhhsize mnch04 mnch511 mnch1218"; #delimit cr; /* BINARY MEASURES OF HEALTH PROBLEMS */ * HLPRB - NO HEALTH PROBLEM from a list of disabilities gen hlp=0 replace hlp=1 if hlprb==. * hllt - "does your health in any way limit your daily activities * compared to most people of your age?": 1=yes 2=no -9=missing recode hllt 2=0 recode hllt -9=0 ***generation of income variables ***equivalise income*** *quietly by pid: gen increeq=fihhyr2/fieqfca ***generate lagged income varable**** *quietly by pid: gen inclag=increeq[_n-1] ***generate mean equivalised real income variable *sort pid wavenum egen meaninc=mean(increeq),by(pid) summ meaninc ***generate lagged self-assessed health variable sort pid wavenum quietly by pid: gen hstatlag=hlstat[_n-1] /* THE FOLLOWING COMMANDS CREATE INDICATORS OF WHETHER OBSERVATIONS ARE IN THE BALANCED AND UNBALANCED ESTIMATION SAMPLES */ quietly oprobit hlstat widowed nvrmar divsep deghdeg hndalev ocse /// hhsize nch04 nch511 nch1218 age age2 age3 age4 yr9293 yr9394 yr9495 yr9596 yr9697 /// yr9798 lninc mlninc mwid mnvrmar mdivsep mhhsize mnch04 mnch511 mnch1218 /// , table cluster(pid) gen insampm = 0 recode insampm 0 = 1 if e(sample) sort pid wavenum gen constant = 1 by pid: egen Ti = sum(constant) if insampm == 1 drop constant sort pid wavenum by pid: gen nextwavem = insampm[_n+1] gen allwavesm = . recode allwavesm . = 0 if Ti ~= 8 recode allwavesm . = 1 if Ti == 8 gen numwavesm = . replace numwavesm = Ti summ Ti nextwavem allwavesm numwavesm /* TABLES & FIGURES FROM Contoyannis Jones & Rice (JAE, 2004) */ /* GRAPHICS-Males */ **hlstat hist*** ***change variable labels!!!*** label variable sahex "hlstat=excellent" label variable sahgood "hlstat=good" label variable sahfair "hlstat=fair" label variable sahpoor "hlstat=poor" label variable sahvpoor "hlstat=very poor" /* FIGURE 1 */ set textsize 75 graph bar sahex sahgood sahfair sahpoor sahvpoor if male==1, title("bar chart for SAH, men") ylabel(0 0.1 0.2 0.3 0.4 0.5) graph export "fig1.eps", as(eps) preview(on) replace sort wavenum graph bar sahex sahgood sahfair sahpoor sahvpoor if male==1, over(wavenum) title("Bar chart for SAH by wave, men") /// ylabel(0 0.1 0.2 0.3 0.4 0.5) /* FIGURE 2 */ ****obtain age groups for plots of self-assessed health*** gen healtab=1 replace healtab =2 if age<36 & age>27 replace healtab =3 if age<44 & age>35 replace healtab =4 if age<52 & age>43 replace healtab =5 if age<60 & age>51 replace healtab =6 if age<68 & age>59 replace healtab =7 if age<76 & age>67 replace healtab =8 if age<84 & age>75 replace healtab =9 if age>83 tab healtab sort healtab graph bar sahex sahgood sahfair sahpoor sahvpoor if male==1 & wavenum==1, over(healtab) /// title("Bar chart for SAH by age group, wave1, men") ylabel(0 0.1 0.2 0.3 0.4 0.5 0.6) /* FIGURE 3 */ *create categorical variable corresponding to income percentiles*** sort pid wavenum xtile incquim=meaninc if male==1,nquantiles(5) summ incquim graph bar sahex sahgood sahfair sahpoor sahvpoor if male==1, over(incquim) /// ti("Bar chart for SAH by quintile of meaninc, men") ylabel(0 0.1 0.2 0.3 0.4 0.5) /* FIGURE 4 */ *obtain categorical variable for educational attainment*** sort pid wavenum gen edatt=1 replace edatt = 2 if ocse==1 replace edatt = 3 if hndalev==1 replace edatt = 4 if deghdeg==1 tab edatt sort edatt graph bar sahex sahgood sahfair sahpoor sahvpoor if male==1, over(edatt) /// ti("Bar chart for SAH by education, men") ylabel(0 0.1 0.2 0.3 0.4 0.5) /* FIGURE 5 */ ****histograms for current health given previous health sort hstatlag graph bar sahex sahgood sahfair sahpoor sahvpoor if male==1 & wavenum==2, over(hstatlag) /// ti("Bar chart for SAH by previous SAH, wave 2, men") ylabel(0 0.1 0.2 0.3 0.4 0.5 0.6) /* PLATE 1 */ ***empirical distribution functions **to obtain all groups on single graph**** cumul meaninc if male==1 & sahex==1,gen(cummalex) cumul meaninc if male==1 & sahgood==1,gen(cummalgd) cumul meaninc if male==1 & sahfair==1,gen(cummalfa) cumul meaninc if male==1 & sahpoor==1,gen(cummalpo) cumul meaninc if male==1 & sahvpoor==1,gen(cummalvp) graph twoway scatter cummalex cummalgd cummalfa cummalpo cummalvp meaninc, /// s(odp.T) ylab(0(.25)1) ti("Empirical CDF's of meaninc, men") /* TABLE II */ xttrans hlstat if male==1,i(pid) t(wavenum) freq xttrans hlstat if male==0,i(pid) t(wavenum) freq ********Descriptives and construction of hypotheticals-Males******* /* CJR TABLE III */ * ALL AVAILABLE DATA summ $xvars *summ $xvars if male==1 *summ $xvars if male==0 * UNBALANCED ESTIMATION SAMPLE summ $xvars if insampm==1 * BALANCED ESTIMATION SAMPLE summ $xvars if allwavesm==1 /* CJR TABLE IV */ tab hlstat if male==1 gen count1=1 replace count1 =10 if wavenum==2 replace count1 =100 if wavenum==3 replace count1 =1000 if wavenum==4 replace count1 =10000 if wavenum==5 replace count1 =100000 if wavenum==6 replace count1 =1000000 if wavenum==7 replace count1 =10000000 if wavenum==8 ****always excellent/good in eight years- gen hexgood=sahex==1|sahgood==1 gen use=hexgood*count1 sort pid egen tot=sum(use), by(pid) egen hsumi=sum(tot), by(pid) summ $xvars if (tot==11111111 & male==1) drop use tot hsumi ****always poor/very poor in eight years- gen hpovpo=sahpoor==1|sahvpoor==1 gen use=hpovpo*count1 sort pid egen tot=sum(use), by(pid) egen hsumi=sum(tot), by(pid) summ $xvars if (tot==11111111 & male==1) drop use tot hsumi ****single transition from excellent/good in eight years- gen use=hexgood*count1 sort pid egen tot=sum(use), by(pid) egen hsumi=sum(tot), by(pid) summ $xvars if (tot==1|tot==11|tot==111|tot==1111|tot==11111|tot==111111|tot==1111111) & male==1 tab hsumi if (tot==1|tot==11|tot==111|tot==1111|tot==11111|tot==111111|tot==1111111) & male==1 drop use tot hsumi ****single transition from poor/vpoor in eight years- gen use=hpovpo*count1 sort pid egen tot=sum(use), by(pid) egen hsumi=sum(tot), by(pid) summ $xvars if (tot==1|tot==11|tot==111|tot==1111|tot==11111|tot==111111|tot==1111111) & male==1 tab hsumi if (tot==1|tot==11|tot==111|tot==1111|tot==11111|tot==111111|tot==1111111) & male==1 drop use tot hsumi