Skip to content

Instantly share code, notes, and snippets.

View aaronschiff's full-sized avatar

Aaron Schiff aaronschiff

View GitHub Profile
@aaronschiff
aaronschiff / random-walks-2.R
Last active June 12, 2017 01:19
Prediction and spurious regression example
# Regress a random walk on a bunch of others and choose the model with the highest R-squared
# Analyse out-of-sample forecasting performance of that model
# Setup
rm(list = ls())
walk_length = 100
reps = 100
# Generate a random walk of length n
generateRandomWalk = function(n) {
@aaronschiff
aaronschiff / random-walks.R
Created June 12, 2017 01:00
Regress pairs of random walks and look at the p-values
# Perform simple regressions on random walks and analyse the results
# Setup
rm(list = ls())
library(broom)
reps = 1000
walk_length = 100
# Generate a random walk of length n
generateRandomWalk = function(n) {
@aaronschiff
aaronschiff / RUP_spiderweb.R
Created August 10, 2016 19:24
Make a map of all the geodata in Auckland's recommended Unitary Plan
# Fun with Unitary Plan data -- all the things!
# Setup
rm(list = ls())
library(maptools)
crs_nztm = CRS("+proj=tmerc +lat_0=0 +lon_0=173 +k=0.9996 +x_0=1600000 +y_0=10000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs")
# Map config
line_width = 1
point_size = 0.25
@aaronschiff
aaronschiff / RUP_overlays_map.R
Created August 7, 2016 23:32
Maps of recommended Auckland Unitary Plan overlays
# Maps of overlays in the IHP recommended Auckland Unitary Plan
# Setup
rm(list = ls())
library(maptools)
crs_nztm = CRS("+proj=tmerc +lat_0=0 +lon_0=173 +k=0.9996 +x_0=1600000 +y_0=10000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs")
# Map config
line_width = 1
line_colour = rgb(100/255, 100/255, 100/255)
@aaronschiff
aaronschiff / Makefile
Created February 11, 2016 20:45
Transformations on LINZ shapefiles for use in Mapbox
DATA_DIR = /Users/aaron/Google\ Drive/Data/Geographic/NZ/Topographic
nzlakes: nzlakes50.shp nzlakes250.shp nzlakes500.shp
nzlakes50.shp: $(DATA_DIR)/50k/nz-lake-polygons-topo-150k/nz-lake-polygons-topo-150k.shp
rm -f temp.*
ogr2ogr temp.shp $(DATA_DIR)/50k/nz-lake-polygons-topo-150k/nz-lake-polygons-topo-150k.shp -nln temp
ogr2ogr nzlakes50.shp temp.shp -sql "SELECT name, OGR_GEOM_AREA/1000 as area FROM temp" -t_srs EPSG:4326
rm temp.*