[R-sig-Geo] Kcross question

Ashly Townsen ashlytownsen at gmail.com
Sat Mar 10 23:58:24 CET 2012


Hi,

I am creating a bivariate K analysis with the spatstat package.  The code I
used is below, but perhaps a little explanation is preferable first.  I am
trying to analyze the location of peacekeeping operations relative to
battle clusters in countries experiencing a civil war (I am a poli. sci.
graduate student).  The analysis should tell me if peacekeeping locations
are located near different types of battle clusters (this example is low,
med, high deaths) and I have created an output graph that should illustrate
how each compares to the other.  The data is all GIS (long, lat) coded and
I have used the country's border as the bound.  The main question I am
struggling over is related to the r (radius?) value in the kcross command.
 Is there a way to force the r to use my desired increments (I know the
help files says this is possible)?  I would prefer an output that is in
kilometers or meters.  If not, how do I determine the value of r in an unit
measurement?  I have seen a few outputs with x axes labels reading r= .5
meters but I can't figure out how to do this myself.  I have tried to use
the breaks argument but I can't seem to get the function work.  Is there a
pre-step I need to conduct to establish my GIS data as a certain projection
or tell R how my data is coded?   I have also attached the output if you
wish to take a look and let me know if you need additional information.

Thanks in advance,


Ashly Adam Townsen
University of Illinois
Department of Political Science



## CREATE BOUND (FOR DRC)
drc <- readShapePoly("drc2", repair=TRUE)
bound.drc <- as.owin(drc, "owin")

## BRING BACK AS MULTITYPE PPP
data.ppp <- scanpp("DRC_BD.txt", window=bound.drc, multitype=TRUE)

#### YEAR 2004 ####

## LOW BATTLE DEATHS
bik.low.drc.sim.2004 <- envelope(data.ppp, correction="best", Kcross,
i="490LowBD2004", j="490pko2004", nsim=100)

## MED BATTLE DEATHS
bik.med.drc.sim.2004 <- envelope(data.ppp, correction="best", Kcross,
i="490MedBD2004", j="490pko2004", nsim=100)

## HIGH BATTLE DEATHS
bik.high.drc.sim.2004 <- envelope(data.ppp, correction="best", Kcross,
i="490HighBD2004", j="490pko2004", nsim=100)

## Creating Plot objects
drc.low.2004 <- data.frame(bik.low.drc.sim.2004[0:50])
drc.low.data.2004 <- drc.low.2004$obs - drc.low.2004$theo

drc.med.2004 <- data.frame(bik.med.drc.sim.2004[0:50])
drc.med.data.2004 <- drc.med.2004$obs - drc.med.2004$theo

drc.high.2004 <- data.frame(bik.high.drc.sim.2004[0:50])
drc.high.data.2004 <- drc.high.2004$obs - drc.high.2004$theo

plot(drc.low.data.2004, type="s", main="Clustering of Battle Deaths and
Peacekeeping Operations, DRC 2004", ylab="Observed - Expected",
xlab="Distance", lty=1, col="black", ylim=c(-1, 10))
lines(drc.med.data.2004, type="s", lty=1, col="blue")
lines(drc.high.data.2004, type="s", lty=1, col="red")
abline(h=0, lty=3, col="gray21")
legend("topleft", inset=0, c("Low BD","Med BD","High BD"), fill=c("black",
"blue", "red"), cex=0.75, horiz=TRUE)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20120310/38675024/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DRC_ALL_2004.pdf
Type: application/pdf
Size: 5662 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20120310/38675024/attachment.pdf>


More information about the R-sig-Geo mailing list