Disability estimates by year
Created: 2012-02-28 16:16:13
Uses census and health survey for england together with R to estimate disability for districts in the UK
Preview
Run
Run this Workflow in the Taverna Workbench...
Workflow Components
Authors (1)
|  |
Titles (1)
|  |
Disability estimates by year |
Descriptions (1)
|  |
Uses census and health survey for england together with R to estimate disability for districts in the UK |
Dependencies (0)
|  |
Inputs (3)
|  |
Name |
Description |
year |
What year the disability estimates are for
|
disability |
A list of disability types. Choose from mobility, hearing, sight, pcare and disability.
pcare=personal care
disability=general disability
|
zonenames |
Districts of the UK. eg Barnet, Tameside
For example names see http://www.direct.gov.uk/en/Dl1/Directories/Localcouncils/AToZOfLocalCouncils/index.htm or look inside the data file Zonename column
Districts of the UK. eg Barnet, Tameside
For example names see http://www.direct.gov.uk/en/Dl1/Directories/Localcouncils/AToZOfLocalCouncils/index.htm or look inside the data file
Districts of the UK.
For example names see http://www.direct.gov.uk/en/Dl1/Directories/Localcouncils/AToZOfLocalCouncils/index.htm or look inside the zonename column of the source datafile at https://www.methodbox.org/data_extracts/402-census-and-hse-mix
Districts of the UK.
For example names see http://www.direct.gov.uk/en/Dl1/Directories/Localcouncils/AToZOfLocalCouncils/index.htm or look inside the data file zonename column
Districts of the UK. eg Barnet, Tameside
For example names see http://www.direct.gov.uk/en/Dl1/Directories/Localcouncils/AToZOfLocalCouncils/index.htm or look inside the data file zonename column
Districts of the UK. eg Barnet, Tameside
|
Processors (11)
|  |
Name |
Type |
Description |
Concatenate_two_strings |
localworker |
Scriptoutput = string1 + string2; |
String_constant |
stringconstant |
Valuepop_ |
Rshell |
rshell |
Script#the source datafile with all the population and disability count details
datafile <- read.csv(datafile)
#rename the pop_'year' column
names(datafile)[names(datafile)==year]<-"population"
#only keep the rows in the required district
datafile <- subset(datafile, datafile$zonename == district )
#intercept slopes from the regression calculations
datafile$a <- ifelse(datafile$sex==2,alpha_female, alpha_male)
datafile$b <- ifelse(datafile$sex==2,beta_female, beta_male)
#logit llti schedules based on the 2001 census data
datafile$logit_LLTI <- 0.5*log(datafile$llti_2001/(1-datafile$llti_2001))
datafile$logit_mod<-datafile$a+(datafile$b*datafile$logit_LLTI)
#mobility rates based on the regression
datafile$modelled <- (exp(2*datafile$logit_mod))/(1+exp(2*datafile$logit_mod))
#sort the data
datafile <- datafile[with(datafile, order(sex, zonecode, age)), ]
#pop for the year, district and disability based on the model
datafile$pop<-datafile$population*datafile$modelled
datafile <- datafile[with(datafile, order(zonecode)), ]
library(doBy)
#sum the calculated population
disab_tot_rel <- summaryBy(pop~zonecode,data=datafile, FUN=c(sum),full.dimension=TRUE)
datafile$disab_tot_rel <- disab_tot_rel$pop.sum
#sum the total population
pop_tot <- summaryBy(population~zonecode,data=datafile, FUN=c(sum),full.dimension=TRUE)
datafile$pop_tot <- pop_tot$population.sum
#remove any duplicate rows
datafile <- datafile[!duplicated(datafile[c("zonecode")]),]
result_data <- subset(datafile, select = c(zonecode,zonename,disab_tot_rel,pop_tot))
result_data$prev <- (result_data$disab_tot_rel/result_data$pop_tot)*100
pct_out <- result_data$prev
disab_tot_out <- result_data$disab_tot_rel
pop_tot_out <- result_data$pop_tot R Serverlocalhost:6311 |
Beanshell |
beanshell |
Scriptswitch (disability_type) {
case "mobility": alpha_male = -0.35111117;
alpha_female = -0.2969268;
beta_male = 1.080914;
beta_female = 1.093486;
break;
case "sight": alpha_male = -1.461451;
alpha_female = -1.290565;
beta_male = 0.8534907;
beta_female = 0.8893959;
break;
case "hearing": alpha_male = -0.8751972;
alpha_female = -1.070253;
beta_male = 0.9570509;
beta_female = 0.9561629;
break;
case "disability": alpha_male = -0.1361027;
alpha_female = -0.1242042;
beta_male = 1.019565;
beta_female = 1.016297;
break;
case "pcare": alpha_male = -0.8308756;
alpha_female = -0.8240076;
beta_male = 0.7947015;
beta_female = 0.8196615;
break;
} |
Split_string_into_string_list_by_regular_expression |
localworker |
ScriptList split = new ArrayList();
if (!string.equals("")) {
String regexString = ",";
if (regex != void) {
regexString = regex;
}
String[] result = string.split(regexString);
for (int i = 0; i < result.length; i++) {
split.add(result[i]);
}
}
|
split_by_line |
stringconstant |
Value\n |
methodbox_url |
stringconstant |
Valuehttps://methodbox.org |
data_download_url |
stringconstant |
Valuedata_extracts/402-census-and-hse-mix/download?type=CSV |
Get_Web_Page_from_URL_2 |
localworker |
ScriptURL inputURL = null;
if (base != void) {
inputURL = new URL(new URL(base), url);
}
else {
inputURL = new URL(url);
}
URLConnection con = inputURL.openConnection();
InputStream in = con.getInputStream();
InputStreamReader isr = new InputStreamReader(in);
Reader inReader = new BufferedReader(isr);
StringBuffer buf = new StringBuffer();
int ch;
while ((ch = inReader.read()) > -1) {
buf.append((char)ch);
}
inReader.close();
contents = buf.toString();
//String NEWLINE = System.getProperty("line.separator");
//
//URL inputURL = null;
//if (base != void) {
// inputURL = new URL(new URL(base), url);
//} else {
// inputURL = new URL(url);
//}
//StringBuffer result = new StringBuffer();
//BufferedReader reader = new BufferedReader(new InputStreamReader(inputURL.openStream()));
//String line = null;
//while ((line = reader.readLine()) != null) {
// result.append(line);
// result.append(NEWLINE);
//}
//
//contents = result.toString();
|
unzip_file |
beanshell |
Scriptimport *;
File tempFile = File.createTempFile(UUID.randomUUID().toString(), ".csv");
BufferedOutputStream dest = null;
FileOutputStream unzippedDatafile = null;
FileInputStream fis = new FileInputStream(zipped_datafile);
ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis));
ZipEntry entry;
while((entry = zis.getNextEntry()) != null) {
if (entry.getName().endsWith(".csv")) {
int count;
data = new byte[2048];
// write the files to the disk
FileOutputStream unzippedDatafile = new FileOutputStream(tempFile);
dest = new BufferedOutputStream(unzippedDatafile, 2048);
while ((count = zis.read(data, 0, 2048)) != -1) {
dest.write(data, 0, count);
}
dest.flush();
dest.close();
}
}
zis.close(); |
Write_Text_File |
localworker |
ScripttempFile = File.createTempFile(UUID.randomUUID().toString(), ".zip");
BufferedWriter out = new BufferedWriter(new FileWriter(tempFile));
out.write(filecontents);
out.close();
outputFile = tempFile.getAbsolutePath();
|
Beanshells (2)
|  |
Name |
Description |
Inputs |
Outputs |
Beanshell |
|
disability_type
|
alpha_male
beta_male
alpha_female
beta_female
|
unzip_file |
|
zipped_datafile
|
tempFile
|
Outputs (3)
|  |
Name |
Description |
pct |
percentage of the district that are estimated to have a disability
|
pop_tot |
|
disab_tot |
|
Datalinks (20)
|  |
Source |
Sink |
year |
Concatenate_two_strings:string2 |
String_constant:value |
Concatenate_two_strings:string1 |
Concatenate_two_strings:output |
Rshell:year |
disability |
Rshell:disability |
Beanshell:alpha_female |
Rshell:alpha_female |
Beanshell:alpha_male |
Rshell:alpha_male |
Beanshell:beta_female |
Rshell:beta_female |
Beanshell:beta_male |
Rshell:beta_male |
Split_string_into_string_list_by_regular_expression:split |
Rshell:district |
unzip_file:tempFile |
Rshell:datafile |
disability |
Beanshell:disability_type |
split_by_line:value |
Split_string_into_string_list_by_regular_expression:regex |
zonenames |
Split_string_into_string_list_by_regular_expression:string |
methodbox_url:value |
Get_Web_Page_from_URL_2:base |
data_download_url:value |
Get_Web_Page_from_URL_2:url |
Write_Text_File:outputFile |
unzip_file:zipped_datafile |
Get_Web_Page_from_URL_2:contents |
Write_Text_File:filecontents |
Rshell:pct_out |
pct |
Rshell:pop_tot_out |
pop_tot |
Rshell:disab_tot_out |
disab_tot |
Coordinations (0)
|  |
Uploader
License
All versions of this Workflow are
licensed under:
Version 1
(of 1)
Credits (1)
(People/Groups)
Attributions (0)
(Workflows/Files)
None
Shared with Groups (0)
None
Featured In Packs (0)
None
Log in to add to one of your Packs
Attributed By (0)
(Workflows/Files)
None
Favourited By (0)
No one
Statistics
Citations (0)Version History
Other workflows that use similar services
(0)
There are no workflows in myExperiment that use similar services to this Workflow.
Log in to make a comment
At the moment the workflow only runs on mac osx and unix due to an issue with reading files on windows. I hope to sort that in the future.
There is an example of using this workflow integrated into a web service using taverna server at http://sae.methodbox.org