# ________________________________________________________ # ( 1 ) fct.plotL <- function ( Kestim, col=c(1,2), lty=c(1,1), ylab="L function", add=F, ylim=NULL){ require(spatstat) if (!is.null(ylim)) { plot ( Kestim, cbind(r=r-r, Lfunc=sqrt(trans/pi)-r)~r, col=0, lty=0, ylab=ylab, ylim=ylim) add <- T } if (!add) plot ( Kestim, cbind(r=r-r, Lfunc=sqrt(trans/pi)-r)~r, col=col, lty=lty, ylab=ylab) if (add) plot ( Kestim, cbind(r=r-r, Lfunc=sqrt(trans/pi)-r)~r, col=col, lty=lty, ylab=ylab, add=add ) # Represente le graph de la fonction L a partir d'un résultat K # ------------- # Kestim = Estimation K (spatstat) a representer sous forme L # col = Couleurs Ref + Est Kcr # lty = Type ligne Ref + Est Kcr # ylim = Limites axe Y # add = Ajoute la courbe sur un graph existant } # ________________________________________________________ # ( 2 ) fct.KcrRandLab <- function (pppMrk, M1, M2, s, nsim=10, quiet=FALSE ) { require(spatstat) if (!quiet) cat("Doing randomization ", 1, "/",nsim,"\n") Mat <- Kcross ( pppMrk%mark%sample(pppMrk$marks), M1, M2, r=s, correction= "translate" )$trans for (isim in (2:nsim)) { if (!quiet) cat("Doing randomization ", isim, "/",nsim,"\n") Tmp <- Kcross ( pppMrk%mark%sample(pppMrk$marks), M1, M2, r=s, correction= "translate" )$trans Mat <- rbind(Mat,Tmp) } # Calcul matrice de randomization Kcross par Random Labelling # ------------- # pppMrk = A marked point pattern # M1 M2 = Marks # s = Distance lags # Proba = The proba for the confidence interval # nsim = Number of simulations / randomizations } # ________________________________________________________ # ( 3 ) fct.plot.ciL <- function ( Mat, s, Proba=0.05, lty=2, col=1, lwd=1 ) { kmin <- apply(Mat, 2, quantile, probs=Proba/2, na.rm=T ) kmax <- apply(Mat, 2, quantile, probs=1-(Proba/2), na.rm=T ) lines ( s, sqrt(kmin/pi)-s, lty=lty, col=col, lwd=lwd ) lines ( s, sqrt(kmax/pi)-s, lty=lty, col=col, lwd=lwd ) # Represente l'interval de confiance sur graph fct.plotL # ------------- # Mat = Matrice randomization calculée par fct.KcrRandLab # s = Distance lags # Proba = Proba de l'interval de confiance # lty = Type ligne # col = Couleur # lwd = Epaisseur de la ligne }