überhaupt verwenden, da Joshua Katz veröffentlichte diese dialect maps, die Sie all over the webharvard's dialect survey mit nicht finden, ich habe zu kopieren versucht, und Verallgemeinern Sie seine Methoden .. aber viel davon ist über meinen Kopf. Josh offenbarte einige seiner Methoden in this poster, aber (soweit ich weiß) hat nichts von seinem Code offenbart.Wie schön randlos geographisch thematische/Heatmaps mit gewichtet (Umfrage) Daten in R zu machen, wahrscheinlich räumliche Glättung auf Punkt Beobachtungen
Mein Ziel ist es, diese Methoden zu verallgemeinern, so dass es für Benutzer eines der großen Erhebungsdatensätze der US-Regierung leicht ist, ihre gewichteten Daten in eine Funktion zu pollen und eine vernünftige geografische Karte zu erhalten. Die Geographie variiert: einige Umfragedatensätze haben ZCTAs, einige haben Bezirke, einige haben Staaten, einige haben Großstädte, etc. Es ist wahrscheinlich klug, jeden Punkt am Schwerpunkt zu planen - Schwerpunkte werden diskutiert here und für die meisten Geographie in verfügbar the census bureau's 2010 gazetteer files. Für jeden Vermessungsdatenpunkt haben Sie also einen Punkt auf einer Karte. aber einige Umfrage Antworten haben Gewichte von 10, andere haben Gewichte von 100.000! Natürlich muss jede "Hitze" oder Glättung oder Färbung, die letztendlich auf der Karte landet, unterschiedliche Gewichte berücksichtigen.
Ich bin gut mit Umfragedaten, aber ich weiß nichts über räumliche Glättung oder Kernel-Schätzung. Die Methode, die Josh in seinem Poster verwendet, ist k-nearest neighbor kernel smoothing with gaussian kernel
, die mir fremd ist. Ich bin ein Neuling bei der Kartierung, aber ich kann die Dinge im Allgemeinen funktionieren, wenn ich weiß, was das Ziel sein sollte.
Hinweis: Diese Frage ist a question asked ten months ago that no longer contains available data sehr ähnlich. Es gibt auch Informationen von on this thread, aber wenn jemand eine kluge Möglichkeit hat, meine genaue Frage zu beantworten, würde ich das offensichtlich lieber sehen.
Das r-Vermessungspaket hat eine svyplot
-Funktion, und wenn Sie diese Codezeilen ausführen, können Sie gewichtete Daten in kartesischen Koordinaten sehen. aber wirklich, für das, was ich tun möchte, muss das Plotten auf einer Karte überlagert werden.
library(survey)
data(api)
dstrat<-svydesign(id=~1,strata=~stype, weights=~pw, data=apistrat, fpc=~fpc)
svyplot(api00~api99, design=dstrat, style="bubble")
Falls es irgend ist, habe ich einig Beispiel-Code geschrieben, die bereit jemanden gibt mir eine schnelle Art und Weise zu helfen, mit einigen Umfragedaten auf Kern-basierten statistischen Bereichen (ein anderer Geographie-Typ) zu starten.
Irgendwelche Ideen, Ratschläge, würde Führung geschätzt werden (und gutgeschrieben, wenn ich eine formale Tutorial bekommen kann/guide/how-to für http://asdfree.com/ geschrieben)
Dank !!!!!!!!!!
# load a few mapping libraries
library(rgdal)
library(maptools)
library(PBSmapping)
# specify some population data to download
mydata <- "http://www.census.gov/popest/data/metro/totals/2012/tables/CBSA-EST2012-01.csv"
# load mydata
x <- read.csv(mydata , skip = 9 , h = F)
# keep only the GEOID and the 2010 population estimate
x <- x[ , c('V1' , 'V6') ]
# name the GEOID column to match the CBSA shapefile
# and name the weight column the weight column!
names(x) <- c('GEOID10' , "weight")
# throw out the bottom few rows
x <- x[ 1:950 , ]
# convert the weight column to numeric
x$weight <- as.numeric(gsub(',' , '' , as.character(x$weight)))
# now just make some fake trinary data
x$trinary <- c(rep(0:2 , 316) , 0:1)
# simple tabulation
table(x$trinary)
# so now the `x` data file looks like this:
head(x)
# and say we just wanted to map
# something easy like
# 0=red, 1=green, 2=blue,
# weighted simply by the population of the cbsa
# # # end of data read-in # # #
# # # shapefile read-in? # # #
# specify the tiger file to download
tiger <- "ftp://ftp2.census.gov/geo/tiger/TIGER2010/CBSA/2010/tl_2010_us_cbsa10.zip"
# create a temporary file and a temporary directory
tf <- tempfile() ; td <- tempdir()
# download the tiger file to the local disk
download.file(tiger , tf , mode = 'wb')
# unzip the tiger file into the temporary directory
z <- unzip(tf , exdir = td)
# isolate the file that ends with ".shp"
shapefile <- z[ grep('shp$' , z) ]
# read the shapefile into working memory
cbsa.map <- readShapeSpatial(shapefile)
# remove CBSAs ending with alaska, hawaii, and puerto rico
cbsa.map <- cbsa.map[ !grepl("AK$|HI$|PR$" , cbsa.map$NAME10) , ]
# cbsa.map$NAME10 now has a length of 933
length(cbsa.map$NAME10)
# convert the cbsa.map shapefile into polygons..
cbsa.ps <- SpatialPolygons2PolySet(cbsa.map)
# but for some reason, cbsa.ps has 966 shapes??
nrow(unique(cbsa.ps[ , 1:2 ]))
# that seems wrong, but i'm not sure how to fix it?
# calculate the centroids of each CBSA
cbsa.centroids <- calcCentroid(cbsa.ps)
# (ignoring the fact that i'm doing something else wrong..because there's 966 shapes for 933 CBSAs?)
# # # # # # as far as i can get w/ mapping # # # #
# so now you've got
# the weighted data file `x` with the `GEOID10` field
# the shapefile with the matching `GEOID10` field
# the centroids of each location on the map
# can this be mapped nicely?
Um zu erfahren, Kernel im Allgemeinen glatt machen, würde ich empfehlen, Kapitel 6 von Hastie, Tibshirani & Friedman [ Elemente des statistischen Lernens] (http://statweb.stanford.edu/~tibs/ElemStatLearn/). Die Formel 6.5 (und der Text um sie herum!) Beschreibt, wie ein k-nächster Nachbarkern (möglicherweise Gauß) in einer Dimension aussehen würde. Sobald Sie das verstanden haben, ist die Erweiterung auf zwei Dimensionen konzeptionell einfach. (Umsetzung ist eine andere Sache, und jemand anderes muss re: bestehende Implementierungen in R. Wiegen) –
@ JoshO'Brien danke! sieht aus wie das ganze Buch auf der Bahn und die Formel ist auf Sie beziehen sich auf PDF-Seite 212 von http://statweb.stanford.edu/~tibs/ElemStatLearn/printings/ESLII_print10.pdf#page=212 –
mehr diese Karten schlagen die New York Times Titelseite heute: http://www.nytimes.com/interactive/2014/05/12/upshot/12-upshot-nba-basketball.html?hp –