/*STATA PROGRAM FOR CHOICE EXPERIMENT EXAMPLE */ #delimit ; set mem 30m; set matsize 800; set more off; set logtype text; log using c:\Klaus\apec64\spring_07\stata\logs\ce_example, replace; /* add baseline categories */ /*use c:\klaus\apec64\spring_07\stata\data\maine_forest; gen dead0=0; recode dead0 0=1 if dead10==0 & dead5==0; label var dead0 "1=no dead trees left after harvest"; gen live0=0; recode live0 0=1 if live153==0 & live459==0; label var live0 "1=no live trees left after harvest"; gen hopen5=0; recode hopen5 0=1 if hopen35==0 & hopen125==0; label var hopen5 "1=max size of harvest openings < 35 acres"; gen perh20=0; recode perh20 0=1 if perh80==0 & perh50==0; label var perh20 "1=20% of forest or less protected"; gen lvslash=0; recode lvslash 0=1 if remslash==0 & dstslash==0; label var lvslash "1=leave slash in place or piles"; save c:\klaus\apec64\spring_07\stata\data\ce_example;*/ use c:\klaus\apec64\spring_07\stata\data\ce_example; /*********************************************************************/ /* Run model with baseline categories = least environmentally friendly harvesting */ /********************************************************************/ clogit choice dead5 dead10 live153 live459 hopen35 hopen5 perh50 perh20 dstslash lvslash tax, group(id); nlcom -(_b[dead5]/_b[tax]); nlcom -(_b[dead10]/_b[tax]); nlcom -(_b[live153]/_b[tax]); nlcom -(_b[live459]/_b[tax]); nlcom -(_b[hopen35]/_b[tax]); nlcom -(_b[hopen5]/_b[tax]); nlcom -(_b[perh50]/_b[tax]); nlcom -(_b[perh20]/_b[tax]); nlcom -(_b[dstslash]/_b[tax]); nlcom -(_b[lvslash]/_b[tax]); /* Marginal Effects */ /********************/ predict phat; /* test if add to one*/ sort runid; egen p_sum=sum(phat), by(id); tab p_sum; /* hit rates */ egen hit=max(phat), by (id); recode hit *=1 if hit==phat; recode hit *=0 if hit<1; label var hit "predicted choice"; tab choice hit; /* marginal own-effects */ gen p_term=phat*(1-phat); gen m_dead5=p_term*_b[dead5]; gen m_dead10=p_term*_b[dead10]; gen m_live153=p_term*_b[live153]; gen m_live459=p_term*_b[live459]; sum m_*; /*********************************************************************/ /* Run model with baseline categories = most environmentally friendly harvesting */ /********************************************************************/ clogit choice dead5 dead0 live153 live0 hopen35 hopen125 perh50 perh80 dstslash remslash tax, group(id); nlcom -(_b[dead5]/_b[tax]); nlcom -(_b[dead0]/_b[tax]); nlcom -(_b[live153]/_b[tax]); nlcom -(_b[live0]/_b[tax]); nlcom -(_b[hopen35]/_b[tax]); nlcom -(_b[hopen125]/_b[tax]); nlcom -(_b[perh50]/_b[tax]); nlcom -(_b[perh80]/_b[tax]); nlcom -(_b[dstslash]/_b[tax]); nlcom -(_b[remslash]/_b[tax]); log close;