From fa061d69a3fda6cee9c392102959fe72db569fc1 Mon Sep 17 00:00:00 2001
From: Ben Anderson <b.anderson@soton.ac.uk>
Date: Fri, 10 Oct 2014 17:33:42 +0100
Subject: [PATCH] loops over subsamples of long form file

---
 NEED/analyse-NEED-EULF-2014-descriptives.do | 42 ++++++++++++---------
 1 file changed, 24 insertions(+), 18 deletions(-)

diff --git a/NEED/analyse-NEED-EULF-2014-descriptives.do b/NEED/analyse-NEED-EULF-2014-descriptives.do
index 0aa7a3c..0c0a786 100644
--- a/NEED/analyse-NEED-EULF-2014-descriptives.do
+++ b/NEED/analyse-NEED-EULF-2014-descriptives.do
@@ -27,8 +27,8 @@ local rpath "`proot'/results/NEED"
 
 local version "v1.1"
 
-local do_2014_desc 1 /// quick tests for 2014
-local do_long_dec 0 /// tests for all years using long file - takes a while
+local do_2014_desc 0 /// quick tests for 2014
+local do_long_dec 1 /// tests for all years using long file - takes a while
 
 set more off
 
@@ -55,27 +55,33 @@ if `do_2014_desc' {
 
 if `do_long_desc' {
 	* Now use the pre-processed long form file which contains all years of consumption data but not the constant values (housing charactersitics etc) which are in the xwave file
-	use "`dpath'/need_eul_may2014_longfile.dta", clear
+	* do this for each random sample of differening sizes as a check
+	local samples "10 20 130 40 50 100"
+	foreach s of local samples {
+		di "************************"
+		di "* Using `s'% sample"
+		use "`dpath'/need_eul_may2014_longfile_`s'pc.dta", clear
 	
-	* set as panel
-	xtset HH_ID year, delta(1 year)
+		* set as panel
+		xtset HH_ID year, delta(1 year)
 
-	xtdescribe 
+		xtdescribe 
 	
-	xtsum Econs Gcons
+		xtsum Econs Gcons
 	
-	* summarise Electricity
-	table EconsValid year, c(count Econs min Econs mean Econs max Econs)
-	* summarise Gas
-	table GconsValid year, c(count Gcons min Gcons mean Gcons max Gcons)
+		* summarise Electricity
+		table EconsValid year, c(count Econs min Econs mean Econs max Econs)
+		* summarise Gas
+		table GconsValid year, c(count Gcons min Gcons mean Gcons max Gcons)
 	
-	* distributions by year
-	local vars "Econs Gcons"
-	foreach v of local vars {
-		histogram `v', by(year) name(histo_`v')
-		graph export "`rpath'/NEED-EULF-2014-histo_`v'_by_year.png", replace 
-		graph box `v', over(year) name(box_`v')
-		graph export "`rpath'/NEED-EULF-2014-box_`v'_by_year.png", replace 
+		* distributions by year
+		local vars "Econs Gcons"
+		foreach v of local vars {
+			histogram `v', by(year) name(histo_`s'pc_`v')
+			graph export "`rpath'/NEED-EULF-2014-`s'pc-histo_`v'_by_year.png", replace 
+			graph box `v', over(year) name(box_`s'pc_`v')
+			graph export "`rpath'/NEED-EULF-2014-`s'pc-box_`v'_by_year.png", replace 
+		}
 	}
 }
 
-- 
GitLab