Relationship between maize diversity and diversity of languages

setwd("/home/duncan/Dropbox/Maiz Mexico (1)/halfdeg/")
d <- read.csv("maize_idiomas.csv")
dv <- read.csv("Diversity.2000_corregido.csv")
library(rgdal)
## Loading required package: sp
## rgdal: version: 0.8-16, (SVN revision 498) Geospatial Data Abstraction
## Library extensions to R successfully loaded Loaded GDAL runtime: GDAL
## 1.7.3, released 2010/11/10 Path to GDAL shared files: /usr/share/gdal/1.7
## GDAL does not use iconv for recoding strings. Loaded PROJ.4 runtime: Rel.
## 4.8.0, 6 March 2012, [PJ_VERSION: 480] Path to PROJ.4 shared files:
## (autodetected)
str(dv)
## 'data.frame':    80144 obs. of  5 variables:
##  $ X           : int  2 3 4 5 6 7 8 9 10 11 ...
##  $ name        : Factor w/ 47 levels "","Ancho 2000",..: 2 2 2 2 2 2 2 2 2 2 ...
##  $ x           : num  -104 -104 -104 -104 -102 ...
##  $ y           : num  20.8 20.8 20.8 20.8 20.8 ...
##  $ sample_count: int  NA NA NA NA NA NA NA NA NA NA ...
coordinates(dv) <- ~x + y
plot(dv)

plot of chunk unnamed-chunk-1

proj4string(dv) <- CRS("+init=epsg:4326")
writeOGR(dv, "PG:dbname=maiz host=geoserv.ecosur.mx port=5432 user=duncan password=botham149", 
    layer_options = "geometry_name=geom", "biodiverse", "PostgreSQL")
## Error: Layer creation failed
library(ggplot2)
theme_set(theme_bw())
g0 <- ggplot(d, aes(x = idiversity, y = mdiversity))
g0 + geom_point(position = "jitter") + geom_smooth(method = "lm", se = TRUE) + 
    xlab("Diversity of indigenous languages") + ylab("Diversity of maize land races")

plot of chunk unnamed-chunk-2

mod <- lm(mdiversity ~ idiversity, data = d)
summary(mod)
## 
## Call:
## lm(formula = mdiversity ~ idiversity, data = d)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
##  -8.08  -3.99  -0.69   3.01  13.01 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   6.2989     0.1611   39.11   <2e-16 ***
## idiversity    0.6955     0.0741    9.38   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.29 on 2682 degrees of freedom
## Multiple R-squared:  0.0318, Adjusted R-squared:  0.0314 
## F-statistic:   88 on 1 and 2682 DF,  p-value: <2e-16
cor.test(d$mdiversity, d$idiversity, method = "spearman")
## 
##  Spearman's rank correlation rho
## 
## data:  d$mdiversity and d$idiversity
## S = 2.506e+09, p-value < 2.2e-16
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
##    rho 
## 0.2225