[R] spatstat rmh problem
Rolf Turner
r.turner at auckland.ac.nz
Tue Sep 16 00:18:52 CEST 2014
Your example is not reproducible. We don't have "cshape" or "im.pop"
(and are possibly lacking other bits and pieces; I didn't check the
details since the example fails to run from the get-go). Please provide
a *reproducible* example.
Also I am puzzled by the line
> mod <- ppm (ppp, ~ pop , covariates = list (pop = im.pop))
Did you mean
> mod <- ppm (dat, ~ pop , covariates = list (pop = im.pop))
???
Also please note that with versions of spatstat later than or equal to
1.37-0 you can write
ppm(dat ~ im.pop)
when the object "im.pop" is present in the global environment.
cheers,
Rolf Turner
On 16/09/14 02:30, Sebastian Schutte wrote:
> Dear R and spatstat developers,
>
> Thanks so much for the time and effort that you invest into this awesome
> software. I have a problem simulating from a Point Process Model in
> spatstat. In summary, the option "new.coef" should allow me to use a
> fitted model and change its beta coefficients before simulating a point
> pattern from the model via Monte Carlo simulation. Intuitively, one
> would assume that the predicted point pattern changes as one fiddles
> with the beta coefficients. However, this does not seem to work.
>
> Please let me know what I am missing here and which screw to drive to
> actually change the simulation output.
>
> #owin is a polygon of country boundaries, "im.pop" is a raster with
> georeferenced population counts.
> #I am using a random point pattern for demonstration purposes
>
> #Fix random seed
> set.seed(12345)
> #Generate artificial points
> dat <- rpoint(500,win=cshape)
> #Fit a (inhomogenous spatial poisson) model to the data
> mod <- ppm (ppp, ~ pop , covariates = list (pop = im.pop))
> #Simulate some points:
> plot(density(rmh(mod)))
> #plot(density(simulate(mod)))
> #Show that this is reproducible
> set.seed(12345)
> #Generate artificial points
> dat <- rpoint(500,win=cshape)
> #Fit a (inhomogenous spatial poisson) model to the data
> mod <- ppm (ppp, ~ pop , covariates = list (pop = im.pop))
> #Simulate some points:
> plot(density(rmh(mod)))
> #As expected, the density is the same
>
> #Now change the coefs and do it again:
> set.seed(12345)
> #Generate artificial points
> dat <- rpoint(500,win=cshape)
> #Fit a (inhomogenous spatial poisson) model to the data
> mod <- ppm (ppp, ~ pop , covariates = list (pop = im.pop))
> #Simulate some points:
> plot(density(rmh(mod),new.coef=c(1,200)))
> #Looks the same, so what am I missing?
--
Rolf Turner
Technical Editor ANZJS
More information about the R-help
mailing list