Dear R-help list, I'm using the excellent spatstat package to fit an inhomogeneous Matern cluster point process model, but unfortunately I'm unable to simulate new data points from the fitted object.
Specifically, I get the following error message: Error in rthin(result, P) : some points of X lie outside the domain of image P I've toyed around a bit, and apparently the error only occurs if the window enclosing the analyzed point pattern is derived from a polygon, and the fitted model is inhomogeneous (includes covariates). Moreover, whether the error occurs appears to be dependent on some idiosyncrasies in the analyzed point patterns, i.e., in the example provided below changing the random seed will sometimes make the simulation work. I'm using spatstat 1.37-0 with R 3.1.0 on a x86_64-w64-mingw32/x64 (64-bit) machine. Here's some reproducible code: > require(spatstat)> set.seed(0)> > # Create an irregular window> poly.mat <- > matrix(c(1,0,0.5,1,0,0), 3, 2, byrow=TRUE)> poly.owin <- owin(poly=poly.mat)> > > # Generate Matern points> matern.ppp <- rMatClust(50, 0.05, 5, > win=poly.owin)> > # Some distance function as a covariate> distorigin <- > function(x, y) {+ sqrt(x^2 + y^2)+ }> > # No covariates: works fine> > homogeneous.fit <- kppm(matern.ppp, ~ 1, clusters="MatClust") > matern.sim <- > simulate(homogeneous.fit, retry=0)> > # Covariates: Simulation fails> > inhomogeneous.fit <- kppm(matern.ppp, ~ distorigin, clusters="MatClust") > > matern.sim <- simulate(inhomogeneous.fit, retry=0)Error in rthin(result, P) : some points of X lie outside the domain of image PWarning message:In simulate.kppm(inhomogeneous.fit, retry = 0) : 1 simulation was unsuccessful: returned as NULL I'm fairly new to working with spatstat, so I might be missing something very basic. Any ideas on what I'm doing wrong? Many thanks for your help and best regards, Philipp Hunziker ETH Zurich [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.