R Under development (unstable) (2025-08-21 r88668 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 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. 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. > library(lgcp) Welcome to 'lgcp': Log-Gaussian Cox Process B. M. Taylor & T. M. Davies & B. S. Rowlingson & P. J. Diggle. Type '?lgcp' for details. Type 'lgcpvignette()' to view the basic package vignette. Type 'lgcpbayes()' to view the Bayesian package vignette. Type 'citation("lgcp")' to view the citation for this package. Please see the lgcp package NEWS file for latest additions, changes and bug fixes. Note, RandomFields covariance functions are currently unavailable. > library(spatstat.explore) Loading required package: spatstat.data Loading required package: spatstat.univar spatstat.univar 3.1-4 Loading required package: spatstat.geom spatstat.geom 3.5-0 Loading required package: spatstat.random spatstat.random 3.4-1 Loading required package: nlme spatstat.explore 3.5-2 > library(sp) > > polylist <- list() > # a pentagon > vert1 <- t(sapply((0:4)*(2*pi/5),function(theta){return(5*c(cos(theta),sin(theta)))})) > vert1 <- rbind(vert1,vert1[1,]) > polylist[[1]] <- Polygons(list(Polygon(vert1)),ID="1") > > # a diamond shape > vert2 <- matrix(c(-8,-10,-12,-10,0,2,0,-2),4,2) > vert2 <- rbind(vert2,vert2[1,]) > polylist[[2]] <- Polygons(list(Polygon(vert2)),ID="2") > > # a square with a rectangular hole > vert3 <- matrix(c(0,0,2,2,-10,-12,-12,-10),4,2) > vert3 <- rbind(vert3,vert3[1,]) > vert4 <- matrix(c(0.25,0.75,0.75,0.25,-10.5,-10.5,-11.5,-11.5),4,2) > vert4 <- rbind(vert4,vert4[1,]) > polylist[[3]] <- Polygons(list(Polygon(vert3),Polygon(vert4,hole=TRUE)),ID="3") > > > sP <- SpatialPolygons(polylist) > > df <- data.frame(list(atrisk=c(1,2,3))) > > spdf <- SpatialPolygonsDataFrame(sP,df) > > sar <- spatialAtRisk(spdf) > sar $atrisk [1] 0.002803899 0.041666667 0.125000000 $spdf class : SpatialPolygonsDataFrame features : 3 extent : -12, 5, -12, 4.755283 (xmin, xmax, ymin, ymax) crs : NA variables : 1 names : atrisk min values : 0.00280389926463538 max values : 0.125 attr(,"class") [1] "fromSPDF" "spatialAtRisk" attr(,"NC") [1] 356.6462 48.0000 24.0000 > > rotsar <- affine(sar,mat=rotmat(pi/6)) > > # Now test simulation code: > #sim <- lgcpSim(affine(owin(poly=list(x=c(-15,-15,5,5),y=c(5,-15,-15,5))),rotmat(pi/6)),model.parameters=lgcppars(sigma=2,phi=1,theta=3),cellwidth=0.2,spatial.intensity=affine(sar,rotmat(pi/6)),temporal.intensity=function(x){100},plot=TRUE) > #sim <- lgcpSim(owin(poly=list(x=c(-15,-15,5,5),y=c(5,-15,-15,5))),model.parameters=lgcppars(sigma=2,phi=1,theta=3),cellwidth=0.2,spatial.intensity=sar,temporal.intensity=function(x){100},plot=TRUE) > > > proc.time() user system elapsed 8.79 0.60 9.40