impetusModel.Rmd
- Introduction
- Drivers of domestic water demand
- Domestic demand response to drought
- Data
- Climate data
- Regression coefficients
- Household data
- Model Versions
- Conference papers:
- Import generic data
- Baseline Year 0 consumption estimation (model v1)
- Baseline Year 0 consumption estimation (model v2)
- Historical 1995-2014 consumption estimation
- Add Water Efficiency uptake
- Drought Response Water Efficiency Model
- About
- Contributions
- Code
- Citation
- Runtime
- References
title: "A household level daily consumption estimation microsimulation model"
author: Ben Anderson (b.anderson@soton.ac.uk, `@dataknut`), Despoina Manouseli (d.manouseli@soton.ac.uk)
& Magesh Nagarajan (m.nagarajan@soton.ac.uk)
date: 'Last run at: `r Sys.time()`'
output:
html_document:
keep_md: yes
number_sections: yes
self_contained: no
toc: yes
toc_depth: 4
toc_float: yes
pdf_document:
number_sections: yes
toc: yes
toc_depth: 4
toc_float: yes
word_document:
fig_caption: yes
keep_md: yes
toc: yes
toc_depth: 4
bibliography: '`r paste0(here::here(), "/bibliography.bib")`'
knitr::opts_chunk$set(echo = TRUE) # echo code so reader can see what is happening
knitr::opts_chunk$set(warning = FALSE)
knitr::opts_chunk$set(message = FALSE)
knitr::opts_chunk$set(fig_caption = TRUE)
knitr::opts_chunk$set(fig_height = 6) # default, make it bigger to stretch vertical axis
knitr::opts_chunk$set(fig_width = 8) # full width
knitr::opts_chunk$set(tidy = TRUE) # tidy up code in case echo = TRUE
# Housekeeping ----
# Set start time ----
startTime <- proc.time()
# Where are we?
sysInfo <- Sys.info()
sysName <- sysInfo[[1]]
nodeName <- sysInfo[[4]]
userName <- sysInfo[[7]]
# default code location - needed to load functions & parameters correctly so
# has to be run here and not in the functions file as we can't find the functions file without it!
library(here)
projLoc <- here::here()
# Functions ----
print(paste0("Loading functions from ", projLoc,"/impetusFunctions.R"))
source(paste0(projLoc,"/impetusFunctions.R"))
# Load libraries ----
# NB libraries required by saveFunctions.R should already be loaded
reqLibsLocal <- c("data.table", # fast data manipulation
#"foreign", # STATA data load
#"sqldf", # sql-like functionality
"ggplot2", # slick graphs
"readr", # for read_csv
#"mefa", # ??
"plyr", # fast data munching & rename
"fGarch", # to create consumption distributions
#"doBy", # for summaryBy
"stargazer", # for neat summary & regression tables
"lubridate", # for date manipulation
"knitr" # for kable
)
print(paste0("Loading the following libraries using lb_myRequiredPackages: ", reqLibsLocal))
# Use Luke's function to require/install/load
lb_myRequiredPackages(reqLibsLocal,"http://cran.rstudio.com/")
# Parameters ----
# Do this here AFTER loading libraries
print(paste0("Loading parameters from ", projLoc,"/impetusParameters.R"))
source(paste0(projLoc,"/impetusParameters.R"))
# give feedback
print(paste0("Running on ", sysName, " with projLoc = ", projLoc)) # sysName is set in impetusParameters.R
# top level data paths are set in impetusParameters.R
print(paste0("User: ",userName))
print(paste0("Platform: ",sysName))
print(paste0("Input data path: ",iPath))
print(paste0("Output data path: ",oPath))
# do not set any other paths here as it will vary by model
# set drought phase colours
develCol <- "yellow1" # Developing
droughtCol <- "orange" # Drought
sevDroughtCol <- "red" # Severe Drought
recoveringCol <- "yellowgreen" # Recovering
Introduction
Purpose:
- to test the impact of range of water efficiency interventions linked to a reconstructed UK drought history for 3 UK water resource zones (1995-2014)
text on problem needed here - why do we need such a model?
To do this we:
- Develop a household level microsimulation model to construct baseline (Year 0, Month 0) consumption per 'usage' in litres/day per household. These usages are:
- Basin
- Bath
- Dishwasher
- External
- Kitchen Sink
- Shower
- WC
- Washing Machine
- Appl regression coefficients from [@parkerThesis2014], alongside UK climate observations to the household level microsimulation model to produce estimated litres/day consumption for each month of 1995-2014. These estimates are adjusted for:
- Month of the year
- Year on year increase/decrease
- Climate driver: Temperature
- Climate driver: Rainfall
- Climate driver: Sunshine hours
- Use a reconstructed historical drought series for 1995-2014 constructed by the Centre for Hydrology to indicate 'drought phase' in each month;
- Test the effects on household water consumption of a number of water efficiency interventions applied during relevant drought phases.
The baseline estimated consumption values are generated in two different ways depending on which model version is used but in both cases they are generated for the range of 'usages' listed above. This report details the calculation of these estimates and tests the results against external data sources.
IMPETUS code base:
- Overall repo: https://github.com/dataknut/IMPETUS
- Code to build this report: https://github.com/dataknut/IMPETUS/tree/master/impetusModel
Drivers of domestic water demand
Summary of lit review as relevant to microsimulation model.
Domestic demand response to drought
Summary of lit review as relevant to interventions to be tested.
Data
Climate data
We use the UK Met Office monthly climate observation data regional monthly climate data for mean temperature, overall rainfall and total sunshine hours. Although this is available from 1910 onwards, we extract just 1995-2014 to match to the CEH drought histories.
Regression coefficients
Discuss [@parkerThesis2014]
Household data
Two sources:
- Synthetic 1800 households with occupancy (hh size) matched to UK Census 2011 distributions
- SPRG 'Traces of Water' household survey (2011) , n = 1800 - discuss water habits etc captured
The final data output consists of 1800 household records for each month of each year in 1995 - 2014 with estimated litres/day for each of the usages listed above.
Model Versions
- v1_2: uses median mcm values from [@parkerThesis2014] Table 4.1
- v1_3: uses median mcm values from [@parkerThesis2014] Table 4.4 & Fig 5.1
- v2: uses values estimated from the SPRG Traces of Water Household Survey
Conference papers:
- Efficient 2017 (& follow-up journal article) - uses model v1
- IMA 2017 (or WRM?) - uses model v2
Import generic data
# Import generic data
Baseline Year 0 consumption estimation (model v1)
# Run model 1 baseline estimation & tests and write out synthetic household file
Baseline Year 0 consumption estimation (model v2)
# Run model 2 baseline estimation & tests and write out synthetic household file
Historical 1995-2014 consumption estimation
# Construct historical consumption levels for each month
Add Water Efficiency uptake
# Run water efficiency model
Drought Response Water Efficiency Model
# Run water efficiency model
About
This work was supported by the NERC funded IMPETUS (Improving Predictions of Drought for User Decision-Making) project:
Contributions
Please note that authorship is alphabetical. Contributions are listed below.
Ben Anderson (b.anderson@soton.ac.uk @dataknut
)
- Development of Model v1_3 (based on model v1)
- Review of model v2_0
- Development of historical consumption estimation method
- Authoring report
Despoina Manouseli (d.manouseli@soton.ac.uk)
- Literature and evidence review
- Development of Model v2_0
- Review of Model v1_3
- Review of historical consumption estimation method
- Authoring report
Magesh Nagarajan (m.nagarajan@soton.ac.uk)
- Initial development of Model v1
- Initial development of historical consumption estimation method
- Initial development of water efficiency scenario modelling tool
Code
- https://github.com/dataknut/IMPETUS (currently private)
Citation
If you wish to refer to any of the material from this report please cite as:
- Anderson, B., Manouseli, D. & Nagarajan, M. (
r 1900 + as.POSIXlt(Sys.Date())$year
) A household level daily consumption estimation microsimulation model, University of Southampton: Southampton, UK.
Runtime
t <- proc.time() - startTime
elapsed <- t[[3]]
Analysis completed in r elapsed
seconds ( r round(elapsed/60,2)
minutes) using knitr in RStudio with r R.version.string
running on r R.version$platform
.
R packages used:
- base R - for the basics [@baseR]
- data.table - for fast (big) data handling [@data.table]
- ggplot2 - for slick graphics [@ggplot2]
- dplyr - for rename [@dplyr]
- fGarch - to create skewed normal consumption distributions [@fgarch]
- lubridate - date manipulation [@lubridate]
- knitr - to create this document [@knitr]