spatial/0000755000176000001440000000000014167756472011762 5ustar ripleyusersspatial/NAMESPACE0000644000176000001440000000126112544221020013146 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, abline, plot, points, symbols) importFrom(stats, anova, deviance, df.residual, extractAIC, fitted, pf, predict, quantile, residuals, var) 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/LICENCE.note0000644000176000001440000000314414036521070013670 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 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 https://www.r-project.org/Licenses/ Bill.Venables@gmail.com ripley@stats.ox.ac.uk spatial/man/0000755000176000001440000000000012131311463012505 5ustar ripleyusersspatial/man/prmat.Rd0000644000176000001440000000200311754562035014127 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/predict.trls.Rd0000644000176000001440000000225111754562035015426 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/Kfn.Rd0000644000176000001440000000235211754562035013531 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/semat.Rd0000644000176000001440000000241711754562035014126 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/Psim.Rd0000644000176000001440000000157711754562035013733 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/ppregion.Rd0000644000176000001440000000145311754562035014637 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/Kaver.Rd0000644000176000001440000000214211754562035014060 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/variogram.Rd0000644000176000001440000000231011754562035014774 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/man/Strauss.Rd0000644000176000001440000000227511754562035014463 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/ppgetregion.Rd0000644000176000001440000000113411754562035015333 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/surf.gls.Rd0000644000176000001440000000323111754562035014553 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.Rd0000644000176000001440000000232211754562035014404 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/correlogram.Rd0000644000176000001440000000241411754562035015326 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.Rd0000644000176000001440000000200611754562035014313 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/Kenvl.Rd0000644000176000001440000000225511754562035014074 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/SSI.Rd0000644000176000001440000000204211754562035013445 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/pplik.Rd0000644000176000001440000000167711754562035014143 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/anova.trls.Rd0000644000176000001440000000222011754562035015074 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/trls.influence.Rd0000644000176000001440000000406611754562035015752 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.Rd0000644000176000001440000000170411754562035014142 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/ppinit.Rd0000644000176000001440000000164611754562035014323 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/DESCRIPTION0000644000176000001440000000150214167756472013466 0ustar ripleyusersPackage: spatial Priority: recommended Version: 7.3-15 Date: 2022-01-12 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"), person("William", "Venables", role = "cph")) 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/ NeedsCompilation: yes Packaged: 2022-01-13 05:06:39 UTC; ripley Author: Brian Ripley [aut, cre, cph], Roger Bivand [ctb], William Venables [cph] Maintainer: Brian Ripley Repository: CRAN Date/Publication: 2022-01-13 08:05:14 UTC spatial/tests/0000755000176000001440000000000012131311463013074 5ustar ripleyusersspatial/tests/Examples/0000755000176000001440000000000012131311463014652 5ustar ripleyusersspatial/tests/Examples/spatial-Ex.Rout.save0000644000176000001440000002747512105707404020515 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) > > > > ### *