library(spatial) #help(package=spatial) towns <- ppinit("towns.dat") par(pty="s") plot(Kfn(towns, 10), type="b", xlab="distance", ylab="L(t)") title("Kfunction for towns data",cex=.5) Kfunc <- Kfn(towns, 10) Kfunc plot(Kfn(towns, 10), type="b", xlab="distance", ylab="L(t)") for(i in 1:10) lines(Kfn(Psim(69), 10), lty=3) lims <- Kenvl(10,100,Psim(69)) lines(lims$x,lims$l, lty=2, col="green", lwd=3) # lty=2: dotted lines lines(lims$x,lims$u, lty=2, col="green", lwd=3) title("Kfunction with envelope and simulation Poisson Models",cex=.5) plot(Kfn(towns, 10), type="b", xlab="distance", ylab="L(t)") for(i in 1:10) lines(Kfn(Strauss(69,0.5,3.5), 10), lty=3) lines(Kaver(10,25,Strauss(69,0.5,3.5)), col="red", lwd=3) title("Kfunction with Simulations and Average Strauss Model",cex=.5) ############################################################# # # Psim: # Simulate Binomial spatial point process. # # Kfn: # Computes Ripley's K function for a set of case locations # (Actually computes L = sqrt(K/pi).) # # Kaver: # Forms the average of a series of (usually simulated) # K-functions. # # Kenvl: # Computes envelope (upper and lower limits) and average # of simulations of K-fns # #############################################################