From fe75c4d348430bdd00d60471b9395ceaa61d73a4 Mon Sep 17 00:00:00 2001 From: Ben Anderson <b.anderson@soton.ac.uk> Date: Fri, 6 Mar 2015 17:35:55 +0000 Subject: [PATCH] added linearity tests to all households model --- NEED/analyse-NEED-EULF-2014-models-v2.0.do | 31 ++++++++++++++++------ 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/NEED/analyse-NEED-EULF-2014-models-v2.0.do b/NEED/analyse-NEED-EULF-2014-models-v2.0.do index 164c377..8b9ba19 100644 --- a/NEED/analyse-NEED-EULF-2014-models-v2.0.do +++ b/NEED/analyse-NEED-EULF-2014-models-v2.0.do @@ -54,15 +54,15 @@ local rpath "`proot'/results/NEED" * restricted analysis to households where gas is main heat source as it is better predicted by variables included & is more relevant to EPC (heat) * uses 1% sample (c 30k) making sure keep proportions of property type and EE_Band to see if linktest fails with smaller n -*local version "v2_10pc" -*local sample 10 -*local sampleby "EE_BAND PROP_TYPE" +local version "v2_10pc" +local sample 10 +local sampleby "EE_BAND PROP_TYPE" * uses 10% sample (c 300k) making sure keep proportions of property type and EE_Band to see if margin plots and co-efficients are the same * (linktest etc will probably now fail due to larger n) -local version "v2_100pc" -local sample 100 -local sampleby "EE_BAND PROP_TYPE" +*local version "v2_100pc" +*local sample 100 +*local sampleby "EE_BAND PROP_TYPE" * uses full sample (c 3m) to see if margin plots and co-efficients are the same * (linktest etc will probably now fail due to larger n) @@ -145,7 +145,11 @@ destring BOILER, force replace replace BOILER = 0 if BOILER == . * household level vars +* for models local generic_hvars "i.BOILER_YEAR i.MAIN_HEAT_FUEL i.LI_YEAR i.LOFT_DEPTH i.FLOOR_AREA_BAND WALL_CONS i.CWI_YEAR i.PROP_TYPE i.PROP_AGE i.EE_BAND" +* for graphs +local generic_hvarsg "BOILER_YEAR MAIN_HEAT_FUEL LI_YEAR LOFT_DEPTH FLOOR_AREA_BAND WALL_CONS CWI_YEAR PROP_TYPE PROP_AGE EE_BAND" +* for models by type local generic_hvarsnp "i.BOILER_YEAR i.MAIN_HEAT_FUEL i.LI_YEAR i.LOFT_DEPTH i.FLOOR_AREA_BAND WALL_CONS i.CWI_YEAR i.PROP_AGE i.EE_BAND" * area level vars @@ -177,6 +181,17 @@ foreach v of local vars { i.BOILER_YEAR est store `v' + * test a variable + predict r, resid + foreach testv of local generic_hvarsg { + di "Testing residuals against `v'" + * based on http://www.ats.ucla.edu/stat/stata/webbooks/reg/chapter2/statareg2.htm + * can't use factor variables in acprplot... + graph box r, over(`testv') name(rtest_`testv') + graph export "`rpath'/graphs/rplot_`v'_`testv'-`version'.png", replace + } + + di "* -> `v' estat to test for heteroskedasticity & omitted vars" estat ovtest estat hettest @@ -189,7 +204,7 @@ foreach v of local vars { di "* test EPC margins for `v'" margins EE_BAND - marginsplot, name(mplot_`v'_EE_BAND) + marginsplot, name(mplot_`v'_EE_BAND) note("All dwellings") graph export "`rpath'/graphs/mplot_`v'_EE_BAND-`version'.png", replace * models by property type - to see if rsq & coefficients vary @@ -212,7 +227,7 @@ foreach v of local vars { linktest di "* test EPC margins for `v' (`pt`p'')" margins EE_BAND - marginsplot, name(mplot_`v'_EE_BAND_`pt`p'') + marginsplot, name(mplot_`v'_EE_BAND_`pt`p'') note("Type: `pt`p''") graph export "`rpath'/graphs/mplot_`v'_EE_BAND_`pt`p''-`version'.png", replace } -- GitLab