spatial/0000755000176000001440000000000012164264460011744 5ustar ripleyusersspatial/DESCRIPTION0000644000176000001440000000137412164265442013460 0ustar ripleyusersPackage: spatial Priority: recommended Version: 7.3-7 Date: 2013-07-01 Depends: R (>= 3.0.0), graphics, stats, utils Suggests: MASS Authors@R: c(person("Brian", "Ripley", role = c("aut", "cre", "cph"), email = "ripley@stats.ox.ac.uk"), person("Roger", "Bivand", role = "ctb")) Author: Brian Ripley Maintainer: Brian Ripley Copyright: W. N. Venables and B. D. Ripley Description: Functions for kriging and point pattern analysis. Title: Functions for Kriging and Point Pattern Analysis LazyLoad: yes ByteCompile: yes License: GPL-2 | GPL-3 URL: http://www.stats.ox.ac.uk/pub/MASS4/ Packaged: 2013-07-01 11:32:29 UTC; ripley NeedsCompilation: yes Repository: CRAN Date/Publication: 2013-07-01 13:42:26 spatial/LICENCE.note0000644000176000001440000000316112164263403013672 0ustar ripleyusersSoftware and datasets to support 'Modern Applied Statistics with S', fourth edition, by W. N. Venables and B. D. Ripley. Springer, 2002. From the text (pp. 464): These datasets and software are provided in good faith, but none of the authors, publishers nor distributors warrant their accuracy nor can be held responsible for the consequences of their use. This file is intended to clarify ownership and copyright: where possible individual files also carry brief copyright notices. Copyrights ========== Files spatial/data/*.dat were generated or digitized by B. D. Ripley: no copyright is asserted. All other files are copyright (C) 1994-2013 W. N. Venables and B. D. Ripley. Those parts which were distributed with the first edition are also copyright (C) 1994 Springer-Verlag New York Inc, with all rights assigned to W. N. Venables and B. D. Ripley. Licence ======= This is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 or 3 of the License (at your option). This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Files share/licenses/GPL-2 and share/licenses/GPL-3 in the R (source or binary) distribution are copies of versions 2 and 3 of the 'GNU General Public License'. These can also be viewed at http://www.r-project.org/licenses/ Bill.Venables@csiro.au ripley@stats.ox.ac.uk spatial/NAMESPACE0000644000176000001440000000134611754561334013173 0ustar ripleyusersuseDynLib(spatial, .registration = TRUE) export(anova.trls, anovalist.trls, correlogram, expcov, gaucov, Kaver, Kenvl, Kfn, plot.trls, ppgetregion, ppinit, pplik, ppregion, predict.trls, prmat, Psim, semat, sphercov, SSI, Strauss, surf.gls, surf.ls, trls.influence, trmat, variogram) importFrom(graphics, plot) importFrom(stats, anova) importFrom(stats, deviance) importFrom(stats, df.residual) importFrom(stats, extractAIC) importFrom(stats, fitted) importFrom(stats, predict) importFrom(stats, residuals) S3method(anova,trls) S3method(deviance,trls) S3method(df.residual,trls) S3method(extractAIC,trls) S3method(fitted,trls) S3method(plot,trls) S3method(predict,trls) S3method(residuals,trls) S3method(summary,trls) spatial/R/0000755000176000001440000000000012164264315012144 5ustar ripleyusersspatial/R/kr.R0000644000176000001440000003761212027627353012717 0ustar ripleyusers# file spatial/R/kr.R # copyright (C) 1994-9 W. N. Venables and B. D. Ripley # Methods for class "trls" contributed by Roger Bivand. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 or 3 of the License # (at your option). # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # A copy of the GNU General Public License is available at # http://www.r-project.org/Licenses/ # # .spfmat <- function(x, y, np) { n <- length(x) npar <- ((np + 1) * (np + 2))/2 .C(VR_fmat, f = double(n * npar), as.double(x), as.double(y), as.integer(n), as.integer(np))$f } surf.ls <- function(np, x, y, z) { if (np > 6L) stop("'np' exceeds 6") if(is.data.frame(x)) { if(any(is.na(match(c("x", "y", "z"), names(x))))) stop("'x' does not have columns 'x', 'y' and 'z'") if(missing(y)) y <- x$y if(missing(z)) z <- x$z x <- x$x } rx <- range(x) ry <- range(y) .C(VR_frset, as.double(rx[1L]), as.double(rx[2L]), as.double(ry[1L]), as.double(ry[2L]) ) n <- length(x) npar <- ((np + 1) * (np + 2))/2 f <- .spfmat(x, y, np) Z <- .C(VR_ls, as.double(x), as.double(y), as.double(z), as.integer(n), as.integer(np), as.integer(npar), f = f, r = double((npar * (npar + 1))/2), beta = double(npar), wz = double(n), ifail = as.integer(0L)) res <- list(x=x, y=y, z=z, np=np, f=f, r=Z$r, beta=Z$beta, wz=Z$wz, rx=rx, ry=ry, call=match.call()) class(res) <- "trls" res } surf.gls <- function(np, covmod, x, y, z, nx=1000, ...) { if (np > 6) stop("'np' exceeds 6") if(is.data.frame(x)) { if(any(is.na(match(c("x", "y", "z"), names(x))))) stop("'x' does not have columns 'x', 'y' and 'z'") if(missing(y)) y <- x$y if(missing(z)) z <- x$z x <- x$x } rx <- range(x) ry <- range(y) .C(VR_frset, as.double(rx[1L]), as.double(rx[2L]), as.double(ry[1L]), as.double(ry[2L])) covmod <- covmod arguments <- list(...) if (length(arguments)) { onames <- names(formals(covmod)) pm <- pmatch(names(arguments), onames, nomatch = 0L) if (any(pm == 0L)) warning(paste("some of ... do not match")) names(arguments[pm > 0L]) <- onames[pm] oargs <- formals(covmod) oargs[pm] <- arguments[pm > 0L] formals(covmod) <- oargs } mm <- 1.5*sqrt((rx[2L]-rx[1L])^2 + (ry[2L]-ry[1L])^2) alph <- c(mm/nx, covmod(seq(0, mm, mm/nx))) .C(VR_alset, as.double(alph), as.integer(length(alph))) n <- length(x) npar <- ((np + 1) * (np + 2))/2 f <- .spfmat(x, y, np) Z <- .C(VR_gls, as.double(x), as.double(y), as.double(z), as.integer(n), as.integer(np), as.integer(npar), as.double(f), l = double((n * (n + 1))/2), r = double((npar * (npar + 1))/2), beta = double(npar), wz = double(n), yy = double(n), W = double(n), ifail = 0L, l1f = double(n * npar) ) if(Z$ifail > 0L) stop("rank failure in Choleski decomposition") if(nx > 1000L) alph <- alph[1L] res <- list(x=x, y=y, z=z, np=np, f=f, alph=alph, l=Z$l, r=Z$r, beta=Z$beta, wz=Z$wz, yy=Z$yy, W=Z$W, l1f=Z$l1f, rx=rx, ry=ry, covmod=covmod, call=match.call()) class(res) <- c("trgls", "trls") res } .trval <- function(obj, x, y) { n <- length(x) .C(VR_valn, z = double(n), as.double(x), as.double(y), as.integer(n), as.double(obj$beta), as.integer(obj$np))$z } predict.trls <- function (object, x, y, ...) { if (!inherits(object, "trls")) stop("'object' is not a fitted trend surface") n <- length(x) if (length(y) != n) stop("'x' and 'y' differ in length") .C(VR_frset, as.double(object$rx[1L]), as.double(object$rx[2L]), as.double(object$ry[1L]), as.double(object$ry[2L]) ) invisible(.trval(object, x, y)) } trmat <- function (obj, xl, xu, yl, yu, n) { if (!inherits(obj, "trls")) stop("'object' is not a fitted trend surface") dx <- (xu - xl)/n dy <- (yu - yl)/n x <- seq(xl, xu, dx) y <- seq(yl, yu, dy) z <- matrix(nrow = length(x), ncol = length(y)) for (i in seq_along(y)) z[, i] <- predict(obj, x, rep(y[i], length(x))) invisible(list(x = x, y = y, z = z)) } if(0){ trmat <- function(obj, xl, xu, yl, yu, n) { if(!inherits(obj, "trls")) stop("'object' is not a fitted trend surface") .C(VR_frset, as.double(obj$rx[1L]), as.double(obj$rx[2L]), as.double(obj$ry[1L]), as.double(obj$ry[2L]) ) dx <- (xu - xl)/n dy <- (yu - yl)/n x <- seq(xl, xu, dx) y <- seq(yl, yu, dy) z <- matrix(nrow = length(x), ncol = length(y)) for(i in seq_along(y)) z[, i] <- .trval(obj, x, rep(y[i], length(x))) invisible(list(x = x, y = y, z = z)) } } prmat <- function(obj, xl, xu, yl, yu, n) { predval <- function(obj, xp, yp) { npt <- length(xp) .C(VR_krpred, z = double(npt), as.double(xp), as.double(yp), as.double(obj$x), as.double(obj$y), as.integer(npt), as.integer(length(obj$x)), as.double(obj$yy) )$z } if(!inherits(obj, "trgls")) stop("'object' not from kriging") if(n > 999) stop("'n' is too large") .C(VR_frset, as.double(obj$rx[1L]), as.double(obj$rx[2L]), as.double(obj$ry[1L]), as.double(obj$ry[2L]) ) alph <- obj$alph if(length(alph) <= 1L) { mm <- 1.5*sqrt((obj$rx[2L]-obj$rx[1L])^2 + (obj$ry[2L]-obj$ry[1L])^2) alph <- c(alph[1L], obj$covmod(seq(0, mm, alph[1L]))) } .C(VR_alset, as.double(alph), as.integer(length(alph)) ) dx <- (xu - xl)/n dy <- (yu - yl)/n xs <- seq(xl, xu, dx) ys <- seq(yl, yu, dy) z <- matrix(nrow = length(xs), ncol = length(ys)) for(i in seq_along(ys)) z[, i] <- .trval(obj, xs, rep(ys[i], length(xs))) + predval(obj, xs, rep(ys[i], length(xs))) invisible(list(x = xs, y = ys, z = z)) } semat <- function(obj, xl, xu, yl, yu, n, se) { seval <- function(obj, xp, yp) { npt <- length(xp) np <- obj$np npar <- ((np + 1) * (np + 2))/2 .C(VR_prvar, z = double(npt), as.double(xp), as.double(yp), as.integer(npt), as.double(obj$x), as.double(obj$y), as.double(obj$l), as.double(obj$r), as.integer(length(obj$x)), as.integer(np), as.integer(npar), as.double(obj$l1f) )$z } if(!inherits(obj, "trgls")) stop("object not from kriging") if(n > 999) stop("'n' is too large") .C(VR_frset, as.double(obj$rx[1L]), as.double(obj$rx[2L]), as.double(obj$ry[1L]), as.double(obj$ry[2L]) ) alph <- obj$alph if(length(alph) <= 1L) { mm <- 1.5*sqrt((obj$rx[2L]-obj$rx[1L])^2 + (obj$ry[2L]-obj$ry[1L])^2) alph <- c(alph[1L], obj$covmod(seq(0, mm, alph[1L]))) } .C(VR_alset, as.double(alph), as.integer(length(alph))) dx <- (xu - xl)/n dy <- (yu - yl)/n xs <- seq(xl, xu, dx) ys <- seq(yl, yu, dy) z <- matrix(nrow = length(xs), ncol = length(ys)) np <- obj$np npar <- ((np + 1) * (np + 2))/2 if(missing(se)) se <- sqrt(sum(obj$W^2)/(length(obj$x) - npar)) for(i in seq_along(ys)) z[, i] <- se * sqrt(seval(obj, xs, rep(ys[i], length(xs)))) invisible(list(x = xs, y = ys, z = z)) } correlogram <- function(krig, nint, plotit=TRUE, ...) { z <- .C(VR_correlogram, xp = double(nint), yp = double(nint), nint = as.integer(nint), as.double(krig$x), as.double(krig$y), if(krig$np > 0) as.double(krig$wz) else as.double(krig$z), as.integer(length(krig$x)), cnt = integer(nint) ) xp <- z$xp[1L:z$nint] yp <- z$yp[1L:z$nint] z <- list(x = xp, y = yp, cnt = z$cnt[1L:z$nint]) if(plotit) if(exists(".Device")) { plot(xp, yp, type = "p", ylim = c(-1, 1), ...) abline(0, 0) invisible(z) } else { warning("Device not active") return(z) } else z } variogram <- function(krig, nint, plotit=TRUE, ...) { z <- .C(VR_variogram, xp = double(nint), yp = double(nint), nint = as.integer(nint), as.double(krig$x), as.double(krig$y), if(krig$np > 0) as.double(krig$wz) else as.double(krig$z), as.integer(length(krig$x)), cnt = integer(nint) ) xp <- z$xp[1L:z$nint] yp <- z$yp[1L:z$nint] if(xp[1L] > 0) {xp <- c(0, xp); yp <- c(0, yp)} z <- list(x = xp, y = yp, cnt = z$cnt[1L:z$nint]) if(plotit) if(exists(".Device")) { plot(xp, yp, type = "p", ...) invisible(z) } else { warning("Device not active") return(z) } else z } expcov <- function(r, d, alpha=0, se=1) { se^2*(alpha*(r < d/10000) + (1-alpha)*exp(-r/d)) } gaucov <- function(r, d, alpha=0, se=1) { se^2*(alpha*(r < d/10000) + (1-alpha)*exp(-(r/d)^2)) } sphercov <- function(r, d, alpha=0, se=1, D=2) { r <- r/d if(D == 2) { t <- 1 - (2/pi)*(r*sqrt(1-r^2) + asin(r)) } else { t <- 1 - 1.5*r + r^3/2 } se^2*(alpha*(r < 1/10000) + (1-alpha)*ifelse(r < 1, t, 0)) } # Method despatch functions for trend surface trls class objects # residuals.trls <- function (object, ...) { if (!inherits(object, "trls")) stop("'object' is not a fitted trend surface") object$wz } fitted.trls <- function (object, ...) { if (!inherits(object, "trls")) stop("'object' is not a fitted trend surface") object$z - residuals(object) } deviance.trls <- function (object, ...) { if (!inherits(object, "trls")) stop("'object' is not a fitted trend surface") sum(residuals(object)^2) } df.residual.trls <- function (object, ...) { if (!inherits(object, "trls")) stop("'object' is not a fitted trend surface") length(object$z) - length(object$beta) } extractAIC.trls <- function (fit, scale, k = 2, ...) { if (!inherits(fit, "trls")) stop("'object' is not a fitted trend surface") n <- length(fit$z) edf <- length(fit$beta) RSS <- deviance(fit) dev <- n * log(RSS/n) c(edf, dev + k * edf) } # # Anova output to match Burrough & McDonnell (1998) Principals # of Geographical Information Systems (Oxford University Press) # book tabulation # anova.trls <- function (object, ...) { if (length(list(object, ...)) > 1L) return(anovalist.trls(object, ...)) if (!inherits(object, "trls")) stop("'object' is not a fitted trend surface") rss <- deviance(object) rdf <- df.residual.trls(object) n <- length(object$z) edf <- n - rdf - 1L tss <- var(object$z) * (n - 1L) ess <- tss - rss ems <- ess/edf rms <- rss/rdf f <- ems/rms p <- 1 - pf(f, edf, rdf) table <- data.frame(format(c(ess, rss, tss)), format(c(edf, rdf, edf + rdf)), c(format(c(ems, rms)), ""), c(format(f), "", ""), c(format.pval(p), "", "")) dimnames(table) <- list(c("Regression", "Deviation", "Total"), c("Sum Sq", "Df", "Mean Sq", "F value", "Pr(>F)")) cat("Analysis of Variance Table\n", "Model: ") cat(deparse(object$call), "\n", sep="") table } anovalist.trls <- function (object, ...) { objs <- list(object, ...) nmodels <- length(objs) for (i in 1L:nmodels) { if (!inherits(objs[[i]], "trls")) stop("'object' is not a fitted trend surface") } if (nmodels == 1L) return(anova.trls(object)) models <- as.character(lapply(objs, function(x) x$call)) df.r <- unlist(lapply(objs, df.residual.trls)) ss.r <- unlist(lapply(objs, deviance.trls)) df <- c(NA, -diff(df.r)) ss <- c(NA, -diff(ss.r)) ms <- ss/df f <- p <- rep(NA, nmodels) for (i in 2L:nmodels) { if (df[i] > 0) { f[i] <- ms[i]/(ss.r[i]/df.r[i]) p[i] <- 1 - pf(f[i], df[i], df.r[i]) } else if (df[i] < 0) { f[i] <- ms[i]/(ss.r[i - 1]/df.r[i - 1]) p[i] <- 1 - pf(f[i], -df[i], df.r[i - 1]) } else { ss[i] <- 0 } } table <- data.frame(df.r, ss.r, df, ss, f, p) dimnames(table) <- list(1L:nmodels, c("Res.Df", "Res.Sum Sq", "Df", "Sum Sq", "F value", "Pr(>F)")) title <- "Analysis of Variance Table\n" topnote <- paste("Model ", format(1L:nmodels), ": ", models, sep = "", collapse = "\n") sss <- getOption("show.signif.stars") if (sss) options(show.signif.stars = FALSE) print(structure(table, heading = c(title, topnote), class = c("anova", "data.frame"))) if (sss) options(show.signif.stars = TRUE) invisible(structure(table, heading = c(title, topnote), class = c("anova", "data.frame"))) } # # and a basic summary method, avoiding the coefficient values # summary.trls <- function (object, digits = max(3, getOption("digits") - 3), ...) { if (!inherits(object, "trls")) stop("'object' is not a fitted trend surface") print(anova.trls(object)) rdf <- df.residual.trls(object) n <- length(object$z) rss <- deviance(object) tss <- var(object$z) * (n - 1) ess <- tss - rss rsquared <- ess/tss adj.rsquared <- 1 - (1 - rsquared) * ((n - 1)/rdf) cat("Multiple R-Squared:", format(rsquared, digits = digits)) cat(",\tAdjusted R-squared:", format(adj.rsquared, digits = digits), "\n") AIC <- extractAIC(object) cat("AIC: (df = ", AIC[1L], ") ", AIC[2L], "\n", sep = "") cat("Fitted:\n") if (rdf > 5L) { nam <- c("Min", "1Q", "Median", "3Q", "Max") rq <- structure(quantile(fitted.trls(object)), names = nam) print(rq, digits = digits) } else { print(fitted(object), digits = digits) } cat("Residuals:\n") if (rdf > 5L) { nam <- c("Min", "1Q", "Median", "3Q", "Max") rq <- structure(quantile(residuals(object)), names = nam) print(rq, digits = digits) } else { print(residuals(object), digits = digits) } } # # Influence measures, rather fewer than lm.influence # trls.influence <- function (object) { if (!inherits(object, "trls")) stop("'object' is not a fitted trend surface") nr <- length(object$z) nc <- length(object$beta) X <- matrix(object$f, nrow = nr, ncol = nc) hii <- stats::hat(X, FALSE) s <- sqrt(deviance(object)/df.residual.trls(object)) r <- residuals(object) stresid <- r/(s * sqrt(1 - hii)) Di <- ((stresid^2) * hii)/(nc * (1 - hii)) invisible(list(r = r, hii = hii, stresid = stresid, Di = Di)) } plot.trls <- function (x, border = "red", col = NA, pch = 4, cex = 0.6, add = FALSE, div = 8, ...) { if (!inherits(x, "trls")) stop("'x' not a fitted trend surface") infl <- trls.influence(x) dx <- diff(range(x$x)) dy <- diff(range(x$y)) dxy <- (dx + dy)/2 mDi <- max(infl$Di) sc <- (mDi * dxy)/div if (!add) plot(x$x, x$y, type = "n", xlab = "", ylab = "") symbols(x$x, x$y, circles=sc * infl$Di, add=TRUE, fg=border, inches=FALSE) points(x$x, x$y, pch = pch) } spatial/R/pp.R0000644000176000001440000001121211754561334012710 0ustar ripleyusers# file spatial/R/pp.R # copyright (C) 1994-9 W. N. Venables and B. D. Ripley # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 or 3 of the License # (at your option). # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # A copy of the GNU General Public License is available at # http://www.r-project.org/Licenses/ # # ppinit <- function(file) { tfile <- file t1file <- system.file("ppdata", file, package="spatial") if(nzchar(t1file)) tfile <- t1file h <- scan(tfile, list(xl = 0, xu = 0, yl = 0, yu = 0, fac = 0), n = 5L, skip = 2L, quiet = TRUE) pp <- scan(tfile, list(x = 0, y = 0), skip = 3, quiet = TRUE) pp$x <- pp$x/h$fac pp$y <- pp$y/h$fac pp$area <- c(xl=h$xl/h$fac, xu=h$xu/h$fac, yl=h$yl/h$fac, yu=h$yu/h$fac) ppregion(pp) invisible(pp) } Kfn <- function(pp, fs, k = 100) { zz <- (c(range(pp$x), range(pp$y)) - ppgetregion())*c(1,-1,1,-1) if(any(zz < 0)) stop("some points outside region") z <- .C(VR_sp_pp2, as.double(pp$x), as.double(pp$y), as.integer(length(pp$x)), k1 = as.integer(k), h = double(k), dmin = double(1L), lm = double(1L), as.double(fs)) list(y = z$h[1L:z$k1], x = (seq(1L:z$k1) * fs)/k, k = k, dmin = z$dmin, lm = max(z$dmin, z$lm), call=match.call()) } Kenvl <- function(fs, nsim, ...) { dot.expression <- as.expression(substitute(...)) h <- Kfn(pp = eval(dot.expression), fs) hx <- h$x hu <- h$y hl <- h$y ha <- h$y^2 for(i in 2:nsim) { h <- Kfn(pp = eval(dot.expression), fs)$y hu <- pmax(hu, h) hl <- pmin(hl, h) ha <- ha + h^2 } list(x = hx, lower = hl, upper = hu, aver = sqrt(ha/nsim), call=match.call()) } Kaver <- function(fs, nsim, ...) { dot.expression <- as.expression(substitute(...)) h <- Kfn(pp = eval(dot.expression), fs) hx <- h$x ha <- h$y^2 for(i in 2:nsim) { h <- Kfn(pp = eval(dot.expression), fs)$y ha <- ha + h^2 } list(x = hx, y = sqrt(ha/nsim), call=match.call()) } ppregion <- function(xl = 0, xu = 1, yl = 0, yu = 1) { if(is.null(xl)) stop("invalid input") if(is.numeric(xl)) if(length(xl) != 1L || length(xu) != 1L || length(yl) != 1L || length(yu) != 1L) stop("invalid input") if(is.list(xl)) { if(is.null(xl$area) && any(is.na(match( c("xl", "xu", "yl", "yu"), names(xl))))) stop("invalid input") } if(is.list(xl)) { if(length(xl$area)) .C(VR_ppset, as.double(xl$area)) else .C(VR_ppset, as.double(c(xl$xl, xl$xu, xl$yl, xl$yu))) } else .C(VR_ppset, as.double(c(xl, xu, yl, yu))) invisible() } ppgetregion <- function() { xx <- .C(VR_ppget, z=double(4))$z names(xx) <- c("xl", "xu", "yl", "yu") xx } Psim <- function(n) { z <- .C(VR_pdata, as.integer(n), x = double(n), y = double(n)) invisible(list(x = z$x, y = z$y, call=match.call())) } Strauss <- function(n, c = 0, r) { init <- 0 if(!exists(".ppx")) { init <- 1 z <- .C(VR_pdata, as.integer(n), x = double(n), y = double(n)) assign(".ppx", z$x) assign(".ppy", z$y) } z <- .C(VR_simpat, as.integer(n), x = as.double(.ppx), y = as.double(.ppy), as.double(c), as.double(r), as.integer(init)) assign(".ppx", z$x) assign(".ppy", z$y) invisible(list(x = z$x, y = z$y, call=match.call())) } SSI <- function(n, r) { z <- .C(VR_simmat, as.integer(n), x = double(n), y = double(n), as.double(r)) invisible(list(x = z$x, y = z$y, call=match.call())) } pplik <- function(pp, R, ng=50, trace=FALSE) { pplikfn <- function(cc, R, n, x, y, ng, target, trace=FALSE) { z <- .C(VR_plike, as.double(x), as.double(y), as.integer(n), as.double(cc), as.double(R), as.integer(ng), as.double(target), res=double(1) ) if(trace) { print(c(cc, z$res)) flush.console() } z$res } n <- length(pp$x) ar <- pp$area target <- n * (Kfn(pp, R,1)$y)^2 * pi / ((ar["xu"] - ar["xl"]) * (ar["yu"] - ar["yl"])) if(target == 0) return(0) tmp <- pplikfn(1, R, n, pp$x, pp$y, ng, target, FALSE) if(tmp <= 0) return(1) stats::uniroot(pplikfn, interval=c(0,1), R=R, n=n, x=pp$x, y=pp$y, ng=ng, target=target, trace=trace)$root } spatial/R/zzz.R0000644000176000001440000000024611754561334013133 0ustar ripleyusers.noGenerics <- TRUE .onUnload <- function(libpath) library.dynam.unload("spatial", libpath) if(getRversion() < "2.6.0") nzchar <- function(x) nchar(x, "b") > 0 spatial/inst/0000755000176000001440000000000012164263264012722 5ustar ripleyusersspatial/inst/CITATION0000644000176000001440000000127711754561334014071 0ustar ripleyuserscitHeader("To cite the spatial package in publications use:") citEntry(entry="Book", title = "Modern Applied Statistics with S", author = personList(as.person("W. N. Venables"), as.person("B. D. Ripley")), publisher = "Springer", edition = "Fourth", address = "New York", year = 2002, note = "ISBN 0-387-95457-0", url = "http://www.stats.ox.ac.uk/pub/MASS4", textVersion = paste("Venables, W. N. & Ripley, B. D. (2002)", "Modern Applied Statistics with S.", "Fourth Edition. Springer, New York. ISBN 0-387-95457-0") )spatial/inst/NEWS0000644000176000001440000000104611754561334013425 0ustar ripleyusersSoftware and datasets to support 'Modern Applied Statistics with S', fourth edition, by W. N. Venables and B. D. Ripley. Springer, 2002, ISBN 0-387-95457-0. This file documents software changes since the third edition. - Methods for class "surf.ls" contributed by Roger Bivand. - surf.ls and surf.gls now check for x,y,z cols in a data frame given for x. - PP datasets moved from data to ppdata - no longer duplicate topo dataset from MASS - Strauss and SSI are now interruptible - the extractAIC method for "trls" objects was using incorrect edf spatial/inst/PP.files0000644000176000001440000000334011754561334014270 0ustar ripleyusersList of point pattern files =========================== caveolae.dat Appleyard et al (1985) cells.dat Ripley (1977) davis.dat Ripley (1981) fig 8.8 drumlin.dat Upton & Fingleton (1985, p.77), Ripley (1990) eagles.dat Ripley (1981) fig 8.11 fig1b.dat Ripley (1988) fig1c.dat Ripley (1988) fig2a.dat Ripley (1988) fig2b.dat Ripley (1988) fig3a.dat Ripley (1988) fig3b.dat Ripley (1988) fig3c.dat Ripley (1988) grocery.dat Ripley (1979) hccells.dat Ripley (1977) nztrees.dat Ripley (1981) fig 8.6 pairfn.dat Ripley (1977) pereg.dat Ripley (1981) fig 8.12 pines.dat Ripley (1981) fig 8.7 redwood.dat Ripley (1977) schools.dat Upton & Fingleton (1985, p.77) stowns1.dat Ripley (1990) tokyo.dat Okabe & Miki (1984) meat stores in figure 3 towns.dat Ripley (1977) S.T. Appleyard, J.A. Witkowski, B.D. Ripley, D.M. Shotton and V. Dubowicz (1985) A novel procedure for pattern analysis of features present on freeze fractured plasma membranes. J. Cell Science 74, 105-117. Okabe, A. & Miki, F. (1984) Environment & Planning, 16, 163-171. Ripley (1977) Modelling spatial patterns (with discussion). J. Roy. Statist. Soc.B 39, 172--212. Ripley (1979) The analysis of geographical maps. In Exploratory and Explanatory Statistical Analysis of Spatial Data eds C.P.A. Bartels and R.H. Ketellapper, Martinus Nijhoff, Boston, 53--72. Ripley (1981) Spatial Statistics. Wiley Ripley (1988) Point processes in the earth sciences. In Quantitative Analysis of Mineral and Energy Resources eds C.-J.F. Chung, A.G. Fabbri and R. Sinding-Larsen, Reidel, Dordrecht, 301-322. Ripley (1990) Gibbsian interaction models. In 'Spatial Statistics: Past, Present and Future' ed D.A. Griffith, Institute of Mathematical Geography (IMAGE) Ann Arbor, pp. 3-25. spatial/inst/po/0000755000176000001440000000000011772553043013341 5ustar ripleyusersspatial/inst/po/de/0000755000176000001440000000000011754561334013733 5ustar ripleyusersspatial/inst/po/de/LC_MESSAGES/0000755000176000001440000000000011772553043015516 5ustar ripleyusersspatial/inst/po/de/LC_MESSAGES/R-spatial.mo0000644000176000001440000000275612036207033017706 0ustar ripleyusersHIZ&i* #1&IpGX+n9&&=Pc'|%#    'n' is too large'np' exceeds 6'object' is not a fitted trend surface'object' not from kriging'x' and 'y' differ in length'x' does not have columns 'x', 'y' and 'z''x' not a fitted trend surfaceDevice not activeinvalid inputobject not from krigingrank failure in Choleski decompositionsome of ... do not matchsome points outside regionProject-Id-Version: R 2.15.2 / spatial 7.3-5 Report-Msgid-Bugs-To: bugs@r-project.org POT-Creation-Date: 2012-09-23 17:22 PO-Revision-Date: 2012-10-12 23:18+0200 Last-Translator: Chris Leick Language-Team: German Language: de MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Plural-Forms: nplurals=2; plural=(n != 1); 'n' ist zu groß'np' überschreitet 6'object' ist keine angepasste Trend-Fläche'objekt' nicht von Kriging'x' und 'y' unterscheiden sich in der Länge voneinander.'x' hat keine Spalten 'x', 'y' und 'z''x' ist keine angepasste Trend-FlächeGerät nicht aktivungültige EingabeObjekt nicht von Krigingfehlerhafter Rang in Cholesky-Zerlegungeinige von … stimmen nicht übereineinige Punkte außerhalb der Regionspatial/inst/po/en@quot/0000755000176000001440000000000011754561334014756 5ustar ripleyusersspatial/inst/po/en@quot/LC_MESSAGES/0000755000176000001440000000000011772553043016541 5ustar ripleyusersspatial/inst/po/en@quot/LC_MESSAGES/R-spatial.mo0000644000176000001440000000254412036207033020724 0ustar ripleyusersHIZ&i* #1&Ip8*0$N:s" & 0I    'n' is too large'np' exceeds 6'object' is not a fitted trend surface'object' not from kriging'x' and 'y' differ in length'x' does not have columns 'x', 'y' and 'z''x' not a fitted trend surfaceDevice not activeinvalid inputobject not from krigingrank failure in Choleski decompositionsome of ... do not matchsome points outside regionProject-Id-Version: spatial 7.3-5 POT-Creation-Date: 2012-10-08 10:54 PO-Revision-Date: 2012-10-08 10:54 Last-Translator: Automatically generated Language-Team: none MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Language: en Plural-Forms: nplurals=2; plural=(n != 1); ‘n’ is too large‘np’ exceeds 6‘object’ is not a fitted trend surface‘object’ not from kriging‘x’ and ‘y’ differ in length‘x’ does not have columns ‘x’, ‘y’ and ‘z’‘x’ not a fitted trend surfaceDevice not activeinvalid inputobject not from krigingrank failure in Choleski decompositionsome of ... do not matchsome points outside regionspatial/inst/po/fr/0000755000176000001440000000000011754561334013752 5ustar ripleyusersspatial/inst/po/fr/LC_MESSAGES/0000755000176000001440000000000011772553043015535 5ustar ripleyusersspatial/inst/po/fr/LC_MESSAGES/R-spatial.mo0000644000176000001440000000301312036207033017710 0ustar ripleyusersHIZ&i* #1&Ip=P2_% '-/O$a0.$    'n' is too large'np' exceeds 6'object' is not a fitted trend surface'object' not from kriging'x' and 'y' differ in length'x' does not have columns 'x', 'y' and 'z''x' not a fitted trend surfaceDevice not activeinvalid inputobject not from krigingrank failure in Choleski decompositionsome of ... do not matchsome points outside regionProject-Id-Version: spatial 7.2-20 Report-Msgid-Bugs-To: bugs@r-project.org POT-Creation-Date: 2012-09-23 17:22 PO-Revision-Date: 2005-12-07 23:53+0100 Last-Translator: Philippe Grosjean Language-Team: French Language: fr MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Plural-Forms: nplurals=2; plural=(n > 1); 'n' est trop large'np' dpasse 6'object' n'est pas une surface de tendance ajuste'object' n'est pas issu d'un krigeage'x' et 'y' diffrent en longueur'x' n'a pas de colonnes 'x', 'y' et 'z''x' n'est pas une surface de tendance ajusteLe priphrique n'est pas actifentre incorrectel'objet n'est pas issu d'un krigeageerreur de rang dans la dcomposition de Choleskyquelques arguments de ... ne correspondent pasquelques points sortent de la rgionspatial/inst/po/pl/0000755000176000001440000000000011772553043013754 5ustar ripleyusersspatial/inst/po/pl/LC_MESSAGES/0000755000176000001440000000000011772553043015541 5ustar ripleyusersspatial/inst/po/pl/LC_MESSAGES/R-spatial.mo0000644000176000001440000000321212036207033017715 0ustar ripleyusersHIZ&i* #1&Ip(2&(C(l-8K"g    'n' is too large'np' exceeds 6'object' is not a fitted trend surface'object' not from kriging'x' and 'y' differ in length'x' does not have columns 'x', 'y' and 'z''x' not a fitted trend surfaceDevice not activeinvalid inputobject not from krigingrank failure in Choleski decompositionsome of ... do not matchsome points outside regionProject-Id-Version: spatial 7.3-4 Report-Msgid-Bugs-To: bugs@r-project.org POT-Creation-Date: 2012-09-23 17:22 PO-Revision-Date: Last-Translator: Łukasz Daniel Language-Team: Łukasz Daniel Language: pl_PL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit na-Revision-Date: 2012-05-29 07:55+0100 Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2); X-Poedit-SourceCharset: iso-8859-1 X-Generator: Poedit 1.5.3 'n' jest zbyt duże'np' przekracza 6'object' nie jest dopasowaną powierzchnią trendu'object' nie jest z krigingu'x' oraz 'y' różnią się długością'x' nie zawiera kolumn 'x', 'y' oraz 'z''x' nie jest dopasowaną powierzchnią trenduUrządzenie nie jest aktywneniepoprawne wejście'object' nie jest z kriginguniepowodzenie pozycjonowania w dekompozycji Cholesky'egoniektóre z ... nie pasująniektóre punkty są poza obszaremspatial/inst/ppdata/0000755000176000001440000000000011754561334014176 5ustar ripleyusersspatial/inst/ppdata/agter.dat0000644000176000001440000000065111754561334015774 0ustar ripleyusers40 Agterberg 0 7 0 7 0.1 5.96 3.28 5.38 2.46 2.34 1.46 3.94 4.54 3.58 3.39 2.79 6.69 6.94 3.00 5.49 4.69 0.36 2.16 1.31 1.93 2.12 4.35 1.86 3.26 2.83 0.96 4.37 3.64 3.75 4.29 3.51 4.41 3.66 4.35 4.14 1.29 4.29 1.09 4.26 0.92 4.11 1.01 3.75 3.21 4.09 0.71 3.58 0.77 3.49 0.90 5.94 3.41 3.56 2.74 5.12 3.47 3.04 2.57 5.14 2.79 1.52 2.96 5.27 2.83 3.64 4.44 2.81 2.68 2.91 6.21 2.23 4.29 5.55 3.58 0.13 2.40 5.59 4.22 4.78 5.14 spatial/inst/ppdata/caveolae.dat0000644000176000001440000000665511754561334016463 0ustar ripleyusers434 CAVEOLAE 0 1000 0 1000 1 98 994 76 925 108 935 155 985 190 989 204 948 188 937 133 922 226 968 228 947 280 947 251 916 309 974 422 951 417 989 530 993 532 976 573 999 522 920 603 935 611 987 634 982 655 982 675 995 659 996 721 993 780 963 840 973 888 826 854 828 826 890 705 811 685 836 660 866 632 880 609 877 579 843 546 826 532 805 503 822 430 818 432 899 381 817 321 818 310 889 290 868 267 842 270 814 246 822 223 878 216 891 189 893 180 868 151 815 133 815 132 901 71 888 18 861 31 760 24 758 30 724 68 727 97 745 82 754 87 776 119 791 169 794 178 747 133 737 148 726 225 753 240 768 245 799 303 788 294 765 284 755 267 741 351 772 344 760 344 726 393 735 409 742 471 776 483 797 490 774 486 741 578 743 589 704 605 784 630 766 655 755 670 757 703 714 723 712 755 716 758 769 817 782 828 746 838 714 880 763 909 731 917 773 942 789 941 686 928 666 938 609 831 668 780 622 763 635 765 680 780 689 689 665 638 622 685 689 619 686 560 693 526 699 519 680 520 660 517 634 571 630 563 642 463 635 467 652 482 662 434 691 420 678 417 707 352 664 363 673 305 655 312 643 292 627 295 693 275 697 211 701 197 695 167 668 129 688 110 690 109 671 178 609 59 623 11 586 32 595 38 568 84 529 78 566 98 539 113 549 107 576 128 592 119 600 167 541 188 588 146 561 216 584 213 534 244 518 271 541 284 543 274 590 268 601 336 565 330 575 301 531 308 516 400 566 413 584 409 591 440 576 463 580 475 561 425 535 530 595 515 578 534 564 573 547 594 557 580 503 621 526 622 576 662 555 681 564 696 570 696 556 681 551 686 516 663 522 666 508 700 507 794 567 808 551 831 560 844 574 848 551 867 565 913 535 969 518 986 494 989 476 951 490 929 499 927 481 953 452 908 414 876 424 890 485 863 489 861 464 843 443 821 423 790 441 764 417 724 420 729 488 692 473 679 456 667 457 699 449 610 413 581 427 569 415 548 416 595 446 566 461 532 466 510 460 498 475 474 498 473 449 450 459 420 447 401 430 384 433 369 426 359 435 334 483 272 424 294 445 274 493 261 503 257 463 225 488 180 501 165 498 174 477 155 480 137 445 111 443 133 486 60 462 42 470 38 416 98 414 89 488 60 501 86 395 77 366 67 334 47 325 100 341 103 360 116 372 124 347 144 367 180 390 188 393 173 367 196 349 148 334 209 315 228 316 240 366 286 332 269 313 305 387 319 366 328 389 335 401 367 399 350 376 359 366 326 343 338 320 367 320 386 341 407 406 450 401 433 350 538 320 588 347 593 382 509 374 607 353 638 364 693 382 701 363 714 372 820 377 815 317 876 372 893 391 919 378 930 397 961 331 951 347 948 364 998 399 994 315 973 220 926 228 854 270 811 257 840 241 625 281 609 289 621 252 628 242 706 297 485 266 442 295 418 271 431 245 460 214 371 230 358 278 358 299 336 259 292 281 273 292 244 293 258 284 233 299 212 297 225 273 213 259 266 228 185 286 136 222 171 216 85 209 57 218 29 284 22 266 9 237 16 108 16 126 25 146 58 181 38 173 76 158 85 143 96 128 60 107 107 122 111 191 146 188 138 122 185 141 198 180 227 146 240 154 280 170 282 108 365 161 394 116 307 136 320 126 399 199 417 200 497 177 516 199 577 113 580 143 541 148 513 122 593 102 671 153 690 159 744 154 831 112 859 150 901 141 916 125 948 145 961 189 986 134 998 162 977 94 997 41 935 10 930 71 903 55 884 79 856 5 841 47 841 66 817 81 876 39 758 67 744 95 652 57 627 3 598 8 582 39 552 80 490 18 414 83 443 104 380 12 323 30 332 42 328 66 311 80 318 92 303 81 279 70 270 22 242 11 225 45 182 17 166 66 196 80 154 35 111 36 125 60 112 93 81 53 79 26 48 43 34 20 18 34 54 76 spatial/inst/ppdata/cells.dat0000644000176000001440000000063011754561334015771 0ustar ripleyusers42 CELLS 0 1 0 1 1 .35 .025 .487 .087 .637 .05 .775 .025 .825 .125 .087 .187 .237 .15 .4 .162 .575 .212 .737 .237 .062 .362 .212 .337 .325 .287 .45 .287 .65 .362 .9 .262 .337 .462 .462 .425 .6 .475 .8 .387 .938 .4 .15 .5 .35 .6 .562 .575 .725 .512 .862 .525 .987 .512 .062 .75 .175 .65 .337 .750 .462 .75 .525 .65 .737 .687 .862 .637 .237 .787 .637 .812 .775 .85 .9 .775 .175 .912 .35 .962 .462 .9 .625 .95 spatial/inst/ppdata/davis.dat0000644000176000001440000000046211754561334016000 0ustar ripleyusers47 CRYSTALS 0 80 0 100 1 2 41 4 3 4 15 9 13 7 35 8 44 10 58 14 2 22 2 21 56 22 53 24 31 27 12 27 34 28 76 37 14 37 61 11 25 15 15 38 25 38 7 41 51 46 2 47 12 50 13 51 25 56 12 58 40 59 28 60 61 62 70 66 1 66 15 65 75 69 38 71 27 76 1 77 4 1 86 8 95 12 88 35 93 45 82 50 83 49 96 69 83 27 85 spatial/inst/ppdata/drumlin.dat0000644000176000001440000000446111754561334016347 0ustar ripleyusers232 Drumlin 44 1353 910 2220 164 0438 2169 0351 2140 0095 2122 0057 2084 0355 2065 0402 2079 0423 1990 0248 2024 0182 2012 0440 1886 0057 1904 0439 1807 0436 1750 0444 1654 0313 1663 0444 1583 0383 1570 0112 1541 0174 1545 0440 1515 0376 1500 0064 1452 0180 1435 0421 1434 0106 1409 0393 1379 0344 1360 0298 1350 0247 1368 0078 1343 0446 1341 0182 1303 0343 1303 0126 1271 0285 1258 0366 1258 0350 1208 0094 1176 0205 1175 0257 1175 0396 1176 0450 1173 0319 1152 0362 1140 0070 1137 0418 1125 0046 1110 0107 1110 0190 1103 0242 1108 0308 1054 0434 1043 0097 1043 0053 1012 0146 0997 0206 1010 0271 1010 0442 1010 0369 0978 0399 0961 0429 0974 0123 0934 0207 0919 0270 0915 0353 0936 0378 0924 0631 2212 0702 2180 0566 2143 0720 2154 0762 2151 0745 2123 0835 2125 0569 2090 0630 2103 0675 2113 0701 2106 0697 2072 0580 2012 0679 2030 0716 1992 0682 1947 0580 1889 0536 1852 0795 1860 0886 1856 0697 1829 0537 1806 0848 1800 0826 1784 0530 1734 0721 1730 0827 1717 0505 1672 0567 1694 0671 1663 0702 1677 0794 1667 0900 1637 0695 1621 0536 1628 0487 1601 0588 1606 0904 1594 0555 1569 0687 1571 0756 1571 0883 1559 0517 1542 0626 1505 0697 1514 0881 1503 0594 1484 0684 1480 0473 1466 0825 1460 0554 1444 0511 1426 0689 1430 0848 1421 0709 1393 0571 1371 0827 1366 0555 1348 0917 1343 0695 1336 0497 1328 0664 1302 0505 1282 0754 1288 0839 1268 0524 1242 0695 1237 0779 1237 0518 1170 0629 1164 0650 1178 0905 1172 0517 1117 0825 1118 0624 1097 0682 1092 0490 1065 0752 1046 0899 1031 0617 0998 0787 0997 0503 0965 0745 0972 0858 0973 0584 0933 0700 0913 0795 0913 0934 0918 0901 2206 1025 2157 1095 2142 0951 2124 0926 2085 1005 2091 1080 2093 1219 2088 1257 2054 0937 2031 0990 2033 1020 2022 0952 1960 1000 1958 1336 1969 0927 1909 1034 1919 1345 1911 1082 1887 1258 1885 0955 1823 0991 1814 1018 1826 1076 1829 1177 1815 1186 1840 1288 1820 0926 1795 1221 1795 0925 1765 1090 1768 1193 1761 1019 1710 1166 1721 1350 1708 0924 1695 1040 1697 1271 1686 0978 1684 1331 1664 0984 1620 1334 1591 0946 1561 1240 1562 1342 1551 1185 1530 1291 1524 1345 1509 0938 1486 1344 1449 1128 1421 1292 1424 1283 1358 1090 1330 1077 1288 1218 1268 1285 1240 1036 1210 1082 1149 1093 1170 1253 1177 1316 1162 0954 1103 1004 1128 1158 1109 1217 1108 1282 1122 1044 1090 1084 1070 1026 1030 1117 0996 1153 1042 0955 0956 1004 0986 1093 0968 1210 0962 1062 0924 1194 0917 spatial/inst/ppdata/eagles.dat0000644000176000001440000000015011754561334016124 0ustar ripleyusers14 EAGLES 0 80 0 80 1 4 39 25 55 43 72 63 74 74 60 45 56 32 41 21 38 35 21 55 42 53 18 63 9 55 1 47 32 spatial/inst/ppdata/fig1b.dat0000644000176000001440000000732211754561334015664 0ustar ripleyusers314 fig1b 0 256 0 256 256 31 211 28 223 34 229 40 228 45 221 39 218 27 215 19 209 20 203 24 198 28 197 38 201 47 202 48 203 57 209 59 217 59 218 53 227 48 237 38 238 24 233 16 222 16 215 30 209 35 204 48 212 54 217 45 188 35 186 29 190 22 152 31 144 30 138 22 131 17 120 16 114 25 84 39 79 107 84 127 96 171 126 177 139 182 183 177 203 139 229 84 209 125 183 129 200 120 224 165 205 176 198 202 172 207 182 215 209 213 231 186 238 226 201 227 163 214 142 211 137 209 126 209 122 219 107 226 106 229 93 220 72 222 60 229 51 232 49 226 42 212 26 202 25 187 27 175 44 195 58 209 75 210 96 184 120 173 122 145 89 133 81 113 58 86 56 82 81 83 130 56 110 100 97 141 118 141 127 130 137 96 152 81 171 87 175 98 177 116 181 152 153 159 156 154 172 137 191 152 199 162 209 167 221 158 221 113 215 96 209 67 193 59 176 49 158 45 155 38 144 38 141 35 119 36 111 37 96 46 72 41 63 27 50 20 47 17 42 32 37 47 28 69 28 103 19 146 12 156 12 172 6 173 6 187 10 206 7 218 10 230 11 237 16 239 37 245 72 248 100 242 125 242 139 242 144 243 152 243 159 243 171 245 176 240 200 235 229 233 233 214 233 197 229 189 228 180 228 165 249 149 249 129 246 113 241 97 238 85 244 84 236 75 227 66 219 58 209 47 198 35 189 27 185 30 174 43 170 34 183 36 193 41 205 56 214 76 219 80 231 63 234 49 225 47 229 36 238 21 230 10 198 7 185 12 172 11 157 159 50 136 57 130 46 150 68 169 64 170 55 176 64 184 69 205 66 182 90 183 55 211 49 198 37 173 46 144 33 168 17 174 19 166 33 149 19 168 19 174 12 191 7 228 13 186 21 188 38 197 35 227 28 232 30 240 39 236 54 212 70 241 66 241 70 232 78 214 86 173 82 165 65 193 56 197 42 221 43 187 24 204 10 231 21 232 10 225 47 222 75 188 75 181 71 147 99 115 132 106 139 79 183 100 203 84 218 72 237 77 243 92 232 58 254 39 244 23 244 15 220 14 196 32 162 43 161 52 168 73 188 82 209 84 216 90 227 90 244 62 224 65 201 49 186 42 171 49 183 54 181 59 184 64 190 57 199 67 189 64 208 70 221 98 226 85 171 70 147 92 155 68 163 66 165 85 173 92 177 102 175 101 152 93 145 76 136 59 131 53 115 56 112 61 103 68 97 76 92 79 88 96 58 97 80 95 99 92 112 85 125 77 143 81 158 99 154 101 145 104 131 99 109 94 106 101 104 108 114 113 105 98 117 80 130 81 141 87 156 71 142 73 167 77 172 85 180 88 188 86 196 79 195 62 151 52 137 57 121 68 109 75 103 78 104 80 104 81 92 spatial/inst/ppdata/fig1c.dat0000644000176000001440000001052311754561334015662 0ustar ripleyusers367 fig1c 0 256 0 256 256 11 194 17 201 27 206 35 210 39 216 41 223 42 225 46 230 53 234 59 236 63 242 63 247 57 246 50 243 39 238 6 122 23 136 39 150 56 161 77 173 91 183 107 195 124 206 141 217 151 224 163 232 171 237 174 239 179 242 188 246 197 250 201 251 9 65 34 81 62 92 79 106 98 117 116 128 137 140 153 153 174 171 197 182 207 189 210 191 219 196 224 199 231 203 234 205 243 210 250 215 254 217 17 10 36 20 58 35 72 46 93 60 111 75 142 94 171 112 179 116 203 125 229 138 240 145 248 149 94 9 96 10 136 20 143 21 164 27 183 43 209 53 233 58 246 64 250 67 254 72 12 200 16 208 17 214 21 216 29 220 29 220 20 213 17 211 12 209 8 205 5 201 5 201 17 207 27 217 29 219 45 234 54 243 57 245 62 251 59 250 58 249 48 242 34 232 33 231 23 226 17 232 21 241 38 245 44 227 31 219 26 217 23 216 26 213 12 203 11 201 13 190 11 185 7 131 20 144 35 156 42 161 58 169 62 171 88 186 108 197 122 208 136 217 156 231 168 237 181 243 185 245 191 249 193 252 198 255 215 247 212 244 204 241 189 234 171 227 156 219 153 217 139 206 118 193 101 182 95 178 81 168 77 165 66 157 62 153 49 143 44 138 32 131 28 128 17 122 13 120 8 117 28 134 45 147 48 150 51 163 54 154 54 152 61 160 76 166 78 166 93 177 98 188 103 194 110 198 121 211 120 214 130 204 138 200 154 198 160 208 175 219 192 225 224 230 250 233 248 239 139 201 121 220 102 226 76 221 34 184 54 182 63 225 95 194 107 241 128 236 72 209 44 213 26 178 14 160 14 157 14 52 42 89 48 95 67 93 82 94 85 97 101 109 128 118 150 137 182 157 210 172 216 177 234 189 250 201 247 201 219 177 173 161 137 147 88 123 37 90 25 72 24 66 55 59 70 91 104 120 141 128 137 143 150 152 195 170 244 202 254 207 248 213 230 183 214 160 192 160 153 167 121 145 106 135 86 108 62 85 33 43 14 39 14 35 35 23 58 58 69 46 89 52 114 69 143 94 166 102 199 132 211 111 217 115 228 140 243 133 225 107 196 105 184 105 155 94 126 74 98 53 76 39 49 25 69 20 104 54 128 68 159 78 167 82 203 97 214 104 236 121 241 134 223 130 204 111 151 89 109 76 96 72 77 70 53 47 49 42 35 33 35 12 55 10 59 3 97 4 120 7 126 5 134 7 131 18 141 13 149 33 155 9 161 37 166 42 171 32 178 29 180 43 181 30 187 23 194 51 192 16 198 33 217 23 222 28 214 42 215 43 226 47 239 49 242 57 250 53 247 43 247 40 242 31 233 28 225 27 204 27 199 35 206 46 234 55 248 68 236 62 245 68 240 69 226 64 201 70 203 83 248 86 226 76 175 64 171 66 151 61 125 37 108 34 102 36 39 98 60 126 95 135 103 155 123 161 131 172 131 182 165 190 188 197 227 209 128 219 143 232 145 233 167 233 21 111 15 103 10 92 16 144 43 144 133 82 150 82 154 84 138 67 125 59 97 63 76 53 98 47 177 74 186 79 188 81 191 98 171 96 178 86 190 115 196 116 215 126 237 113 247 124 251 135 249 141 211 132 219 136 191 122 spatial/inst/ppdata/fig2a.dat0000644000176000001440000000321311754561334015657 0ustar ripleyusers137 fig2a 0 256 0 256 256 25 209 132 201 212 147 155 67 43 57 79 141 216 215 216 214 200 67 166 29 144 115 86 203 168 163 45 162 91 74 80 32 28 200 31 208 32 215 25 214 18 208 20 205 39 162 44 170 47 167 49 163 41 159 44 155 48 157 78 198 82 200 82 201 85 206 85 206 89 204 89 210 81 207 77 203 133 197 137 204 138 204 132 204 127 201 126 197 214 208 212 213 212 219 218 218 224 216 220 213 218 211 76 141 78 146 78 146 82 145 81 142 76 137 81 138 83 141 43 62 39 59 39 56 43 55 43 55 47 57 48 60 92 72 92 72 88 73 89 75 93 77 94 75 89 70 95 73 95 73 74 32 78 32 79 36 79 36 77 36 77 36 82 36 82 32 82 32 78 30 78 30 79 28 79 28 77 27 77 27 84 28 167 31 165 32 160 31 160 27 163 29 162 26 168 26 168 26 153 64 154 68 152 68 152 68 152 64 158 61 157 65 203 65 203 65 200 69 202 69 197 71 196 67 197 65 200 64 214 143 214 143 211 143 209 146 209 146 210 150 215 148 215 149 170 160 163 162 165 167 172 166 172 164 172 164 167 168 167 161 147 112 149 116 144 117 142 115 143 113 143 110 147 115 spatial/inst/ppdata/fig2b.dat0000644000176000001440000000704311754561334015665 0ustar ripleyusers299 fig2b 0 256 0 256 256 19 196 31 225 50 214 54 226 9 226 20 205 33 181 52 179 57 198 32 201 22 182 26 169 31 168 45 168 43 199 69 223 53 244 51 242 32 238 17 236 15 235 18 214 7 198 9 173 22 155 52 156 61 157 74 174 68 193 69 198 74 213 127 186 110 182 106 181 88 170 85 165 82 156 81 152 81 136 88 124 92 121 111 101 117 100 147 98 171 118 178 142 177 150 169 165 161 173 130 191 112 181 134 173 146 179 144 156 106 150 108 163 84 141 106 117 114 135 129 156 118 133 118 99 120 97 129 115 149 112 168 118 169 135 170 138 151 166 155 149 133 145 135 128 137 127 153 130 149 134 116 140 119 142 126 157 121 169 99 169 95 149 99 123 28 114 28 114 15 104 45 109 61 99 65 90 64 88 44 83 18 82 14 82 18 92 27 95 37 89 47 91 48 92 48 95 48 95 34 97 28 103 57 87 51 84 45 82 24 82 20 81 26 80 36 79 44 77 137 154 164 180 187 188 205 179 224 160 224 156 231 128 228 104 226 101 214 90 197 82 194 83 180 93 161 112 153 129 155 135 167 148 185 112 193 106 198 105 211 103 222 112 224 115 219 128 205 141 199 149 199 153 205 162 199 178 187 179 186 170 181 161 186 148 179 139 180 129 179 128 177 122 188 122 200 115 200 123 200 125 188 136 191 134 210 110 209 129 213 147 220 148 239 147 201 95 190 102 189 102 175 102 72 18 80 34 83 37 98 41 113 38 120 30 122 25 129 13 131 1 116 4 108 9 94 14 86 9 98 2 72 21 78 13 76 12 91 23 108 23 116 15 95 42 99 30 104 31 107 31 108 30 158 237 149 227 147 213 154 205 169 200 179 200 181 201 186 206 189 209 199 223 203 239 204 245 196 250 194 252 179 254 176 253 166 250 162 249 174 244 187 237 183 245 189 246 190 245 194 238 194 234 191 224 181 212 174 210 166 208 157 213 154 227 160 232 162 234 173 237 180 227 180 224 170 220 166 225 170 226 189 46 189 46 175 43 175 43 168 37 162 32 161 29 160 22 164 12 173 8 175 6 207 15 208 29 207 32 196 45 194 34 181 38 177 34 177 28 184 16 186 15 196 9 195 16 184 22 185 23 187 26 186 28 186 31 190 27 196 22 187 19 180 24 179 25 176 23 183 17 37 197 38 197 42 204 39 212 38 212 31 208 24 194 30 181 46 184 39 90 39 91 35 92 39 96 177 220 171 223 180 230 175 226 120 130 118 138 126 147 127 137 132 135 130 139 114 146 117 155 214 127 199 132 195 136 193 139 182 134 186 127 192 123 194 129 190 121 192 116 198 115 201 128 186 139 154 145 spatial/inst/ppdata/fig3a.dat0000644000176000001440000000156211754561334015665 0ustar ripleyusers71 fig3a 0 256 0 256 256 47 200 107 224 174 187 123 158 85 150 42 124 31 77 104 29 178 26 233 75 219 137 224 204 155 217 159 130 168 76 116 104 73 94 116 62 56 36 61 238 40 161 31 71 32 82 42 117 41 130 40 156 40 167 46 196 48 206 63 234 58 242 107 220 107 228 84 154 86 146 86 146 72 98 75 89 54 39 59 33 223 198 225 210 218 132 219 143 234 80 232 70 178 30 178 20 178 20 168 72 167 73 169 80 160 126 160 126 157 134 172 182 173 182 176 192 156 213 154 220 123 162 123 153 121 151 116 107 116 99 116 99 115 63 119 59 119 60 103 32 104 24 spatial/inst/ppdata/fig3b.dat0000644000176000001440000000145211754561334015664 0ustar ripleyusers65 fig2c 0 256 0 256 256 16 218 43 218 73 216 101 216 130 216 161 215 195 214 224 214 210 237 178 237 148 237 118 236 89 237 63 237 35 238 27 195 55 193 90 190 116 189 149 190 180 192 209 188 242 191 241 241 14 163 39 164 39 164 70 162 103 161 133 161 164 158 195 155 231 155 31 132 54 130 87 129 119 126 148 125 179 126 214 123 244 123 16 99 42 95 71 90 101 91 132 89 165 89 196 85 231 88 24 63 55 59 86 57 114 55 150 56 183 49 213 48 243 46 34 33 70 30 98 28 128 26 160 23 197 20 225 15 13 16 spatial/inst/ppdata/fig3c.dat0000644000176000001440000000173111754561334015665 0ustar ripleyusers80 fig3c 0 256 0 256 256 31 196 91 196 157 196 220 198 33 128 92 127 157 125 222 125 30 59 90 57 158 54 226 51 35 203 38 196 98 202 99 196 163 201 165 195 225 202 227 197 39 133 41 128 97 132 100 126 159 129 162 124 225 131 229 122 230 58 234 51 163 60 164 53 95 64 97 57 36 65 35 58 27 198 29 189 92 187 98 190 84 190 87 201 149 193 152 202 157 188 223 190 215 189 211 196 213 202 218 203 220 132 215 128 215 120 223 118 151 128 149 123 157 118 92 133 83 129 89 122 95 120 33 133 26 128 31 122 37 123 29 64 22 60 26 54 87 63 82 57 93 49 83 49 154 59 148 53 152 47 160 47 222 57 215 50 221 44 230 46 spatial/inst/ppdata/grocery.dat0000644000176000001440000000075711754561334016353 0ustar ripleyusers79 GROCERY 0 54 54 0 54 7 4 5 4 1 6 13 6 25 8 4 9 20 9 25 9 32 9 44.5 10.5 44 10 5 12 10 13 21 13 5 15 23 16 43 17 12 17 22 18 52.5 17.5 52 18 9 19 6 20 28 24 24 27 19 28 40 28 24 29 29 29 18 30 38 30 41 30 19 31 20 31 43 31 17 32 21 33 16 33 20 33 27 33 18 34 36 34 18.5 35.5 19 35 25 35 33 35 18 36 22 36 26 36 37 36 21 37 19 37 25 37 23 38 23 29 10 39 19 39 21 39 26 39 31 39 9 40 19 40 21 40 36 40 21 41 19 42 46 42 12 43 6 44 8 44 5 45 13 46 15 46 19 47 21 47 38 47 24 48 24 52 29 53 -EOR- spatial/inst/ppdata/hccells.dat0000644000176000001440000000066211754561334016311 0ustar ripleyusers42 HC CELLS 0 1 0 1 1 .063 .619 .328 .238 .8 .177 .923 .734 .541 .736 .767 .303 .674 .732 .063 .247 .842 .431 .627 .585 .111 .958 .253 .882 .280 .586 .681 .894 .393 .702 .175 .762 .337 .462 .861 .989 .520 .334 .057 .516 .611 .135 .543 .523 .41 .86 .407 .553 .925 .848 .365 .027 .156 .318 .062 .75 .544 .012 .46 .119 .796 .619 .288 .368 .385 .321 .762 .064 .215 .034 .63 .351 .121 .160 .974 .97 .001 .131 .898 .347 .585 .831 .716 .470 spatial/inst/ppdata/nztrees.dat0000644000176000001440000000106711754561334016366 0ustar ripleyusers86 N.Z. TREES 0 153 0 95 1.1 1 20 1 42 1 72 2 67 3 22 5 16 6 32 14 3 14 54 17 3 17 33 19 35 20 9 26 37 28 53 29 29 30 43 32 88 33 85 33 15 39 59 41 71 42 6 43 3 43 0 46 86 50 63 50 65 53 63 52 9 55 21 56 10 56 48 61 53 61 56 65 85 66 58 70 22 75 51 75 81 79 10 83 55 90 44 90 46 91 52 91 71 92 88 94 12 96 43 104 15 104 18 106 47 108 52 109 84 110 14 112 38 113 86 116 43 117 48 116 71 117 69 118 55 120 47 123 49 122 20 124 64 125 88 127 28 129 21 129 38 126 7 137 92 141 52 143 70 143 81 143 89 147 87 148 91 150 7 150 14 150 23 150 33 150 44 150 62 150 78 150 92 spatial/inst/ppdata/pairfn.dat0000644000176000001440000000066611754561334016157 0ustar ripleyusers42 PAIRFN 0 1 0 1 1 .997 .962 .968 .448 .583 .741 .091 .152 .807 .396 .971 .103 .532 .041 .208 .009 .824 .813 .587 .266 .115 .509 .221 .622 .937 .32 .664 .086 .651 .608 .989 .814 .656 .342 .238 .403 .426 .309 .827 .989 .586 .878 .709 .511 .349 .068 .181 .754 .929 .65 .448 .836 .354 .668 .289 .272 .709 .932 .809 .108 .154 .884 .777 .681 .894 .220 .231 .148 .066 .635 .339 .914 .852 .535 .537 .449 .354 .494 .448 .155 .073 .372 .471 .630 spatial/inst/ppdata/pereg.dat0000644000176000001440000000022511754561334015771 0ustar ripleyusers20 PEREGRINES 0 80 20 100 80 11 25 18 55 14 66 14 82 33 39 33 45 38 64 32 68 59 21 56 53 48 55 50 76 56 81 42 90 59 92 78 25 63 37 63 66 74 70 70 85 spatial/inst/ppdata/pines.dat0000644000176000001440000000067011754561334016011 0ustar ripleyusers71 PINES 0 96 0 100 10 1 99 1 72 2 62 2 84 7 45 9 75 11 85 13 63 14 16 16 54 17 26 17 41 20 2 21 80 23 87 24 11 25 70 26 57 27 54 28 42 28 26 33 52 33 63 36 59 37 80 39 34 39 47 39 91 41 17 45 23 48 53 49 63 52 43 52 75 53 98 53 13 56 78 58 18 59 68 60 55 61 43 61 32 61 25 63 41 65 81 66 89 66 16 69 4 72 52 72 60 73 42 74 36 74 54 75 93 76 17 79 85 81 45 82 67 83 10 84 32 85 20 86 9 87 87 92 60 92 81 93 8 94 10 94 26 95 23 95 46 95 62 spatial/inst/ppdata/redwood.dat0000644000176000001440000000124711754561334016337 0ustar ripleyusers62 REDWOODS 0 1 -1 0 1 0.36 -0.08 0.44 -0.1 0.48 -0.08 0.48 -0.14 0.5 -0.1 0.76 -0.14 0.78 -0.12 0.78 -0.16 0.84 -0.08 0.86 -0.18 0.9 -0.08 0.9 -0.1 0.9 -0.16 0.9 -0.2 0.18 -0.4 0.18 -0.38 0.2 -0.42 0.6 -0.34 0.62 -0.34 0.64 -0.36 0.64 -0.28 0.68 -0.32 0.68 -0.24 0.7 -0.28 0.72 -0.26 0.1 -0.58 0.12 -0.58 0.12 -0.62 0.14 -0.58 0.18 -0.56 0.18 -0.54 0.2 -0.52 0.2 -0.5 0.22 -0.46 0.24 -0.48 0.52 -0.58 0.5 -0.6 0.58 -0.58 0.94 -0.52 0.96 -0.54 0.22 -0.8 0.22 -0.84 0.26 -0.7 0.44 -0.76 0.48 -0.78 0.5 -0.76 0.9 -0.76 0.9 -0.78 0.48 -0.68 0.52 -0.66 0.56 -0.64 0.999 -0.84 0.44 -0.82 0.48 -0.82 0.34 -0.84 0.38 -0.84 0.26 -0.86 0.4 -0.86 0.28 -0.86 0.74 -0.9 0.86 -0.9 0.96 -0.96 spatial/inst/ppdata/schools.dat0000644000176000001440000000105111754561334016337 0ustar ripleyusers40 schools 300 1225 560 1830 100 421 836 462 1462 463 1292 473 1344 488 763 497 1281 507 1040 538 670 569 1298 571 875 575 1242 588 985 593 1397 597 759 654 755 666 678 668 1323 709 914 726 783 732 1623 736 1205 752 1113 755 1669 760 1465 765 1352 783 1096 806 1533 815 975 853 1202 862 1299 884 1654 910 1237 917 1526 973 1717 978 1425 1007 1143 1011 1545 1045 1660 1056 1388 1106 1533 spatial/inst/ppdata/stowns1.dat0000644000176000001440000000133511754561334016310 0ustar ripleyusers80 towns 380 1055 1307 1951 16.3 1032 1931 0764 1929 0709 1916 0620 1938 0601 1919 0555 1919 0540 1951 0418 1939 0514 1903 0662 1904 0893 1902 0925 1910 0983 1875 0813 1880 0733 1882 0657 1868 0409 1844 0456 1855 0740 1845 0867 1842 0874 1837 0779 1805 0688 1818 0634 1802 1048 1842 0454 1773 0841 1751 0874 1766 0983 1762 1032 1764 0533 1706 0567 1726 0705 1680 0765 1710 0826 1684 0906 1710 0967 1702 0842 1656 0943 1629 0544 1630 0444 1622 0651 1601 0773 1612 0833 1590 0999 1594 0950 1542 0643 1539 0423 1542 0493 1518 0555 1511 0801 1515 0978 1516 0485 1476 0631 1482 0861 1476 0998 1478 0428 1412 0549 1422 0676 1446 0758 1423 0896 1422 0657 1398 0442 1365 0482 1375 0527 1370 0581 1371 0750 1364 0871 1347 0906 1323 0697 1311 spatial/inst/ppdata/tokyo.dat0000644000176000001440000000575111754561334016045 0ustar ripleyusers232 Toshima 65 1890 978 2105 270 65 1355 68 1808 69 1136 74 1151 79 1701 89 1384 89 1175 99 1580 124 1865 134 1842 151 1353 159 1680 169 2076 171 1628 178 2020 179 1461 206 1580 213 992 218 1785 218 1251 266 1641 298 1686 299 2099 300 1074 305 1303 306 1517 309 1040 316 1477 322 1500 342 1513 343 1584 351 1004 355 1235 357 1500 363 1516 369 1559 372 1573 378 1550 391 2066 392 1647 415 2077 422 1074 427 1807 439 1359 440 1096 443 1520 454 1347 468 1345 474 1330 488 1313 492 1786 496 1061 500 1971 507 1750 517 1469 524 1251 526 1530 555 2024 556 1622 556 1452 556 1952 587 1484 596 1875 599 1447 607 1304 608 2043 614 1258 618 1664 622 1114 624 1430 629 2054 632 1402 655 1439 661 1412 668 1076 672 1647 677 1130 677 1439 682 981 683 1729 684 2070 694 1695 704 1950 708 2024 714 1950 720 2097 722 1273 722 1535 724 1953 732 1746 734 1667 741 1732 752 1304 755 1134 757 1835 764 1006 769 1663 775 1019 778 2096 806 1439 813 1079 816 1824 851 1754 860 1748 865 1739 870 1500 883 1736 885 1758 896 1664 903 1079 910 1928 918 1006 925 994 943 1888 946 1458 948 1701 950 1380 964 1684 966 1474 974 1624 984 1971 988 1955 1016 1067 1024 1277 1027 1831 1030 1322 1045 1880 1046 1848 1050 1311 1059 1541 1070 1683 1082 1950 1087 1933 1092 1391 1108 1182 1109 1097 1118 1378 1121 1301 1132 1834 1141 1909 1151 1865 1156 1363 1166 1762 1175 1754 1179 1627 1180 1211 1196 2052 1203 1196 1207 1661 1208 1844 1215 1055 1216 1595 1218 1703 1219 989 1220 1695 1230 1256 1246 1909 1268 1781 1271 1408 1271 1199 1275 1929 1279 1939 1288 1963 1295 1946 1300 2040 1303 1954 1311 1969 1311 1325 1328 1425 1340 1939 1344 1099 1345 1425 1349 1087 1363 1431 1366 2034 1372 1670 1379 1645 1384 1624 1406 2042 1406 2029 1408 1863 1419 1551 1425 1943 1431 1554 1438 1848 1438 1145 1462 1069 1478 1306 1478 1680 1481 1381 1521 1907 1524 1260 1542 1935 1553 1833 1566 1440 1568 1505 1573 1721 1579 1468 1579 1053 1587 1281 1634 1539 1640 1968 1642 1356 1648 2052 1662 1972 1670 1553 1677 1496 1687 1125 1692 1920 1702 1650 1709 1903 1721 1586 1722 1263 1722 1888 1723 1878 1735 1444 1736 1246 1741 1524 1743 1989 1753 1388 1777 1371 1778 1201 1781 1018 1788 1005 1810 1484 1818 1829 1819 1962 1835 1328 1853 1843 1872 1814 1884 1694 1886 1820 spatial/inst/ppdata/towns.dat0000644000176000001440000000152111754561334016041 0ustar ripleyusers69 TOWNS 0 40 0 40 1 .84 39.16 .84 33.20 4.24 34.04 2.56 32.36 9.36 37.44 12.76 37.44 13.60 39.16 17.04 36.60 17.04 34.88 18.72 38.28 17.88 34.88 20.44 35.76 21.28 33.20 18.72 31.48 25.52 35.76 28.08 33.20 28.92 32.36 29.80 36.60 31.48 37.44 35.76 35.76 39.16 33.20 39.16 39.16 4.24 29.80 8.52 24.68 10.20 26.40 15.32 30.64 23.84 30.64 18.72 23.84 22.12 25.52 26.40 23.84 27.24 28.92 20.44 29.80 30.64 25.52 34.88 24.68 35.76 28.08 38.28 28.08 1.72 15.32 2.56 20.44 9.36 21.28 15.32 15.32 16.16 18.72 23.84 19.56 26.40 17.88 27.24 22.12 34.04 14.48 33.20 20.44 36.60 18.72 1.72 7.64 5.96 13.60 5.96 11.08 9.36 13.60 9.36 7.64 15.32 11.92 17.04 5.96 17.88 8.52 22.96 7.64 24.68 13.60 28.08 11.92 29.80 7.64 35.76 12.76 36.60 10.20 4.24 4.24 5.96 5.12 8.52 4.24 10.20 4.24 18.72 0 22.96 3.40 29.80 2.56 31.48 .84 spatial/man/0000755000176000001440000000000011754561334012523 5ustar ripleyusersspatial/man/Kaver.Rd0000644000176000001440000000214211754561334014061 0ustar ripleyusers% file spatial/man/Kaver.Rd % copyright (C) 1994-9 W. N. Venables and B. D. Ripley % \name{Kaver} \alias{Kaver} \title{ Average K-functions from Simulations } \description{ Forms the average of a series of (usually simulated) K-functions. } \usage{ Kaver(fs, nsim, \dots) } \arguments{ \item{fs}{ full scale for K-fn } \item{nsim}{ number of simulations } \item{\dots}{ arguments to simulate one point process object }} \value{ list with components \code{x} and \code{y} of the average K-fn on L-scale. } \references{ Ripley, B. D. (1981) \emph{Spatial Statistics.} Wiley. Venables, W. N. and Ripley, B. D. (2002) \emph{Modern Applied Statistics with S.} Fourth edition. Springer. } \seealso{ \code{\link{Kfn}}, \code{\link{Kenvl}} } \examples{ towns <- ppinit("towns.dat") par(pty="s") plot(Kfn(towns, 40), type="b") plot(Kfn(towns, 10), type="b", xlab="distance", ylab="L(t)") for(i in 1:10) lines(Kfn(Psim(69), 10)) lims <- Kenvl(10,100,Psim(69)) lines(lims$x,lims$lower, lty=2, col="green") lines(lims$x,lims$upper, lty=2, col="green") lines(Kaver(10,25,Strauss(69,0.5,3.5)), col="red") } \keyword{spatial} spatial/man/Kenvl.Rd0000644000176000001440000000225511754561334014075 0ustar ripleyusers% file spatial/man/Kenvl.Rd % copyright (C) 1994-9 W. N. Venables and B. D. Ripley % \name{Kenvl} \alias{Kenvl} \title{ Compute Envelope and Average of Simulations of K-fns } \description{ Computes envelope (upper and lower limits) and average of simulations of K-fns } \usage{ Kenvl(fs, nsim, \dots) } \arguments{ \item{fs}{ full scale for K-fn } \item{nsim}{ number of simulations } \item{\dots}{ arguments to produce one simulation }} \value{ list with components \item{x}{ distances } \item{lower}{ min of K-fns } \item{upper}{ max of K-fns } \item{aver}{ average of K-fns }} \references{ Ripley, B. D. (1981) \emph{Spatial Statistics.} Wiley. Venables, W. N. and Ripley, B. D. (2002) \emph{Modern Applied Statistics with S.} Fourth edition. Springer. } \seealso{ \code{\link{Kfn}}, \code{\link{Kaver}} } \examples{ towns <- ppinit("towns.dat") par(pty="s") plot(Kfn(towns, 40), type="b") plot(Kfn(towns, 10), type="b", xlab="distance", ylab="L(t)") for(i in 1:10) lines(Kfn(Psim(69), 10)) lims <- Kenvl(10,100,Psim(69)) lines(lims$x,lims$lower, lty=2, col="green") lines(lims$x,lims$upper, lty=2, col="green") lines(Kaver(10,25,Strauss(69,0.5,3.5)), col="red") } \keyword{spatial} spatial/man/Kfn.Rd0000644000176000001440000000235211754561334013532 0ustar ripleyusers% file spatial/man/Kfn.Rd % copyright (C) 1994-2009 W. N. Venables and B. D. Ripley % \name{Kfn} \alias{Kfn} \title{ Compute K-fn of a Point Pattern } \description{ Actually computes \eqn{L = \sqrt{K/\pi}}{L = sqrt(K/pi)}. } \usage{ Kfn(pp, fs, k=100) } \arguments{ \item{pp}{ a list such as a pp object, including components \code{x} and \code{y} } \item{fs}{ full scale of the plot } \item{k}{ number of regularly spaced distances in (0, \code{fs}) }} \value{ A list with components \item{x}{ vector of distances } \item{y}{ vector of L-fn values } \item{k}{ number of distances returned -- may be less than \code{k} if \code{fs} is too large } \item{dmin}{ minimum distance between pair of points } \item{lm}{ maximum deviation from L(t) = t }} \details{ relies on the domain D having been set by \code{ppinit} or \code{ppregion}. } \references{ Ripley, B. D. (1981) \emph{Spatial Statistics.} Wiley. Venables, W. N. and Ripley, B. D. (2002) \emph{Modern Applied Statistics with S.} Fourth edition. Springer. } \seealso{ \code{\link{ppinit}}, \code{\link{ppregion}}, \code{\link{Kaver}}, \code{\link{Kenvl}} } \examples{ towns <- ppinit("towns.dat") par(pty="s") plot(Kfn(towns, 10), type="s", xlab="distance", ylab="L(t)") } \keyword{spatial} spatial/man/Psim.Rd0000644000176000001440000000157711754561334013734 0ustar ripleyusers% file spatial/man/Psim.Rd % copyright (C) 1994-9 W. N. Venables and B. D. Ripley % \name{Psim} \alias{Psim} \title{ Simulate Binomial Spatial Point Process } \description{ Simulate Binomial spatial point process. } \usage{ Psim(n) } \arguments{ \item{n}{ number of points }} \value{ list of vectors of \code{x} and \code{y} coordinates. } \details{ relies on the region being set by \code{ppinit} or \code{ppregion}. } \references{ Ripley, B. D. (1981) \emph{Spatial Statistics.} Wiley. Venables, W. N. and Ripley, B. D. (2002) \emph{Modern Applied Statistics with S.} Fourth edition. Springer. } \section{Side Effects}{ uses the random number generator. } \seealso{ \code{\link{SSI}}, \code{\link{Strauss}} } \examples{ towns <- ppinit("towns.dat") par(pty="s") plot(Kfn(towns, 10), type="s", xlab="distance", ylab="L(t)") for(i in 1:10) lines(Kfn(Psim(69), 10)) } \keyword{spatial} spatial/man/SSI.Rd0000644000176000001440000000204211754561334013446 0ustar ripleyusers% file spatial/man/SSI.Rd % copyright (C) 1994-9 W. N. Venables and B. D. Ripley % \name{SSI} \alias{SSI} \title{ Simulates Sequential Spatial Inhibition Point Process } \description{ Simulates SSI (sequential spatial inhibition) point process. } \usage{ SSI(n, r) } \arguments{ \item{n}{ number of points } \item{r}{ inhibition distance }} \value{ list of vectors of \code{x} and \code{y} coordinates } \details{ uses the region set by \code{ppinit} or \code{ppregion}. } \section{Side Effects}{ uses the random number generator. } \section{Warnings}{ will never return if \code{r} is too large and it cannot place \code{n} points. } \references{ Ripley, B. D. (1981) \emph{Spatial Statistics.} Wiley. Venables, W. N. and Ripley, B. D. (2002) \emph{Modern Applied Statistics with S.} Fourth edition. Springer. } \seealso{ \code{\link{Psim}}, \code{\link{Strauss}} } \examples{ towns <- ppinit("towns.dat") par(pty = "s") plot(Kfn(towns, 10), type = "b", xlab = "distance", ylab = "L(t)") lines(Kaver(10, 25, SSI(69, 1.2))) } \keyword{spatial} spatial/man/Strauss.Rd0000644000176000001440000000227511754561334014464 0ustar ripleyusers% file spatial/man/Strauss.Rd % copyright (C) 1994-9 W. N. Venables and B. D. Ripley % \name{Strauss} \alias{Strauss} \title{ Simulates Strauss Spatial Point Process } \description{ Simulates Strauss spatial point process. } \usage{ Strauss(n, c=0, r) } \arguments{ \item{n}{ number of points } \item{c}{ parameter \code{c} in \eqn{[0, 1]}. \code{c = 0} corresponds to complete inhibition at distances up to \code{r}. } \item{r}{ inhibition distance }} \value{ list of vectors of \eqn{x} and \eqn{y} coordinates } \section{Side Effects}{ uses the random number generator } \details{ Uses spatial birth-and-death process for 4\code{n} steps, or for 40\code{n} steps starting from a binomial pattern on the first call from an other function. Uses the region set by \code{ppinit} or \code{ppregion}. } \references{ Ripley, B. D. (1981) \emph{Spatial Statistics.} Wiley. Venables, W. N. and Ripley, B. D. (2002) \emph{Modern Applied Statistics with S.} Fourth edition. Springer. } \seealso{ \code{\link{Psim}}, \code{\link{SSI}} } \examples{ towns <- ppinit("towns.dat") par(pty="s") plot(Kfn(towns, 10), type="b", xlab="distance", ylab="L(t)") lines(Kaver(10, 25, Strauss(69,0.5,3.5))) } \keyword{spatial} spatial/man/anova.trls.Rd0000644000176000001440000000222011754561334015075 0ustar ripleyusers% file spatial/man/anova.trls.Rd % copyright (C) 2001-2 W. N. Venables and B. D. Ripley % \name{anova.trls} \alias{anova.trls} \alias{anovalist.trls} \title{ Anova tables for fitted trend surface objects } \description{ Compute analysis of variance tables for one or more fitted trend surface model objects; where \code{anova.trls} is called with multiple objects, it passes on the arguments to \code{anovalist.trls}. } \usage{ \method{anova}{trls}(object, \dots) anovalist.trls(object, \dots) } \arguments{ \item{object}{ A fitted trend surface model object from \code{surf.ls} } \item{\dots}{ Further objects of the same kind }} \value{ \code{anova.trls} and \code{anovalist.trls} return objects corresponding to their printed tabular output. } \references{ Venables, W. N. and Ripley, B. D. (2002) \emph{Modern Applied Statistics with S.} Fourth edition. Springer. } \seealso{ \code{\link{surf.ls}} } \examples{ library(stats) data(topo, package="MASS") topo0 <- surf.ls(0, topo) topo1 <- surf.ls(1, topo) topo2 <- surf.ls(2, topo) topo3 <- surf.ls(3, topo) topo4 <- surf.ls(4, topo) anova(topo0, topo1, topo2, topo3, topo4) summary(topo4) } \keyword{spatial} spatial/man/correlogram.Rd0000644000176000001440000000241411754561334015327 0ustar ripleyusers% file spatial/man/correlogram.Rd % copyright (C) 1994-9 W. N. Venables and B. D. Ripley % \name{correlogram} \alias{correlogram} \title{ Compute Spatial Correlograms } \description{ Compute spatial correlograms of spatial data or residuals. } \usage{ correlogram(krig, nint, plotit = TRUE, \dots) } \arguments{ \item{krig}{ trend-surface or kriging object with columns \code{x}, \code{y}, and \code{z} } \item{nint}{ number of bins used } \item{plotit}{ logical for plotting } \item{\dots}{ parameters for the plot }} \value{ \code{x} and \code{y} coordinates of the correlogram, and \code{cnt}, the number of pairs averaged per bin. } \section{Side Effects}{ Plots the correlogram if \code{plotit = TRUE}. } \details{ Divides range of data into \code{nint} bins, and computes the covariance for pairs with separation in each bin, then divides by the variance. Returns results for bins with 6 or more pairs. } \references{ Ripley, B. D. (1981) \emph{Spatial Statistics.} Wiley. Venables, W. N. and Ripley, B. D. (2002) \emph{Modern Applied Statistics with S.} Fourth edition. Springer. } \seealso{ \code{\link{variogram}} } \examples{ data(topo, package="MASS") topo.kr <- surf.ls(2, topo) correlogram(topo.kr, 25) d <- seq(0, 7, 0.1) lines(d, expcov(d, 0.7)) } \keyword{spatial} spatial/man/expcov.Rd0000644000176000001440000000200611754561334014314 0ustar ripleyusers% file spatial/man/expcov.Rd % copyright (C) 1994-9 W. N. Venables and B. D. Ripley % \name{expcov} \alias{expcov} \alias{gaucov} \alias{sphercov} \title{ Spatial Covariance Functions } \description{ Spatial covariance functions for use with \code{surf.gls}. } \usage{ expcov(r, d, alpha = 0, se = 1) gaucov(r, d, alpha = 0, se = 1) sphercov(r, d, alpha = 0, se = 1, D = 2) } \arguments{ \item{r}{ vector of distances at which to evaluate the covariance } \item{d}{ range parameter } \item{alpha}{ proportion of nugget effect } \item{se}{ standard deviation at distance zero } \item{D}{ dimension of spheres. }} \value{ vector of covariance values. } \references{ Ripley, B. D. (1981) \emph{Spatial Statistics.} Wiley. Venables, W. N. and Ripley, B. D. (2002) \emph{Modern Applied Statistics with S.} Fourth edition. Springer. } \seealso{ \code{\link{surf.gls}} } \examples{ data(topo, package="MASS") topo.kr <- surf.ls(2, topo) correlogram(topo.kr, 25) d <- seq(0, 7, 0.1) lines(d, expcov(d, 0.7)) } \keyword{spatial} spatial/man/ppgetregion.Rd0000644000176000001440000000113411754561334015334 0ustar ripleyusers% file spatial/man/ppgetregion.Rd % copyright (C) 1994-9 W. N. Venables and B. D. Ripley % \name{ppgetregion} \alias{ppgetregion} \title{ Get Domain for Spatial Point Pattern Analyses } \description{ Retrieves the rectangular domain \code{(xl, xu)} \eqn{\times}{x} \code{(yl, yu)} from the underlying \code{C} code. } \usage{ ppgetregion() } \value{ A vector of length four with names \code{c("xl", "xu", "yl", "yu")}. } \references{ Venables, W. N. and Ripley, B. D. (2002) \emph{Modern Applied Statistics with S.} Fourth edition. Springer. } \seealso{ \code{\link{ppregion}} } \keyword{spatial} spatial/man/ppinit.Rd0000644000176000001440000000164611754561334014324 0ustar ripleyusers% file spatial/man/ppinit.Rd % copyright (C) 1994-9 W. N. Venables and B. D. Ripley % \name{ppinit} \alias{ppinit} \title{ Read a Point Process Object from a File } \description{ Read a file in standard format and create a point process object. } \usage{ ppinit(file) } \arguments{ \item{file}{ string giving file name }} \value{ class \code{"pp"} object with components \code{x}, \code{y}, \code{xl}, \code{xu}, \code{yl}, \code{yu} } \details{ The file should contain the number of points\cr a header (ignored)\cr xl xu yl yu scale\cr x y (repeated n times)\cr } \section{Side Effects}{ Calls \code{ppregion} to set the domain. } \references{ Venables, W. N. and Ripley, B. D. (2002) \emph{Modern Applied Statistics with S.} Fourth edition. Springer. } \seealso{ \code{\link{ppregion}} } \examples{ towns <- ppinit("towns.dat") par(pty="s") plot(Kfn(towns, 10), type="b", xlab="distance", ylab="L(t)") } \keyword{spatial} spatial/man/pplik.Rd0000644000176000001440000000167711754561334014144 0ustar ripleyusers% file spatial/man/pplik.Rd % copyright (C) 1994-9 W. N. Venables and B. D. Ripley % \name{pplik} \alias{pplik} \title{ Pseudo-likelihood Estimation of a Strauss Spatial Point Process } \description{ Pseudo-likelihood estimation of a Strauss spatial point process. } \usage{ pplik(pp, R, ng=50, trace=FALSE) } \arguments{ \item{pp}{ a pp object } \item{R}{ the fixed parameter \code{R} } \item{ng}{ use a \code{ng} x \code{ng} grid with border \code{R} in the domain for numerical integration. } \item{trace}{ logical? Should function evaluations be printed? }} \value{ estimate for \code{c} in the interval \eqn{[0, 1]}. } \references{ Ripley, B. D. (1988) \emph{Statistical Inference for Spatial Processes.} Cambridge. Venables, W. N. and Ripley, B. D. (2002) \emph{Modern Applied Statistics with S.} Fourth edition. Springer. } \seealso{ \code{\link{Strauss}} } \examples{ pines <- ppinit("pines.dat") pplik(pines, 0.7) } \keyword{spatial} spatial/man/ppregion.Rd0000644000176000001440000000145311754561334014640 0ustar ripleyusers% file spatial/man/ppregion.Rd % copyright (C) 1994-9 W. N. Venables and B. D. Ripley % \name{ppregion} \alias{ppregion} \title{ Set Domain for Spatial Point Pattern Analyses } \description{ Sets the rectangular domain \code{(xl, xu)} \eqn{\times}{x} \code{(yl, yu)}. } \usage{ ppregion(xl = 0, xu = 1, yl = 0, yu = 1) } \arguments{ \item{xl}{ Either \code{xl} or a list containing components \code{xl}, \code{xu}, \code{yl}, \code{yu} (such as a point-process object) } \item{xu}{ } \item{yl}{ } \item{yu}{ }} \value{ none } \references{ Venables, W. N. and Ripley, B. D. (2002) \emph{Modern Applied Statistics with S.} Fourth edition. Springer. } \section{Side Effects}{ initializes variables in the \code{C} subroutines. } \seealso{ \code{\link{ppinit}}, \code{\link{ppgetregion}} } \keyword{spatial} spatial/man/predict.trls.Rd0000644000176000001440000000225111754561334015427 0ustar ripleyusers\name{predict.trls} \alias{predict.trls} \title{ Predict method for trend surface fits } \description{ Predicted values based on trend surface model object } \usage{ \method{predict}{trls}(object, x, y, \dots) } \arguments{ \item{object}{ Fitted trend surface model object returned by \code{surf.ls} } \item{x}{ Vector of prediction location eastings (x coordinates) } \item{y}{ Vector of prediction location northings (y coordinates) } \item{\dots}{ further arguments passed to or from other methods. }} \value{ \code{predict.trls} produces a vector of predictions corresponding to the prediction locations. To display the output with \code{image} or \code{contour}, use \code{trmat} or convert the returned vector to matrix form. } \references{ Venables, W. N. and Ripley, B. D. (2002) \emph{Modern Applied Statistics with S.} Fourth edition. Springer. } \seealso{ \code{\link{surf.ls}}, \code{\link{trmat}} } \examples{ data(topo, package="MASS") topo2 <- surf.ls(2, topo) topo4 <- surf.ls(4, topo) x <- c(1.78, 2.21) y <- c(6.15, 6.15) z2 <- predict(topo2, x, y) z4 <- predict(topo4, x, y) cat("2nd order predictions:", z2, "\\n4th order predictions:", z4, "\\n") } \keyword{spatial} spatial/man/prmat.Rd0000644000176000001440000000200311754561334014130 0ustar ripleyusers% file spatial/man/prmat.Rd % copyright (C) 1994-9 W. N. Venables and B. D. Ripley % \name{prmat} \alias{prmat} \title{ Evaluate Kriging Surface over a Grid } \description{ Evaluate Kriging surface over a grid. } \usage{ prmat(obj, xl, xu, yl, yu, n) } \arguments{ \item{obj}{ object returned by \code{surf.gls} } \item{xl}{ limits of the rectangle for grid } \item{xu}{ } \item{yl}{ } \item{yu}{ } \item{n}{ use \code{n} x \code{n} grid within the rectangle }} \value{ list with components \code{x}, \code{y} and \code{z} suitable for \code{contour} and \code{image}. } \references{ Ripley, B. D. (1981) \emph{Spatial Statistics.} Wiley. Venables, W. N. and Ripley, B. D. (2002) \emph{Modern Applied Statistics with S.} Fourth edition. Springer. } \seealso{ \code{\link{surf.gls}}, \code{\link{trmat}}, \code{\link{semat}} } \examples{ data(topo, package="MASS") topo.kr <- surf.gls(2, expcov, topo, d=0.7) prsurf <- prmat(topo.kr, 0, 6.5, 0, 6.5, 50) contour(prsurf, levels=seq(700, 925, 25)) } \keyword{spatial} spatial/man/semat.Rd0000644000176000001440000000241711754561334014127 0ustar ripleyusers% file spatial/man/semat.Rd % copyright (C) 1994-9 W. N. Venables and B. D. Ripley % \name{semat} \alias{semat} \title{ Evaluate Kriging Standard Error of Prediction over a Grid } \description{ Evaluate Kriging standard error of prediction over a grid. } \usage{ semat(obj, xl, xu, yl, yu, n, se) } \arguments{ \item{obj}{ object returned by \code{surf.gls} } \item{xl}{ limits of the rectangle for grid } \item{xu}{ } \item{yl}{ } \item{yu}{ } \item{n}{ use \code{n} x \code{n} grid within the rectangle } \item{se}{ standard error at distance zero as a multiple of the supplied covariance. Otherwise estimated, and it assumed that a correlation function was supplied. }} \value{ list with components x, y and z suitable for \code{contour} and \code{image}. } \references{ Ripley, B. D. (1981) \emph{Spatial Statistics.} Wiley. Venables, W. N. and Ripley, B. D. (2002) \emph{Modern Applied Statistics with S.} Fourth edition. Springer. } \seealso{ \code{\link{surf.gls}}, \code{\link{trmat}}, \code{\link{prmat}} } \examples{ data(topo, package="MASS") topo.kr <- surf.gls(2, expcov, topo, d=0.7) prsurf <- prmat(topo.kr, 0, 6.5, 0, 6.5, 50) contour(prsurf, levels=seq(700, 925, 25)) sesurf <- semat(topo.kr, 0, 6.5, 0, 6.5, 30) contour(sesurf, levels=c(22,25)) } \keyword{spatial} spatial/man/surf.gls.Rd0000644000176000001440000000323111754561334014554 0ustar ripleyusers% file spatial/man/surf.gls.Rd % copyright (C) 1994-9 W. N. Venables and B. D. Ripley % \name{surf.gls} \alias{surf.gls} \title{ Fits a Trend Surface by Generalized Least-squares } \description{ Fits a trend surface by generalized least-squares. } \usage{ surf.gls(np, covmod, x, y, z, nx = 1000, \dots) } \arguments{ \item{np}{ degree of polynomial surface } \item{covmod}{ function to evaluate covariance or correlation function } \item{x}{ x coordinates or a data frame with columns \code{x}, \code{y}, \code{z} } \item{y}{ y coordinates } \item{z}{ z coordinates. Will supersede \code{x$z} } \item{nx}{ Number of bins for table of the covariance. Increasing adds accuracy, and increases size of the object. } \item{\dots}{ parameters for \code{covmod} }} \value{ list with components \item{beta}{ the coefficients } \item{x}{ } \item{y}{ } \item{z}{ and others for internal use only. }} \references{ Ripley, B. D. (1981) \emph{Spatial Statistics.} Wiley. Venables, W. N. and Ripley, B. D. (2002) \emph{Modern Applied Statistics with S.} Fourth edition. Springer. } \seealso{ \code{\link{trmat}}, \code{\link{surf.ls}}, \code{\link{prmat}}, \code{\link{semat}}, \code{\link{expcov}}, \code{\link{gaucov}}, \code{\link{sphercov}} } \examples{ library(MASS) # for eqscplot data(topo, package="MASS") topo.kr <- surf.gls(2, expcov, topo, d=0.7) trsurf <- trmat(topo.kr, 0, 6.5, 0, 6.5, 50) eqscplot(trsurf, type = "n") contour(trsurf, add = TRUE) prsurf <- prmat(topo.kr, 0, 6.5, 0, 6.5, 50) contour(prsurf, levels=seq(700, 925, 25)) sesurf <- semat(topo.kr, 0, 6.5, 0, 6.5, 30) eqscplot(sesurf, type = "n") contour(sesurf, levels = c(22, 25), add = TRUE) } \keyword{spatial} spatial/man/surf.ls.Rd0000644000176000001440000000232211754561334014405 0ustar ripleyusers% file spatial/man/surf.ls.Rd % copyright (C) 1994-9 W. N. Venables and B. D. Ripley % \name{surf.ls} \alias{surf.ls} \title{ Fits a Trend Surface by Least-squares } \description{ Fits a trend surface by least-squares. } \usage{ surf.ls(np, x, y, z) } \arguments{ \item{np}{ degree of polynomial surface } \item{x}{ x coordinates or a data frame with columns \code{x}, \code{y}, \code{z} } \item{y}{ y coordinates } \item{z}{ z coordinates. Will supersede \code{x$z} }} \value{ list with components \item{beta}{ the coefficients } \item{x}{ } \item{y}{ } \item{z}{ and others for internal use only. }} \references{ Ripley, B. D. (1981) \emph{Spatial Statistics.} Wiley. Venables, W. N. and Ripley, B. D. (2002) \emph{Modern Applied Statistics with S.} Fourth edition. Springer. } \seealso{ \code{\link{trmat}}, \code{\link{surf.gls}} } \examples{ library(MASS) # for eqscplot data(topo, package="MASS") topo.kr <- surf.ls(2, topo) trsurf <- trmat(topo.kr, 0, 6.5, 0, 6.5, 50) eqscplot(trsurf, type = "n") contour(trsurf, add = TRUE) points(topo) eqscplot(trsurf, type = "n") contour(trsurf, add = TRUE) plot(topo.kr, add = TRUE) title(xlab= "Circle radius proportional to Cook's influence statistic") } \keyword{spatial} spatial/man/trls.influence.Rd0000644000176000001440000000406611754561334015753 0ustar ripleyusers% file spatial/man/trls.influence.Rd % copyright (C) 2001-2 W. N. Venables and B. D. Ripley % \name{trls.influence} \alias{trls.influence} \alias{plot.trls} \title{ Regression diagnostics for trend surfaces } \description{ This function provides the basic quantities which are used in forming a variety of diagnostics for checking the quality of regression fits for trend surfaces calculated by \code{surf.ls}. } \usage{ trls.influence(object) \method{plot}{trls}(x, border = "red", col = NA, pch = 4, cex = 0.6, add = FALSE, div = 8, \dots) } \arguments{ \item{object, x}{ Fitted trend surface model from \code{surf.ls} } \item{div}{ scaling factor for influence circle radii in \code{plot.trls} } \item{add}{ add influence plot to existing graphics if \code{TRUE} } \item{border, col, pch, cex, \dots}{ additional graphical parameters } } \value{ \code{trls.influence} returns a list with components: \item{r}{ raw residuals as given by \code{residuals.trls} } \item{hii}{ diagonal elements of the Hat matrix } \item{stresid}{ standardised residuals } \item{Di}{ Cook's statistic } } \references{ Unwin, D. J., Wrigley, N. (1987) Towards a general-theory of control point distribution effects in trend surface models. \emph{Computers and Geosciences,} \bold{13}, 351--355. Venables, W. N. and Ripley, B. D. (2002) \emph{Modern Applied Statistics with S.} Fourth edition. Springer. } \seealso{ \code{\link{surf.ls}}, \code{\link{influence.measures}}, \code{\link{plot.lm}} } \examples{ library(MASS) # for eqscplot data(topo, package = "MASS") topo2 <- surf.ls(2, topo) infl.topo2 <- trls.influence(topo2) (cand <- as.data.frame(infl.topo2)[abs(infl.topo2$stresid) > 1.5, ]) cand.xy <- topo[as.integer(rownames(cand)), c("x", "y")] trsurf <- trmat(topo2, 0, 6.5, 0, 6.5, 50) eqscplot(trsurf, type = "n") contour(trsurf, add = TRUE, col = "grey") plot(topo2, add = TRUE, div = 3) points(cand.xy, pch = 16, col = "orange") text(cand.xy, labels = rownames(cand.xy), pos = 4, offset = 0.5) } \keyword{spatial} spatial/man/trmat.Rd0000644000176000001440000000170411754561334014143 0ustar ripleyusers% file spatial/man/trmat.Rd % copyright (C) 1994-9 W. N. Venables and B. D. Ripley % \name{trmat} \alias{trmat} \title{ Evaluate Trend Surface over a Grid } \description{ Evaluate trend surface over a grid. } \usage{ trmat(obj, xl, xu, yl, yu, n) } \arguments{ \item{obj}{ object returned by \code{surf.ls} or \code{surf.gls} } \item{xl}{ limits of the rectangle for grid } \item{xu}{ } \item{yl}{ } \item{yu}{ } \item{n}{ use \code{n} x \code{n} grid within the rectangle }} \value{ list with components \code{x}, \code{y} and \code{z} suitable for \code{contour} and \code{image}. } \references{ Ripley, B. D. (1981) \emph{Spatial Statistics.} Wiley. Venables, W. N. and Ripley, B. D. (2002) \emph{Modern Applied Statistics with S.} Fourth edition. Springer. } \seealso{ \code{\link{surf.ls}}, \code{\link{surf.gls}} } \examples{ data(topo, package="MASS") topo.kr <- surf.ls(2, topo) trsurf <- trmat(topo.kr, 0, 6.5, 0, 6.5, 50) } \keyword{spatial} spatial/man/variogram.Rd0000644000176000001440000000231011754561334014775 0ustar ripleyusers% file spatial/man/variogram.Rd % copyright (C) 1994-9 W. N. Venables and B. D. Ripley % \name{variogram} \alias{variogram} \title{ Compute Spatial Variogram } \description{ Compute spatial (semi-)variogram of spatial data or residuals. } \usage{ variogram(krig, nint, plotit = TRUE, \dots) } \arguments{ \item{krig}{ trend-surface or kriging object with columns \code{x}, \code{y}, and \code{z} } \item{nint}{ number of bins used } \item{plotit}{ logical for plotting } \item{\dots}{ parameters for the plot }} \value{ \code{x} and \code{y} coordinates of the variogram and \code{cnt}, the number of pairs averaged per bin. } \section{Side Effects}{ Plots the variogram if \code{plotit = TRUE} } \details{ Divides range of data into \code{nint} bins, and computes the average squared difference for pairs with separation in each bin. Returns results for bins with 6 or more pairs. } \references{ Ripley, B. D. (1981) \emph{Spatial Statistics.} Wiley. Venables, W. N. and Ripley, B. D. (2002) \emph{Modern Applied Statistics with S.} Fourth edition. Springer. } \seealso{ \code{\link{correlogram}} } \examples{ data(topo, package="MASS") topo.kr <- surf.ls(2, topo) variogram(topo.kr, 25) } \keyword{spatial} spatial/po/0000755000176000001440000000000012164264315012361 5ustar ripleyusersspatial/po/R-de.po0000644000176000001440000000324112036206737013512 0ustar ripleyusers# Translation of vr/R-spatial.pot to German # Copyright (C) 2007-2012 The R Foundation # This file is distributed under the same license as the lattice R package. # Chris Leick , 2009-2012. # msgid "" msgstr "" "Project-Id-Version: R 2.15.2 / spatial 7.3-5\n" "Report-Msgid-Bugs-To: bugs@r-project.org\n" "POT-Creation-Date: 2012-09-23 17:22\n" "PO-Revision-Date: 2012-10-12 23:18+0200\n" "Last-Translator: Chris Leick \n" "Language-Team: German \n" "Language: de\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" msgid "'np' exceeds 6" msgstr "'np' überschreitet 6" msgid "'x' does not have columns 'x', 'y' and 'z'" msgstr "'x' hat keine Spalten 'x', 'y' und 'z'" msgid "some of ... do not match" msgstr "einige von … stimmen nicht überein" msgid "rank failure in Choleski decomposition" msgstr "fehlerhafter Rang in Cholesky-Zerlegung" msgid "'object' is not a fitted trend surface" msgstr "'object' ist keine angepasste Trend-Fläche" msgid "'x' and 'y' differ in length" msgstr "'x' und 'y' unterscheiden sich in der Länge voneinander." msgid "'object' not from kriging" msgstr "'objekt' nicht von Kriging" msgid "'n' is too large" msgstr "'n' ist zu groß" msgid "object not from kriging" msgstr "Objekt nicht von Kriging" msgid "Device not active" msgstr "Gerät nicht aktiv" msgid "'x' not a fitted trend surface" msgstr "'x' ist keine angepasste Trend-Fläche" msgid "some points outside region" msgstr "einige Punkte außerhalb der Region" msgid "invalid input" msgstr "ungültige Eingabe" spatial/po/R-fr.po0000644000176000001440000000327412032030324013516 0ustar ripleyusers# Translation of R-spatial.pot to French # Copyright (C) 2005 The R Foundation # This file is distributed under the same license as the spatial R package. # Philippe Grosjean , 2005. # msgid "" msgstr "" "Project-Id-Version: spatial 7.2-20\n" "Report-Msgid-Bugs-To: bugs@r-project.org\n" "POT-Creation-Date: 2012-09-23 17:22\n" "PO-Revision-Date: 2005-12-07 23:53+0100\n" "Last-Translator: Philippe Grosjean \n" "Language-Team: French \n" "Language: fr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=ISO-8859-1\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" msgid "'np' exceeds 6" msgstr "'np' dpasse 6" msgid "'x' does not have columns 'x', 'y' and 'z'" msgstr "'x' n'a pas de colonnes 'x', 'y' et 'z'" msgid "some of ... do not match" msgstr "quelques arguments de ... ne correspondent pas" msgid "rank failure in Choleski decomposition" msgstr "erreur de rang dans la dcomposition de Cholesky" msgid "'object' is not a fitted trend surface" msgstr "'object' n'est pas une surface de tendance ajuste" msgid "'x' and 'y' differ in length" msgstr "'x' et 'y' diffrent en longueur" msgid "'object' not from kriging" msgstr "'object' n'est pas issu d'un krigeage" msgid "'n' is too large" msgstr "'n' est trop large" msgid "object not from kriging" msgstr "l'objet n'est pas issu d'un krigeage" msgid "Device not active" msgstr "Le priphrique n'est pas actif" msgid "'x' not a fitted trend surface" msgstr "'x' n'est pas une surface de tendance ajuste" msgid "some points outside region" msgstr "quelques points sortent de la rgion" msgid "invalid input" msgstr "entre incorrecte" spatial/po/R-pl.po0000644000176000001440000000670012033512606013530 0ustar ripleyusersmsgid "" msgstr "" "Project-Id-Version: spatial 7.3-4\n" "Report-Msgid-Bugs-To: bugs@r-project.org\n" "POT-Creation-Date: 2012-09-23 17:22\n" "PO-Revision-Date: \n" "Last-Translator: Łukasz Daniel \n" "Language-Team: Łukasz Daniel \n" "Language: pl_PL\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "na-Revision-Date: 2012-05-29 07:55+0100\n" "Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " "|| n%100>=20) ? 1 : 2);\n" "X-Poedit-SourceCharset: iso-8859-1\n" "X-Generator: Poedit 1.5.3\n" # spatial/R/kr.R: 33 # stop("'np' exceeds 6") # spatial/R/kr.R: 73 # stop("'np' exceeds 6") msgid "'np' exceeds 6" msgstr "'np' przekracza 6" # spatial/R/kr.R: 36 # stop("'x' does not have columns 'x', 'y' and 'z'") # spatial/R/kr.R: 76 # stop("'x' does not have columns 'x', 'y' and 'z'") msgid "'x' does not have columns 'x', 'y' and 'z'" msgstr "'x' nie zawiera kolumn 'x', 'y' oraz 'z'" # spatial/R/kr.R: 90 # warning(paste("some of ... do not match")) msgid "some of ... do not match" msgstr "niektóre z ... nie pasują" # spatial/R/kr.R: 119 # stop("rank failure in Choleski decomposition") msgid "rank failure in Choleski decomposition" msgstr "niepowodzenie pozycjonowania w dekompozycji Cholesky'ego" # spatial/R/kr.R: 143 # stop("'object' is not a fitted trend surface") # spatial/R/kr.R: 158 # stop("'object' is not a fitted trend surface") # spatial/R/kr.R: 172 # stop("'object' is not a fitted trend surface") # spatial/R/kr.R: 369 # stop("'object' is not a fitted trend surface") # spatial/R/kr.R: 376 # stop("'object' is not a fitted trend surface") # spatial/R/kr.R: 383 # stop("'object' is not a fitted trend surface") # spatial/R/kr.R: 390 # stop("'object' is not a fitted trend surface") # spatial/R/kr.R: 397 # stop("'object' is not a fitted trend surface") # spatial/R/kr.R: 415 # stop("'object' is not a fitted trend surface") # spatial/R/kr.R: 445 # stop("'object' is not a fitted trend surface") # spatial/R/kr.R: 490 # stop("'object' is not a fitted trend surface") # spatial/R/kr.R: 527 # stop("'object' is not a fitted trend surface") msgid "'object' is not a fitted trend surface" msgstr "'object' nie jest dopasowaną powierzchnią trendu" # spatial/R/kr.R: 145 # stop("'x' and 'y' differ in length") msgid "'x' and 'y' differ in length" msgstr "'x' oraz 'y' różnią się długością" # spatial/R/kr.R: 207 # stop("'object' not from kriging") msgid "'object' not from kriging" msgstr "'object' nie jest z krigingu" # spatial/R/kr.R: 208 # stop("'n' is too large") # spatial/R/kr.R: 260 # stop("'n' is too large") msgid "'n' is too large" msgstr "'n' jest zbyt duże" # spatial/R/kr.R: 259 # stop("object not from kriging") msgid "object not from kriging" msgstr "'object' nie jest z krigingu" # spatial/R/kr.R: 309 # warning("Device not active") # spatial/R/kr.R: 337 # warning("Device not active") msgid "Device not active" msgstr "Urządzenie nie jest aktywne" # spatial/R/kr.R: 544 # stop("'x' not a fitted trend surface") msgid "'x' not a fitted trend surface" msgstr "'x' nie jest dopasowaną powierzchnią trendu" # spatial/R/pp.R: 36 # stop("some points outside region") msgid "some points outside region" msgstr "niektóre punkty są poza obszarem" # spatial/R/pp.R: 84 # stop("invalid input") # spatial/R/pp.R: 88 # stop("invalid input") # spatial/R/pp.R: 92 # stop("invalid input") msgid "invalid input" msgstr "niepoprawne wejście" spatial/po/R-spatial.pot0000644000176000001440000000163712034521313014736 0ustar ripleyusersmsgid "" msgstr "" "Project-Id-Version: spatial 7.3-5\n" "POT-Creation-Date: 2012-10-08 10:54\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" msgid "'np' exceeds 6" msgstr "" msgid "'x' does not have columns 'x', 'y' and 'z'" msgstr "" msgid "some of ... do not match" msgstr "" msgid "rank failure in Choleski decomposition" msgstr "" msgid "'object' is not a fitted trend surface" msgstr "" msgid "'x' and 'y' differ in length" msgstr "" msgid "'object' not from kriging" msgstr "" msgid "'n' is too large" msgstr "" msgid "object not from kriging" msgstr "" msgid "Device not active" msgstr "" msgid "'x' not a fitted trend surface" msgstr "" msgid "some points outside region" msgstr "" msgid "invalid input" msgstr "" spatial/src/0000755000176000001440000000000012164264315012532 5ustar ripleyusersspatial/src/init.c0000644000176000001440000000340712164264315013645 0ustar ripleyusers/* * spatial/src/init.c by W. N. Venables and B. D. Ripley. Copyright (C) 2002 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 or 3 of the License * (at your option). * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * A copy of the GNU General Public License is available at * http://www.r-project.org/Licenses/ * */ #include #include "spatial.h" #include "R_ext/Rdynload.h" static const R_CMethodDef CEntries[] = { {"VR_alset", (DL_FUNC) &VR_alset, 2}, {"VR_correlogram", (DL_FUNC) &VR_correlogram, 8}, {"VR_fmat", (DL_FUNC) &VR_fmat, 5}, {"VR_frset", (DL_FUNC) &VR_frset, 4}, {"VR_gls", (DL_FUNC) &VR_gls, 15}, {"VR_krpred", (DL_FUNC) &VR_krpred, 8}, {"VR_ls", (DL_FUNC) &VR_ls, 11}, {"VR_prvar", (DL_FUNC) &VR_prvar, 12}, {"VR_valn", (DL_FUNC) &VR_valn, 6}, {"VR_variogram", (DL_FUNC) &VR_variogram, 8}, {"VR_pdata", (DL_FUNC) &VR_pdata, 3}, {"VR_plike", (DL_FUNC) &VR_plike, 8}, {"VR_ppget", (DL_FUNC) &VR_ppget, 1}, {"VR_ppset", (DL_FUNC) &VR_ppset, 1}, {"VR_simmat", (DL_FUNC) &VR_simmat, 4}, {"VR_simpat", (DL_FUNC) &VR_simpat, 6}, {"VR_sp_pp2", (DL_FUNC) &VR_sp_pp2, 8}, {NULL, NULL, 0} }; #include void R_init_spatial(DllInfo *dll) { R_registerRoutines(dll, CEntries, NULL, NULL, NULL); R_useDynamicSymbols(dll, FALSE); #if defined(R_VERSION) && R_VERSION >= R_Version(2, 16, 0) R_forceSymbols(dll, TRUE); #endif } spatial/src/krc.c0000644000176000001440000004017412164264315013463 0ustar ripleyusers/* * spatial/src/krc.c by W. N. Venables and B. D. Ripley Copyright (C) 1994-2002 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 or 3 of the License * (at your option). * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * A copy of the GNU General Public License is available at * http://www.r-project.org/Licenses/ * */ #include #include "spatial.h" #ifndef max # define max(a,b) ((a) > (b) ? (a) : (b)) #endif /* defines gls ls fmat frset alset valn pred prvar correlogram variogram */ static void dscale(double, double, double *, double *); static void cholcov(double *, double *, double *, int, Sint *); static void householder(double *, double *, double *, double *, int, int, Sint *); static void chols(int, double *, double *, Sint *); static void solv(double *, double *, int, double *, double *); static void fsolv(double *, double *, int, double *); static void bsolv(double *, double *, int, double *); static void house_rhs(double *, double *, double *, int, int, double *, double *); static double val(double, double, double *, Sint *); static double *alph1 = NULL; static double xl1, xu1, yl1, yu1; void VR_alset(Sfloat *alph, Sint *nalph) { int i; if (alph1 != NULL) alph1 = Realloc(alph1, *nalph, double); else alph1 = Calloc(*nalph, double); for (i = 0; i < *nalph; ++i) alph1[i] = alph[i]; } static double powi(double x, int i) { int j; double tmp; tmp = 1.0; for (j = 1; j <= i; ++j) tmp *= x; return tmp; } static void cov(int n, double *d, int pred) { int i; double p, dd; int id; double mm; mm = alph1[0]; for (i = 0; i < n; ++i) { dd = sqrt(d[i]); id = (int) (dd / mm); p = dd / mm - id; if (pred && id == 0) p = 1; /* Preserve nugget effect on prediction */ d[i] = (1 - p) * alph1[id + 1] + p * alph1[id + 2]; } } void VR_gls(double *x, double *y, double *z, Sint *n, Sint *np, Sint *npar, double *f, double *l, double *r, double *bz, double *wz, double *yy, double *w, Sint *ifail, double *l1f) { double b[28]; Sint i, j; Sint i1; double *w1, *w2; double *lf, *nu; /* Generalized least squares (GLS) estimation of the parameters of spatial regression for observations (X,Y,Z) and regression matrix F. On output L contains the Cholesky factor of the covariance matrix of the observations, BZ the coefficients of the trend surface fitted by GLS, WZ the residuals of the observations for this fitted surface, W the product of the inverse of the Choleski factor of the covariance matrix and WZ, YY is the product of the inverse of the covariance matrix and WZ, and R the square root of the covariance matrix of BZ. NU and B hold the operations performed in the Householder decomposition of the transformed regression problem i.e. the decomposition of L1F = LF (the product of the inverse of the Cholesky factor L and the F matrix). W1 and W2 are used as workspace. Form the Cholesky decomposition of the covariance matrix */ lf = Calloc(*n * *npar, double); nu = Calloc(*n * *npar, double); w1 = Calloc(*n, double); w2 = Calloc(*n, double); cholcov(x, y, l, *n, ifail); if (*ifail > 0) return; /* Find the product of the inverse Cholesky factor and F */ for (i = 0; i < *npar; ++i) { i1 = i * (*n); for (j = 0; j < *n; ++j) w1[j] = f[j + i1]; fsolv(w2, w1, *n, l); for (j = 0; j < *n; ++j) { l1f[j + i1] = w2[j]; lf[j + i1] = w2[j]; } } /* Perform Householder orthogonalization on LF and solve transformed regression problem by least squares. */ householder(lf, nu, b, r, *n, *npar, ifail); if (*ifail > 0) return; fsolv(w1, z, *n, l); house_rhs(nu, b, r, *n, *npar, w1, bz); for (i = 0; i < *n; ++i) wz[i] = z[i] - val(x[i], y[i], bz, np); solv(yy, wz, *n, l, l); fsolv(w, wz, *n, l); Free(lf); Free(nu); Free(w1); Free(w2); } void VR_ls(double *x, double *y, double *z, Sint *n, Sint *np, Sint *npar, double *f, double *r, double *bz, double *wz, Sint *ifail) { double b[28]; Sint i, j, k; double *fw, *nu; /* Least squares estimation of parameters of spatial regression for observations (X,Y,Z) and regression matrix F. On output BZ contains the regression coefficients fitted by LS, WZ the residuals of the observations for this fitted surface and R the covariance matrix of BZ. NU and B hold the operations performed in the Householder decomposition of the regression problem i.e. the decomposition of F. Copy F matrix to FW for use in householder */ fw = Calloc(*n * *npar, double); nu = Calloc(*n * *npar, double); k = 0; for (i = 1; i <= *npar; ++i) for (j = 1; j <= *n; ++j) { fw[k] = f[k]; ++k; } householder(fw, nu, b, r, *n, *npar, ifail); if (*ifail > 0) return; house_rhs(nu, b, r, *n, *npar, z, bz); for (i = 0; i < *n; ++i) wz[i] = z[i] - val(x[i], y[i], bz, np); Free(fw); Free(nu); } /* -------------------------------------------------------------------- */ void VR_fmat(double *f, double *x, double *y, Sint *n, Sint *np) { int i, j, k, k1; double *xs, *ys; /* FMAT evaluates the 'regression' matrix F (scaled to [-1,+1]x[-1,+1] to avoid excessively large or small values) */ xs = Calloc(*n, double); ys = Calloc(*n, double); for (i = 0; i < *n; ++i) dscale(x[i], y[i], &xs[i], &ys[i]); k1 = 0; for (i = 0; i <= *np; ++i) for (j = 0; j <= *np - i; ++j) for (k = 0; k < *n; ++k) f[k1++] = powi(xs[k], j) * powi(ys[k], i); Free(xs); Free(ys); } static void cholcov(double *x, double *y, double *l, int n, Sint *ifail) { int i, j; static double *w; int i1; double t1, t2; /* Finds the Cholesky factor of the covariance matrix */ w = Calloc(n * (n + 1) / 2, double); i1 = 0; for (i = 0; i < n; ++i) for (j = 0; j <= i; ++j) { t1 = x[i] - x[j]; t2 = y[i] - y[j]; w[i1++] = t1 * t1 + t2 * t2; } cov(n * (n + 1) / 2, w, 0); chols(n, w, l, ifail); Free(w); } /* ---------------------------------------------------------------------- */ /* GENERAL PURPOSE MATRIX ROUTINES */ static void householder(double *f, double *nu, double *b, double *r, int n, int m, Sint *ifail) { int i, j, k; double c1, c2; int i1, i2, k1, k2, k3, i3; /* Finds the Householder decomposition of the NxM matrix F, F is reduced to the matrix P' = [R' 0] where R is MxM and upper triangular. The operations performed are stored in NU and B. Perform Householder decomposition (ref. Golub and Van Loan 'matrix Computations' p.40) */ *ifail = 0; for (k = 0; k < m; ++k) { k1 = k * n; k3 = k1 + k; c2 = fabs(f[k3]); for (i = k + 1; i < n; ++i) c2 = max(c2, fabs(f[i + k1])); if (c2 < 1e-6) { *ifail = k + 1; return; } c1 = 0.0; for (i = k; i < n; ++i) { k2 = k1 + i; nu[k2] = f[k2] / c2; c1 += nu[k2] * nu[k2]; } c1 = sqrt(c1); b[k] = c1 * (c1 + fabs(nu[k3])); if (nu[k3] >= 0.0) nu[k3] += c1; else nu[k3] -= c1; i1 = (k + 1) * (k + 2) / 2; i2 = k + 1; for (i = k; i < m; ++i) { i3 = i * n; c1 = 0.0; for (j = k; j < n; ++j) c1 += nu[k1 + j] * f[i3 + j]; c1 /= b[k]; r[i1 - 1] = f[i3 + k] - c1 * nu[k3]; for (j = k; j < n; ++j) f[i3 + j] -= c1 * nu[k1 + j]; i1 += i2; ++i2; } } } static void house_rhs(double *nu, double *b, double *r, int n, int m, double *z, double *beta) { int i, k; double *w; int k1; double sum; /* house_rhs is used in conjunction with householder. Once the Householder decomposition has been performed on the matrix F and the operations stored in NU and B the same operations can be performed on any rhs vector Z to give least squares estimates beta. */ w = Calloc(n, double); for (i = 0; i < n; ++i) w[i] = z[i]; for (k = 0; k < m; ++k) { sum = 0.0; k1 = k * n; for (i = k; i < n; ++i) sum += nu[i + k1] * w[i]; sum /= b[k]; for (i = k; i < n; ++i) w[i] -= sum * nu[i + k1]; } bsolv(beta, w, m, r); Free(w); } static void chols(int n, double *a, double *l, Sint *ifail) { double eps = 1e-9; int icol, irow, i, j, k, m; double w = 0.0; /* -Wall */ int i1; /* Forms Cholesky Decomposition of symmetric matrix (lower triangle stored as a vector A). L is stored in vector form to save space. Algorithm from M.J.R. Healy (1968) Applied Statistics pp. 195-197. */ /* Parameter adjustments to Fortran addressing */ --l; --a; *ifail = 1; j = 1; k = 0; for (icol = 1; icol <= n; ++icol) { i1 = 0; for (irow = 1; irow <= icol; ++irow) { ++k; w = a[k]; m = j; for (i = 1; i <= irow; ++i) { ++i1; if (i == irow) continue; if (fabs(l[i1]) < eps && fabs(l[m]) < eps) ++m; else { w -= l[i1] * l[m]; ++m; } } if (irow == icol) break; if (l[i1] == 0.0) l[k] = 0.0; else l[k] = w / l[i1]; } if (fabs(w) < fabs(a[k] * eps)) l[k] = 0.0; else { if (w <= 0.0) return; l[k] = sqrt(w); } j += icol; } for (i = 1; i <= n; ++i) { j = i * (i + 1) / 2; if (l[j] == 0.0) return; } *ifail = 0; return; } static void fsolv(double *x, double *y, int n, double *l) { int i, j, i1; double sum; /* Solves Lx = y for x by forward substitution - L lower triangular and stored as a vector. */ i1 = 0; for (i = 0; i < n; ++i) { x[i] = y[i]; sum = 0.0; for (j = 0; j < i; ++j) sum += x[j] * l[i1++]; x[i] = (x[i] - sum) / l[i1++]; } } static void bsolv(double *x, double *y, int n, double *u) { int i, j, i1, ic; double sum; /* Solves Ux = y for x by backward substitution - U upper triangular and stored as a vector. */ i1 = n * (n + 1) / 2 - 1; for (i = n - 1; i >= 0; --i) { x[i] = y[i]; sum = 0.0; ic = i1; for (j = i + 1; j < n; ++j) { ic += j; sum += x[j] * u[ic]; } x[i] = (x[i] - sum) / u[i1]; i1 -= i + 1; } } static void solv(double *x, double *y, int n, double *l, double *u) { double *w; /* Solves Ax = y where A = LU */ w = Calloc(n, double); fsolv(w, y, n, l); bsolv(x, w, n, u); Free(w); } void VR_frset(Sfloat *xl, Sfloat *xu, Sfloat *yl, Sfloat *yu) { xl1 = *xl; yl1 = *yl; xu1 = *xu; yu1 = *yu; } static void dscale(double xo, double yo, double *xs, double *ys) { double xl2, yl2; /* Scales (xo, yo) to (xs, ys) ( -1 < xs, ys < 1 ) */ xl2 = (xu1 + xl1) / 2; yl2 = (yu1 + yl1) / 2; *xs = (xo - xl2) / (xu1 - xl2); *ys = (yo - yl2) / (yu1 - yl2); } /* ----------------------------------------------------- */ /* VARIANCE/COVARIANCE,PREDICTION AND STANDARD ERROR ROUTINES */ static double val(double xp, double yp, double *beta, Sint *np) { int i, j, i1; double xs, ys, sum; /* Evaluates the fitted surface at the point (XP,YP) for coeffs BETA */ dscale(xp, yp, &xs, &ys); sum = 0.0; i1 = 0; for (i = 0; i <= *np; ++i) for (j = 0; j <= *np - i; ++j) sum += beta[i1++] * powi(xs, j) * powi(ys, i); return sum; } void VR_valn(double *z, double *x, double *y, Sint *n, double *beta, Sint *np) { int i, j, i1; int it; double xp, yp, xs, ys, sum; /* Evaluates the fitted surface at the point (XP,YP) for coeffs BETA */ for (it = 0; it < *n; ++it) { xp = x[it]; yp = y[it]; dscale(xp, yp, &xs, &ys); sum = 0.0; i1 = 0; for (i = 0; i <= *np; ++i) for (j = 0; j <= *np - i; ++j) sum += beta[i1++] * powi(xs, j) * powi(ys, i); z[it] = sum; } } void VR_krpred(double *z, double *xs, double *ys, double *x, double *y, Sint *npt, Sint *n, double *yy) { double *d; int i; double t1, t2; int it; double xp, yp; double sum; /* Gives value of interpolator at the point (XP,YP) */ d = Calloc(*n, double); for (it = 0; it < *npt; ++it) { xp = xs[it]; yp = ys[it]; sum = 0.0; for (i = 0; i < *n; ++i) { t1 = x[i] - xp; t2 = y[i] - yp; d[i] = t1 * t1 + t2 * t2; } cov(*n, d, 1); for (i = 0; i < *n; ++i) { sum += yy[i] * d[i]; } z[it] = sum; } Free(d); } void VR_prvar(double *z, double *xp, double *yp, Sint *npt, double *x, double *y, double *l, double *r, Sint *n, Sint *np, Sint *npar, double *l1f) { int i, j, k, i1, k1, it; double *w1, *w2; double xs, ys, xd, yd; double sum, sum1; /* Evaluates prediction variance at (XP,YP) */ w1 = Calloc(*n, double); w2 = Calloc(*n, double); for (it = 0; it < *npt; ++it) { for (i = 0; i < *n; ++i) { xd = x[i] - xp[it]; yd = y[i] - yp[it]; w1[i] = xd * xd + yd * yd; } cov(*n, w1, 1); fsolv(w2, w1, *n, l); sum1 = 0.0; for (i = 0; i < *n; ++i) sum1 += w2[i] * w2[i]; sum1 = alph1[1] - sum1; dscale(xp[it], yp[it], &xs, &ys); k1 = 0; i1 = 0; for (i = 0; i <= *np; ++i) for (j = 0; j <= *np - i; ++j) { ++i1; w1[i1 - 1] = powi(xs, j) * powi(ys, i); for (k = 0; k < *n; ++k) w1[i1 - 1] -= l1f[k1++] * w2[k]; } fsolv(w2, w1, *npar, r); sum = 0.0; for (i = 0; i < *npar; ++i) sum += w2[i] * w2[i]; z[it] = sum1 + sum; } Free(w1); Free(w2); } /* --------------------------------------------------------------------- */ /* CORRELOGRAM AND VARIOGRAM ROUTINES */ void VR_correlogram(Sfloat *xp, Sfloat *yp, Sint *nint, double *x, double *y, double *z, Sint *n, Sint *cnt) { double xd, yd, d, sc, zb, xm, var, sum; int i, j, i1, ibin; double *cp; int *ncp; /* Correlogram for the observations (X,Y,Z). CP holds the empirical correlation for the NINT intervals based on the NCP observations in each interval. XM defines the upper limit on the x axis. */ cp = Calloc(*nint + 1, double); ncp = Calloc(*nint + 1, int); zb = 0.0; for (i = 0; i < *n; ++i) { zb += z[i]; } zb /= *n; for (i = 0; i < *nint; ++i) { ncp[i] = 0; cp[i] = 0.0; } xm = 0.0; for (i = 0; i < *n; ++i) { for (j = 0; j < i; ++j) { xd = x[i] - x[j]; yd = y[i] - y[j]; d = xd * xd + yd * yd; xm = max(xm, d); } } sc = (*nint - 1) / sqrt(xm); for (i = 0; i < *n; ++i) { for (j = 0; j <= i; ++j) { xd = x[i] - x[j]; yd = y[i] - y[j]; d = sqrt(xd * xd + yd * yd); ibin = (int) (sc * d); ++ncp[ibin]; cp[ibin] += (z[i] - zb) * (z[j] - zb); } } sum = 0.0; for (i = 0; i < *n; ++i) { xd = z[i] - zb; sum += xd * xd; } var = sum / *n; /* Only return values for fairly reliable intervals */ i1 = 0; for (i = 0; i < *nint; ++i) { if (ncp[i] > 5) { xp[i1] = i / sc; yp[i1] = cp[i] / (var * ncp[i]); cnt[i1] = ncp[i]; i1++; } } *nint = i1; Free(cp); Free(ncp); } void VR_variogram(Sfloat *xp, Sfloat *yp, Sint *nint, double *x, double *y, double *z, Sint *n, Sint *cnt) { double xd, yd, d, sc, xm; int ibin, i, j, i1; double *sv; int *nsv; /* Variogram for the observations (X,Y,Z). SV holds the empirical semi-variance for the NINT intervals based on the NSV observations in each interval. */ sv = Calloc(*nint + 1, double); nsv = Calloc(*nint + 1, int); for (i = 0; i < *nint; ++i) { nsv[i] = 0; sv[i] = 0.0; } xm = 0.0; for (i = 0; i < *n; ++i) { for (j = 0; j < i; ++j) { xd = x[i] - x[j]; yd = y[i] - y[j]; d = xd * xd + yd * yd; xm = max(xm, d); } } sc = (*nint - 1) / sqrt(xm); for (i = 0; i < *n; ++i) { for (j = 0; j < i; ++j) { xd = x[i] - x[j]; yd = y[i] - y[j]; d = sqrt(xd * xd + yd * yd); ibin = (int) (sc * d); ++nsv[ibin]; xd = z[i] - z[j]; sv[ibin] += xd * xd; } } i1 = 0; for (i = 0; i < *nint; ++i) { if (nsv[i] > 5) { xp[i1] = i / sc; yp[i1] = sv[i] / (2 * nsv[i]); cnt[i1] = nsv[i]; i1++; } } *nint = i1; Free(sv); Free(nsv); } spatial/src/pps.c0000644000176000001440000001264612164264315013511 0ustar ripleyusers/* * spatial/src/pps.c by W. N. Venables and B. D. Ripley. Copyright (C) 1994-2002 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 or 3 of the License * (at your option). * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * A copy of the GNU General Public License is available at * http://www.r-project.org/Licenses/ * */ #include #include /* for M_PI */ #define RANDIN GetRNGstate() #define RANDOUT PutRNGstate() #define UNIF unif_rand() #include "spatial.h" #ifndef max # define max(a,b) ((a) > (b) ? (a) : (b)) # define min(a,b) ((a) < (b) ? (a) : (b)) #endif static Sfloat xl0, yl0, xu0, yu0; static void testinit(void) { if ((xu0 == xl0) || (yu0 == yl0)) error("not initialized -- use ppregion"); } void VR_ppset(Sfloat *area) { xl0 = *area++; xu0 = *area++; yl0 = *area++; yu0 = *area; testinit(); } void VR_ppget(Sfloat *xx) { Sfloat *z = xx; testinit(); *z++ = xl0; *z++ = xu0; *z++ = yl0; *z++ = yu0; } static Sfloat edge(Sfloat x, Sfloat y, Sfloat a) { Sfloat b, c, c1, c2, r[6], w; int i; w = x - xl0; if (w > y - yl0) w = y - yl0; if (w > xu0 - x) w = xu0 - x; if (w > yu0 - y) w = yu0 - y; if (a <= w) return (0.5); r[4] = r[0] = x - xl0; r[5] = r[1] = yu0 - y; r[2] = xu0 - x; r[3] = y - yl0; b = 0.0; for (i = 1; i <= 4; i++) if (r[i] < a) { if (r[i] == 0.0) b += M_PI; else { c = acos(r[i] / a); c1 = atan(r[i - 1] / r[i]); c2 = atan(r[i + 1] / r[i]); b += min(c, c1); b += min(c, c2); } } if (b < 6.28) return (1.0 / (2.0 - b / M_PI)); return (0.0); } void VR_sp_pp2(Sfloat *x, Sfloat *y, Sint *npt, Sint *k, Sfloat *h, Sfloat *dmin, Sfloat *lm, Sfloat *fs) { int n = *npt, kk = *k, k1, i, j, ib; Sfloat ax, ay, xi, yi, sarea, g, dm, alm; double a, x1, y1, rr, fss = *fs, fs1, s1; testinit(); ax = xu0 - xl0; ay = yu0 - yl0; sarea = sqrt(ax * ay); dm = fss; g = 2.0 / (n * n); fs1 = min(fss, 0.5 * sqrt(ax * ax + ay * ay)); s1 = kk / fss; k1 = (int) floor(s1 * fs1 + 1e-3); *k = k1; rr = fs1 * fs1; for (i = 0; i < kk; i++) h[i] = 0.0; for (i = 1; i < n; i++) { xi = x[i]; yi = y[i]; for (j = 0; j < i; j++) { x1 = x[j] - xi; y1 = y[j] - yi; a = x1 * x1 + y1 * y1; if (a < rr) { a = sqrt(a); dm = min(a, dm); ib = (int) floor(s1 * a); if (ib < k1) h[ib] += g * (edge(xi, yi, a) + edge(x[j], y[j], a)); } } } a = 0.0; alm = 0.0; for (i = 0; i < k1; i++) { a += h[i]; h[i] = sqrt(a / M_PI) * sarea; alm = max(alm, fabs(h[i] - (i + 1) / s1)); } *dmin = dm; *lm = alm; } void VR_pdata(Sint *npt, Sfloat *x, Sfloat *y) { int i; Sfloat ax, ay; testinit(); ax = xu0 - xl0; ay = yu0 - yl0; RANDIN; for (i = 0; i < *npt; i++) { x[i] = xl0 + ax * UNIF; y[i] = yl0 + ay * UNIF; } RANDOUT; } void VR_simpat(Sint *npt, Sfloat *x, Sfloat *y, Sfloat *c, Sfloat *r, Sint *init) { int i, attempts = 0, id, j, mm, n = *npt; Sfloat cc, rr, ax, ay, d, x1, y1, u; testinit(); cc = *c; if (cc >= 1.0) { VR_pdata(npt, x, y); return; } RANDIN; ax = xu0 - xl0; ay = yu0 - yl0; rr = (*r) * (*r); mm = 4 * n; if (*init > 0) mm = 10 * mm; for (i = 1; i <= mm; i++) { id = (int) floor(n * UNIF); x[id] = x[0]; y[id] = y[0]; do { attempts++; x[0] = xl0 + ax * UNIF; y[0] = yl0 + ay * UNIF; u = UNIF; d = 1.0; for (j = 1; j < n; j++) { x1 = x[j] - x[0]; y1 = y[j] - y[0]; if (x1 * x1 + y1 * y1 < rr) { d *= cc; if (d < u) continue; } } if(attempts % 1000 == 0) R_CheckUserInterrupt(); } while (d < u); } RANDOUT; } void VR_simmat(Sint *npt, Sfloat *x, Sfloat *y, Sfloat *r) { int i, icnt, attempts = 0, j, n = *npt; Sfloat x1, y1, rr, ax, ay; testinit(); RANDIN; ax = xu0 - xl0; ay = yu0 - yl0; rr = (*r) * (*r); for (i = 0; i < n; i++) { do { attempts++; icnt = 0; x[i] = xl0 + ax * UNIF; y[i] = yl0 + ay * UNIF; if (i > 0) for (j = 0; j < i; j++) { x1 = x[i] - x[j]; y1 = y[i] - y[j]; if (x1 * x1 + y1 * y1 < rr) { icnt = 1; break; } } if(attempts % 1000 == 0) R_CheckUserInterrupt(); } while (icnt > 0); } RANDOUT; } void VR_plike(Sfloat *x, Sfloat *y, Sint *npt, Sfloat *c, Sfloat *r, Sint *ng, Sfloat *target, Sfloat *res) { Sfloat ar, rr, suma = 0, sumb = 0, xi, yi, x1, y1, c1, cc = *c; int ic, i1, i2, j, n = *npt, g = *ng; testinit(); ar = (*r); rr = ar * ar; if (cc <= 0) { *res = -*target; return; } for (i1 = 0; i1 < g; i1++) { xi = xl0 + ar + (xu0 - xl0 - 2 * ar) * i1 / (g - 1); for (i2 = 0; i2 < g; i2++) { yi = yl0 + ar + (yu0 - yl0 - 2 * ar) * i2 / (g - 1); ic = 0; for (j = 0; j < n; j++) { x1 = x[j] - xi; y1 = y[j] - yi; if (x1 * x1 + y1 * y1 < rr) ic += 1; } c1 = (ic > 0) ? pow(cc, (double) ic) : 1; suma += ic * c1; sumb += c1; } } *res = suma / sumb - *target; } spatial/src/spatial.h0000644000176000001440000000305012164264315014336 0ustar ripleyusersvoid VR_alset(Sfloat *alph, Sint *nalph); void VR_gls(double *x, double *y, double *z, Sint *n, Sint *np, Sint *npar, double *f, double *l, double *r, double *bz, double *wz, double *yy, double *w, Sint *ifail, double *l1f); void VR_ls(double *x, double *y, double *z, Sint *n, Sint *np, Sint *npar, double *f, double *r, double *bz, double *wz, Sint *ifail); void VR_fmat(double *f, double *x, double *y, Sint *n, Sint *np); void VR_frset(Sfloat *xl, Sfloat *xu, Sfloat *yl, Sfloat *yu); void VR_valn(double *z, double *x, double *y, Sint *n, double *beta, Sint *np); void VR_krpred(double *z, double *xs, double *ys, double *x, double *y, Sint *npt, Sint *n, double *yy); void VR_prvar(double *z, double *xp, double *yp, Sint *npt, double *x, double *y, double *l, double *r, Sint *n, Sint *np, Sint *npar, double *l1f); void VR_correlogram(Sfloat *xp, Sfloat *yp, Sint *nint, double *x, double *y, double *z, Sint *n, Sint *cnt); void VR_variogram(Sfloat *xp, Sfloat *yp, Sint *nint, double *x, double *y, double *z, Sint *n, Sint *cnt); void VR_ppset(Sfloat *area); void VR_ppget(Sfloat *xx); void VR_sp_pp2(Sfloat *x, Sfloat *y, Sint *npt, Sint *k, Sfloat *h, Sfloat *dmin, Sfloat *lm, Sfloat *fs); void VR_pdata(Sint *npt, Sfloat *x, Sfloat *y); void VR_simpat(Sint *npt, Sfloat *x, Sfloat *y, Sfloat *c, Sfloat *r, Sint *init); void VR_simmat(Sint *npt, Sfloat *x, Sfloat *y, Sfloat *r); void VR_plike(Sfloat *x, Sfloat *y, Sint *npt, Sfloat *c, Sfloat *r, Sint *ng, Sfloat *target, Sfloat *res); spatial/tests/0000755000176000001440000000000011754561334013112 5ustar ripleyusersspatial/tests/Examples/0000755000176000001440000000000012164264315014663 5ustar ripleyusersspatial/tests/Examples/spatial-Ex.Rout.save0000644000176000001440000002747512105705417020517 0ustar ripleyusers R Under development (unstable) (2013-02-09 r61878) -- "Unsuffered Consequences" Copyright (C) 2013 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: x86_64-unknown-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > pkgname <- "spatial" > source(file.path(R.home("share"), "R", "examples-header.R")) > options(warn = 1) > library('spatial') > > base::assign(".oldSearch", base::search(), pos = 'CheckExEnv') > cleanEx() > nameEx("Kaver") > ### * Kaver > > flush(stderr()); flush(stdout()) > > ### Name: Kaver > ### Title: Average K-functions from Simulations > ### Aliases: Kaver > ### Keywords: spatial > > ### ** Examples > > towns <- ppinit("towns.dat") > par(pty="s") > plot(Kfn(towns, 40), type="b") > plot(Kfn(towns, 10), type="b", xlab="distance", ylab="L(t)") > for(i in 1:10) lines(Kfn(Psim(69), 10)) > lims <- Kenvl(10,100,Psim(69)) > lines(lims$x,lims$lower, lty=2, col="green") > lines(lims$x,lims$upper, lty=2, col="green") > lines(Kaver(10,25,Strauss(69,0.5,3.5)), col="red") > > > > graphics::par(get("par.postscript", pos = 'CheckExEnv')) > cleanEx() > nameEx("Kenvl") > ### * Kenvl > > flush(stderr()); flush(stdout()) > > ### Name: Kenvl > ### Title: Compute Envelope and Average of Simulations of K-fns > ### Aliases: Kenvl > ### Keywords: spatial > > ### ** Examples > > towns <- ppinit("towns.dat") > par(pty="s") > plot(Kfn(towns, 40), type="b") > plot(Kfn(towns, 10), type="b", xlab="distance", ylab="L(t)") > for(i in 1:10) lines(Kfn(Psim(69), 10)) > lims <- Kenvl(10,100,Psim(69)) > lines(lims$x,lims$lower, lty=2, col="green") > lines(lims$x,lims$upper, lty=2, col="green") > lines(Kaver(10,25,Strauss(69,0.5,3.5)), col="red") > > > > graphics::par(get("par.postscript", pos = 'CheckExEnv')) > cleanEx() > nameEx("Kfn") > ### * Kfn > > flush(stderr()); flush(stdout()) > > ### Name: Kfn > ### Title: Compute K-fn of a Point Pattern > ### Aliases: Kfn > ### Keywords: spatial > > ### ** Examples > > towns <- ppinit("towns.dat") > par(pty="s") > plot(Kfn(towns, 10), type="s", xlab="distance", ylab="L(t)") > > > > graphics::par(get("par.postscript", pos = 'CheckExEnv')) > cleanEx() > nameEx("Psim") > ### * Psim > > flush(stderr()); flush(stdout()) > > ### Name: Psim > ### Title: Simulate Binomial Spatial Point Process > ### Aliases: Psim > ### Keywords: spatial > > ### ** Examples > > towns <- ppinit("towns.dat") > par(pty="s") > plot(Kfn(towns, 10), type="s", xlab="distance", ylab="L(t)") > for(i in 1:10) lines(Kfn(Psim(69), 10)) > > > > graphics::par(get("par.postscript", pos = 'CheckExEnv')) > cleanEx() > nameEx("SSI") > ### * SSI > > flush(stderr()); flush(stdout()) > > ### Name: SSI > ### Title: Simulates Sequential Spatial Inhibition Point Process > ### Aliases: SSI > ### Keywords: spatial > > ### ** Examples > > towns <- ppinit("towns.dat") > par(pty = "s") > plot(Kfn(towns, 10), type = "b", xlab = "distance", ylab = "L(t)") > lines(Kaver(10, 25, SSI(69, 1.2))) > > > > graphics::par(get("par.postscript", pos = 'CheckExEnv')) > cleanEx() > nameEx("Strauss") > ### * Strauss > > flush(stderr()); flush(stdout()) > > ### Name: Strauss > ### Title: Simulates Strauss Spatial Point Process > ### Aliases: Strauss > ### Keywords: spatial > > ### ** Examples > > towns <- ppinit("towns.dat") > par(pty="s") > plot(Kfn(towns, 10), type="b", xlab="distance", ylab="L(t)") > lines(Kaver(10, 25, Strauss(69,0.5,3.5))) > > > > graphics::par(get("par.postscript", pos = 'CheckExEnv')) > cleanEx() > nameEx("anova.trls") > ### * anova.trls > > flush(stderr()); flush(stdout()) > > ### Name: anova.trls > ### Title: Anova tables for fitted trend surface objects > ### Aliases: anova.trls anovalist.trls > ### Keywords: spatial > > ### ** Examples > > library(stats) > data(topo, package="MASS") > topo0 <- surf.ls(0, topo) > topo1 <- surf.ls(1, topo) > topo2 <- surf.ls(2, topo) > topo3 <- surf.ls(3, topo) > topo4 <- surf.ls(4, topo) > anova(topo0, topo1, topo2, topo3, topo4) Analysis of Variance Table Model 1: surf.ls(np = 0, x = topo) Model 2: surf.ls(np = 1, x = topo) Model 3: surf.ls(np = 2, x = topo) Model 4: surf.ls(np = 3, x = topo) Model 5: surf.ls(np = 4, x = topo) Res.Df Res.Sum Sq Df Sum Sq F value Pr(>F) 1 51 196030 2 49 67186 2 128844 46.9843 4.040e-12 3 46 39958 3 27228 10.4482 2.325e-05 4 42 21577 4 18381 8.9447 2.558e-05 5 37 14886 5 6691 3.3265 0.014 > summary(topo4) Analysis of Variance Table Model: surf.ls(np = 4, x = topo) Sum Sq Df Mean Sq F value Pr(>F) Regression 181144.0 14 12938.8567 32.16092 2.2204e-16 Deviation 14885.7 37 402.3162 Total 196029.7 51 Multiple R-Squared: 0.9241, Adjusted R-squared: 0.8953 AIC: (df = 15) 324.1594 Fitted: Min 1Q Median 3Q Max 702.1 785.0 836.3 880.5 939.1 Residuals: Min 1Q Median 3Q Max -34.077 -12.568 -2.085 14.056 50.161 > > > > cleanEx() > nameEx("correlogram") > ### * correlogram > > flush(stderr()); flush(stdout()) > > ### Name: correlogram > ### Title: Compute Spatial Correlograms > ### Aliases: correlogram > ### Keywords: spatial > > ### ** Examples > > data(topo, package="MASS") > topo.kr <- surf.ls(2, topo) > correlogram(topo.kr, 25) > d <- seq(0, 7, 0.1) > lines(d, expcov(d, 0.7)) > > > > cleanEx() > nameEx("expcov") > ### * expcov > > flush(stderr()); flush(stdout()) > > ### Name: expcov > ### Title: Spatial Covariance Functions > ### Aliases: expcov gaucov sphercov > ### Keywords: spatial > > ### ** Examples > > data(topo, package="MASS") > topo.kr <- surf.ls(2, topo) > correlogram(topo.kr, 25) > d <- seq(0, 7, 0.1) > lines(d, expcov(d, 0.7)) > > > > cleanEx() > nameEx("ppinit") > ### * ppinit > > flush(stderr()); flush(stdout()) > > ### Name: ppinit > ### Title: Read a Point Process Object from a File > ### Aliases: ppinit > ### Keywords: spatial > > ### ** Examples > > towns <- ppinit("towns.dat") > par(pty="s") > plot(Kfn(towns, 10), type="b", xlab="distance", ylab="L(t)") > > > > graphics::par(get("par.postscript", pos = 'CheckExEnv')) > cleanEx() > nameEx("pplik") > ### * pplik > > flush(stderr()); flush(stdout()) > > ### Name: pplik > ### Title: Pseudo-likelihood Estimation of a Strauss Spatial Point Process > ### Aliases: pplik > ### Keywords: spatial > > ### ** Examples > > pines <- ppinit("pines.dat") > pplik(pines, 0.7) [1] 0.1508756 > > > > cleanEx() > nameEx("predict.trls") > ### * predict.trls > > flush(stderr()); flush(stdout()) > > ### Name: predict.trls > ### Title: Predict method for trend surface fits > ### Aliases: predict.trls > ### Keywords: spatial > > ### ** Examples > > data(topo, package="MASS") > topo2 <- surf.ls(2, topo) > topo4 <- surf.ls(4, topo) > x <- c(1.78, 2.21) > y <- c(6.15, 6.15) > z2 <- predict(topo2, x, y) > z4 <- predict(topo4, x, y) > cat("2nd order predictions:", z2, "\n4th order predictions:", z4, "\n") 2nd order predictions: 756.0682 747.0624 4th order predictions: 765.5547 742.3738 > > > > cleanEx() > nameEx("prmat") > ### * prmat > > flush(stderr()); flush(stdout()) > > ### Name: prmat > ### Title: Evaluate Kriging Surface over a Grid > ### Aliases: prmat > ### Keywords: spatial > > ### ** Examples > > data(topo, package="MASS") > topo.kr <- surf.gls(2, expcov, topo, d=0.7) > prsurf <- prmat(topo.kr, 0, 6.5, 0, 6.5, 50) > contour(prsurf, levels=seq(700, 925, 25)) > > > > cleanEx() > nameEx("semat") > ### * semat > > flush(stderr()); flush(stdout()) > > ### Name: semat > ### Title: Evaluate Kriging Standard Error of Prediction over a Grid > ### Aliases: semat > ### Keywords: spatial > > ### ** Examples > > data(topo, package="MASS") > topo.kr <- surf.gls(2, expcov, topo, d=0.7) > prsurf <- prmat(topo.kr, 0, 6.5, 0, 6.5, 50) > contour(prsurf, levels=seq(700, 925, 25)) > sesurf <- semat(topo.kr, 0, 6.5, 0, 6.5, 30) > contour(sesurf, levels=c(22,25)) > > > > cleanEx() > nameEx("surf.gls") > ### * surf.gls > > flush(stderr()); flush(stdout()) > > ### Name: surf.gls > ### Title: Fits a Trend Surface by Generalized Least-squares > ### Aliases: surf.gls > ### Keywords: spatial > > ### ** Examples > > library(MASS) # for eqscplot > data(topo, package="MASS") > topo.kr <- surf.gls(2, expcov, topo, d=0.7) > trsurf <- trmat(topo.kr, 0, 6.5, 0, 6.5, 50) > eqscplot(trsurf, type = "n") > contour(trsurf, add = TRUE) > > prsurf <- prmat(topo.kr, 0, 6.5, 0, 6.5, 50) > contour(prsurf, levels=seq(700, 925, 25)) > sesurf <- semat(topo.kr, 0, 6.5, 0, 6.5, 30) > eqscplot(sesurf, type = "n") > contour(sesurf, levels = c(22, 25), add = TRUE) > > > > cleanEx() detaching ‘package:MASS’ > nameEx("surf.ls") > ### * surf.ls > > flush(stderr()); flush(stdout()) > > ### Name: surf.ls > ### Title: Fits a Trend Surface by Least-squares > ### Aliases: surf.ls > ### Keywords: spatial > > ### ** Examples > > library(MASS) # for eqscplot > data(topo, package="MASS") > topo.kr <- surf.ls(2, topo) > trsurf <- trmat(topo.kr, 0, 6.5, 0, 6.5, 50) > eqscplot(trsurf, type = "n") > contour(trsurf, add = TRUE) > points(topo) > > eqscplot(trsurf, type = "n") > contour(trsurf, add = TRUE) > plot(topo.kr, add = TRUE) > title(xlab= "Circle radius proportional to Cook's influence statistic") > > > > cleanEx() detaching ‘package:MASS’ > nameEx("trls.influence") > ### * trls.influence > > flush(stderr()); flush(stdout()) > > ### Name: trls.influence > ### Title: Regression diagnostics for trend surfaces > ### Aliases: trls.influence plot.trls > ### Keywords: spatial > > ### ** Examples > > library(MASS) # for eqscplot > data(topo, package = "MASS") > topo2 <- surf.ls(2, topo) > infl.topo2 <- trls.influence(topo2) > (cand <- as.data.frame(infl.topo2)[abs(infl.topo2$stresid) > 1.5, ]) r hii stresid Di 1 61.21889 0.35476783 2.585852 0.61275133 4 -45.58507 0.13493260 -1.662930 0.07188916 12 44.71663 0.21022336 1.707234 0.12930392 31 52.05575 0.07154233 1.833006 0.04314966 37 54.75944 0.06974770 1.926349 0.04637112 48 97.75499 0.08574061 3.468809 0.18807312 50 -63.25149 0.27530059 -2.520972 0.40237779 > cand.xy <- topo[as.integer(rownames(cand)), c("x", "y")] > trsurf <- trmat(topo2, 0, 6.5, 0, 6.5, 50) > eqscplot(trsurf, type = "n") > contour(trsurf, add = TRUE, col = "grey") > plot(topo2, add = TRUE, div = 3) > points(cand.xy, pch = 16, col = "orange") > text(cand.xy, labels = rownames(cand.xy), pos = 4, offset = 0.5) > > > > cleanEx() detaching ‘package:MASS’ > nameEx("trmat") > ### * trmat > > flush(stderr()); flush(stdout()) > > ### Name: trmat > ### Title: Evaluate Trend Surface over a Grid > ### Aliases: trmat > ### Keywords: spatial > > ### ** Examples > > data(topo, package="MASS") > topo.kr <- surf.ls(2, topo) > trsurf <- trmat(topo.kr, 0, 6.5, 0, 6.5, 50) > > > > cleanEx() > nameEx("variogram") > ### * variogram > > flush(stderr()); flush(stdout()) > > ### Name: variogram > ### Title: Compute Spatial Variogram > ### Aliases: variogram > ### Keywords: spatial > > ### ** Examples > > data(topo, package="MASS") > topo.kr <- surf.ls(2, topo) > variogram(topo.kr, 25) > > > > ### *