/*******************************************/ /* Example for Meta-regression model (MRM) */ /*******************************************/ #delimit ; set mem 30m; set matsize 80; set logtype text; set more off; log using c:\klaus\apec64\spring_07\stata\logs\meta_regression,replace; use c:\klaus\apec64\spring_07\stata\data\metadata_example; /* inspect data */ /******************/ sum;/* general overview of data */ tab study_id; /* check how many observations per study */ /* to get a total count of studies: */ sort study_id; egen study_runid=group(study_id); /* how many have valid entries for catch? */ tab catch; egen study_runid_catch=group(study_id) if catch<999; sum study_runid_catch; /*OV bias tests */ /*****************/ gen ln_catch=log(catch) if catch<999; gen ln_cs=log(cs_day); /* check for sample correlation*/ corr ln_catch river salmon boat spec_reg mountain substit sam100 dc oe_bid if catch<999 ; /* regress catch against other explanatory variables */ regress ln_catch river salmon boat spec_reg mountain substit sam100 dc oe_bid if catch<999; /* do a hausman test*/ regress ln_cs river salmon boat spec_reg mountain substit sam100 dc oe_bid if catch<999; estimates store no_catch; regress ln_cs ln_catch river salmon boat spec_reg mountain substit sam100 dc oe_bid if catch<999; hausman . no_catch; /* no evidence of OV problems if catch is omitted */ /* MRM version 1, with catch rate omitted, full sample */ /******************************************************/ regress ln_cs river salmon boat spec_reg mountain substit sam100 dc oe_bid; imtest; /* doesn't look like HSK is a problem*/ scalar sig=e(rmse);/* capture regression error */ nlcom exp(_b[_cons]+_b[river]*1+_b[spec_reg]*1+_b[substit]*0.5+_b[sam100]*0.5+_b[oe_bid]*0.5+_b[dc]*0.5+_b[sam100]*0.5+0.5*sig^2); /* MRM version 2, with catch, reduced sample */ /******************************************************/ regress ln_cs ln_catch river salmon boat spec_reg mountain substit sam100 dc oe_bid if catch<999; /* don't forget if-condition!*/ imtest; /* doesn't look like HSK is a problem*/ scalar sig=e(rmse);/* capture regression error */ nlcom exp(_b[_cons]+_b[ln_catch]*log(3.4)+_b[river]*1+_b[spec_reg]*1+_b[substit]*0.5+_b[sam100]*0.5+_b[oe_bid]*0.5+_b[dc]*0.5+_b[sam100]*0.5+0.5*sig^2); /************************************/ /* methodological effects */ /***********************************/ /* Hausman test*/ regress ln_cs river salmon boat spec_reg mountain; estimates store no_method; regress ln_cs river salmon boat spec_reg mountain substit sam100 dc oe_bid; estimates store method; hausman method no_method; regress ln_cs river salmon boat spec_reg mountain; scalar sig=e(rmse);/* capture regression error */ nlcom exp(_b[_cons]+_b[river]*1+_b[spec_reg]*1+0.5*sig^2); log close;