I have two spatial datasets collected on separate spatial processes, and I would like to fit a spatial model to one dataset and then simulate from the parameters of that model onto the spatial coordinates of the other dataset. My two spatial datasets have coordinate systems are the same scale, so that measurements of intensity per unit area make sense to transfer, but they are not the exact same sizes and have arbitrary coordinate systems, so they may not even overlap.
What I was planning to do within spatstat is to fit a model with something like ppm to my first dataset (data1), and then give the coordinates of my second dataset (data2) to the expand argument of rmhcontrol, like this:
#Create dataset 1
x=rnorm(50)
y=rnorm(50)
data1<-ppp(x=x,y=y,
marks=factor(sample(c("A","B"),size=50,replace=TRUE)),
window=owin(range(x),range(y)))
#Create dataset 2
x=rnorm(20,mean=10)
y=rnorm(20,mean=10)
data2<-ppp(x=x,y=y,
marks=factor(sample(c("A","B"),size=20,replace=TRUE)),
window=owin(range(x),range(y)))
m1 <- ppm(data1 ~ marks) #fitted model on one dataset
s2 <- rmhstart(n.start=c(5,5))
c2 <- rmhcontrol(p=1,fixall=TRUE,
expand=rmhexpand(as.owin(data2)),
)
rmh(model=m1,control=c2,start=s2,nsim=2)
However, the help file for rmhcontrol explains for the argument expand: "Indicates that the process is to be simulated on a domain other than the original data window w, then clipped to w when the algorithm has finished." This would seem to imply that this option would still keep the simulated data constrained to the original data window of my model m1, not my new data data2. Is there another way to accomplish this which doesn't require my simulated data to be on the window of the original data that created m1?
I would note the above is just conceptual, and I'm aware that my argument expand in the call to rmhcontrol causes the command to not work. I haven't worked out why (the rmhexpand(as.owin(data2)) command creates no error and expand is supposed to take the output of rmhexpand, but I get an error message in the call to rmhcontrol "argument is missing, with no default"). But it doesn't seem related to the underlying issue that expand doesn't seem like the right way to do it, according to the help files. So before sorting out that error I'm am trying to figure out what is a correct strategy (if one exists) within spatstat. For example, can I change the window of my model m1 instead?
I also know that my code above is just simulating from a simple poisson process and I don't really need this heavy machinery to do what I want. I plan to change the fitted model to something with more complicated interactions between the types and add more conditions on the simulation. This is just test code to see if I can get the simulation strategy I want from spatstat.
If I understand you question right this is straightforward as rmh.ppm() has an argument called w which specifies the window/domain of simulation. You should just omit any specification of expand and do the following (reusing the rest of you code):
c2 <- rmhcontrol(p=1, fixall=TRUE)
rmh(model=m1, control=c2, start=s2, nsim=2, w = Window(data2))