## Reproduce Crema et al 2017 ##
if (FALSE) {
data(euroevol) #load data
## Subset only for ca 8000 to 5000 Cal BP (7500-4000 14C Age)
euroevol2=subset(euroevol,C14Age<=7500&C14Age>=4000)
## define chronological breaks
breaks=seq(8000,5000,-500)
## Create a sf class object
library(sf)
sites.df = unique(data.frame(SiteID=euroevol2$SiteID,
Longitude=euroevol2$Longitude,Latitude=euroevol2$Latitude))
sites.sf = st_as_sf(sites.df,coords=c('Longitude','Latitude'),crs=4326)
## Calibration and binning
bins=binPrep(sites=euroevol2$SiteID,ages=euroevol2$C14Age,h=200)
calDates=calibrate(x=euroevol2$C14Age,errors=euroevol2$C14SD,normalised=FALSE)
## Main Analysis (over 2 cores; requires doSnow package)
## NOTE: the number of simulations should be ideally larger
## to ensure more accurate and precise estimates of the p/q-values.
res.locations=sptest(calDates,timeRange=c(8000,5000),bins=bins,
locations=sites.sf,locations.id.col="SiteID",h=100,breaks=breaks,ncores=2,nsim=100,
permute="locations",datenormalised=FALSE)
## Plot results
library(rnaturalearth)
win <- ne_countries(continent = 'europe',scale=10,returnclass='sf')
#retrieve coordinate limits
xrange <- st_bbox(sites.sf)[c(1,3)]
yrange <- st_bbox(sites.sf)[c(2,4)]
par(mfrow=c(1,2))
par(mar=c(0.1,0.1,0,0.5))
plot(sf::st_geometry(win),col="antiquewhite3",border="antiquewhite3",xlim=xrange,ylim=yrange)
plot(res.locations,index=4,add=TRUE,legend=TRUE,option="raw",breakRange=c(-0.005,0.005))
plot(sf::st_geometry(win),col="antiquewhite3",border="antiquewhite3",xlim=xrange,ylim=yrange)
plot(res.locations,index=4,add=TRUE,legend=TRUE,option="test")
}
Run the code above in your browser using DataLab