I would like to fit a single model to several independent datasets in R
using the spatstat
package. Here, I have 3 independent datasets (ppp
objects called NMJ1
, NMJ2
, and NMJ3
), to which I want to fit a common model. The way to go should be to use the mppm
function:
data <- listof(NMJ1,NMJ2,NMJ3)
data <- hyperframe(X=1:3, Points=data)
r <- matrix(c(120, 240, 240, 90), nrow = 2, ncol = 2)
model <- mppm(Points ~marks*abs(sqrt(x^2+y^2)), data, MultiStrauss(r))
In the model I am fitting, the intensity is a function of the distance to the center of the window and I supposed a MultiStrauss
interaction scheme.
However, the mppm
function is going to fit each dataset independently. When typing subfits(model)
, the fitted trend coefficients are the same for each dataset, but not the gamma coefficients. Similarly, in plotting the results of simulate(model)
, I observe significant and consistent differences between the 3 plots.
What is the best way to handle independent datasets (repetition of samples from the same model) in spatstat
?
This is a bug.
Your code is correct for this purpose. (Namely, when we want the same interaction coefficients to apply to all of the point patterns.)
There is a bug in the function subfits
in the package spatstat.core
.
The fitted model returned by mppm
is correct, but the list of sub-models returned by subfits
is partially incorrect.
The bug will be fixed shortly, in the development version spatstat.core 2.3-0.011
available from the GitHub repository