Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Using R for Research: A Gallery of Applications

Using R for Research: A Gallery of Applications

This is a talk I gave as part of my trip to Ritsumeikan University, Japan.

alexsingleton

June 18, 2013
Tweet

More Decks by alexsingleton

Other Decks in Education

Transcript

  1. Alex Singleton Department of Geography and Planning ! www.alex-singleton.com Using

    R for Research: A Gallery of Applications Pt 1 http://www.flickr.com/photos/epsos/5591761716/sizes/o/in/ photostream/ Ritsumeikan University: 18th June 201 R
  2. Overview • Rates of active transport (e.g. cycling or walking)

    to school are in decline • Pupil-school commute is estimated to contribute around 658k tonnes of CO2 / year • Transport adopted for the pupil-school commute has obvious implications for CO2 emissions
  3. Traditional Estimation Technique • Euclidean Distance • Euclidean distance •

    Average emissions values for mode of transport 183.2 vehicle CO2 g/km (DEFRA 2011) ! SL – trip – 1.2km ! 1.2 * 183.2 = 219.84 CO2 g / journey ! Daily commute - 219.84 * 2 = 439.68 OpenStreetMap
  4. Problems • No account for real world geography – Straight

    lines will typically underestimate true distances • No sensitivity to different vehicle types – What about train / bus etc? • Geocomputation provides a solution…
  5. Challenges • Estimate transport network level routes for pupil journeys

    • Account for variable CO2 emissions between different vehicle types • Individual level for a national population?
  6. Model • d distance • p pupil • i pupil

    home postcode • j school postcode • e CO2 g/km • t transport mode • g location k p = 2 d i p j p t p ( )e t p g p ( )w t p ( ) ( ) Distance CO2g/km Weight
  7. Pupil Data • Department for Education – Pupil Level Annual

    School Census (PLASC) • Postcode level • 2007 – 2012 – “usual” travel mode • 7,373,505 pupil records after exclusions (e.g. no postcode etc) – multiple years • Mostly state school pupils
  8. Vehicle Data • Department for Transport – LSOA average CO

    2 g/km for those vehicles registered within these zones – Driver Vehicle Licensing Agency (DVLA) • European legislation directive 91/441/EC – Cars registered after March 2001 • Caveat – Possible underestimation? » 162.9 CO 2 g/km differs from the DEFRA national estimate of 183.2 CO 2 g/km (DEFRA 2011). » Might be specific car types for school run?
  9. Data Processing OpenStreetMap railway=light_rail railway=subway PostGIS Road / Path Light

    Rail / Tube Routino .osm XML files Meridian2 Railway Lots of Cleaning! 1) Single lines 2) Nodes join 3) Nodes at stations Postcode Directory
  10. Software Infrastructure PostGIS PgRouting Iterative process for each pupil Routino

    1) Query pupil (origin, destination, mode) Rail / Light Rail 2) Mode Choice? Road Pupil (distance, mode) 3) Car based? Yes Return LSOA Avg. CO2 g/km No Use type averages Pupil (distance, mode, CO2 g/km) 4) Implement the model
  11. 0.00 0.25 0.50 0.75 0.00 0.25 0.50 0.75 0.00 0.25

    0.50 0.75 0.00 0.25 0.50 0.75 0.00 0.25 0.50 0.75 0.00 0.25 0.50 0.75 0.00 0.25 0.50 0.75 0.00 0.25 0.50 0.75 0.00 0.25 0.50 0.75 0.00 0.25 0.50 0.75 0.00 0.25 0.50 0.75 0.00 0.25 0.50 0.75 0.00 0.25 0.50 0.75 1 2 3 4 5 6 7 8 9 10 11 12 13 0−0.5km 0.5−1km 1−1.5km 1.5−2km 2−2.5km 2.5−3km 3−3.5km 3.5−4km 4−4.5km 4.5−5km 5−5.5km 5.5−6km 6−6.5km 6.5−7km 7−7.5km 7.5−8km 8−8.5km 8.5−9km 9−9.5km 9.5−10km Distance Percentage Mode BUS CAR NON School Year • Over time increase in distance of non • Year 6-7 – large jump in distance non – Bus more prevalent
  12. Next Steps • Estimating Bus Routes – Walk to bus

    stop – route to school? • Multimodal journeys • Data issues – E.g. confusion in London (tube, rail, light rail) • Scaling issues – This all takes a very long time! • Temporal changes – Policy evaluation
  13. Time and Money Saving • In each report there are

    ~391 pages, each with a map. That means, for the 354 local authorities in England & Wales ~138,414 maps • Say 10 minutes a map: 23,069 hours • Working 24hr shifts for 961 days! • Salary £18 / hour • Total cost £415,242 • Working weeks (35 hrs) – 659 weeks (~11 years)
  14. R in Action • 2 lists – – A) All

    local authorities – B) All census variables – prepared for mapping • Start Loop 1 – for local authority X in A – Start Loop 2 – for census variable Y in B – Make a map for variable Y in local authority X – Close Loop 2 when all Y in B are mapped • Close Loop 1, and move onto next X in A • End code when all X in A have been mapped