K1D User Guide

K1D: analysis of synchrony of events at one or multiple sites using the Ripley K function.

The method is a simplification of the commonly used Ripley K function for spatial aggregation or evenness, but applied to one dimension (time) rather than two dimensions (space). The method is described in the online appendix from Gavin et al. 2006. A desktop version of the program (with additional features) is available on the Environmental Change Research Group website. If you compare it to the desktop program, this program is the same as the "bivariate bidirectional" option with integer data.

The k1d.sim function can do two types of simulations: "circular", which is moving the record forward a random number of years, and wrapping around to the back, and "random" which is just picking random years (not picking the same year twice, though). You can change the number of simulations (nsim) and the size of the confidence envelopes (perc).

Function K1d

Description

Calculates the bivariate Ripley K statistic on one dimension. Integer data required. Requires R package 'compiler'

Arguments

X A matrix where columns are sites and rows contain dates of events. The code requires integer data. There does not need to be same number of dates at each site.

start The first year of the analysis period.

end The last year of the analysis period. Events occurring outside of the bounds of start and end will be ignored.

stepsize The length of the period of each step of the analysis. Not smaller than the precision of the data (e.g., 1 year).

nstep the number of steps to analyze. Total temporal window is from 0 to (nstep * stepsize)-1.

Value

A list with the following items: The original input data listed above (X, start, end, stepsize, nstep)

record.length The length of the analysis period. end - start + 1

h A vector of the intervals analyzed (0, stepsize * 1, stepsize * 2, ... , stepsize * (nstep-1))

Khat A vector of the Khat values. Same length as h.

Lhat A vector of the Lhat values. Lhat = Khat/2- h - 0.5

Gn The number of sites in X

n An array of length Gn giving the of the number of events at each site.

dmax This is the maximum value of h.

An example using the Utah fire history data (dates of fire events at 16 sites in Utah; See Heyerdahl et al. 2011).

# Load the software
source("k1d.R.txt")
# Read the example data file
X <- read.csv("utah.csv")
t <- k1d(X,start=1600,end=1880,nstep=51,stepsize=1)
# plot the Lhat function
plot.k1d(t)  

Function k1d.sim

Description

Computes the ENVELOPES for Ripley's K-function for 2 types of processes (circular or randomization; see below). Hundreds of simulations requires a long period (many minutes) to run.

Arguments

k1d.obj An object created by the function k1d

rcol vector of length 2, first value indicates whether to randomize record 1, second value indicates whether to randomize records 2 and greater. Default value=c(TRUE,TRUE).

scenario Either "circular" or "random". If "circular", each randomization shifts series by a random amount, wrapping events from the end to the start of the analysis period. If "random", random dates are chosen for all events (uniform probability over the analysis period).

nsim The number of simulations to run.

perc A vector of length 2, giving the percentiles of the analysis.

Value

A matrix with two columns and h rows. Each column is the lower and upper confidence interval of Lhat for the simulations. The rows correspond to each step as in h.

s <- k1d.sim(t,scenario="circular",nsim=10,perc=c(0.025,0.975))
lines(t$h,s[1,],col=2)
lines(t$h,s[2,],col=2)