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, Strauss(r))
However, r
is a free parameter, which I want to optimize. I started by doing:
ll <- -Inf
r_hat <- 0
for (r in seq(from=0.5, to=10, by=0.05)){
fit1 <- ppm(NMJ1~marks*sqrt(x^2+y^2),Strauss(r))
fit2 <- ppm(NMJ2~marks*sqrt(x^2+y^2),Strauss(r))
fit3 <- ppm(NMJ3~marks*sqrt(x^2+y^2),Strauss(r))
if(logLik.ppm(fit1)+logLik.ppm(fit2)+logLik.ppm(fit3) > ll) {
ll <- logLik.ppm(fit1)+logLik.ppm(fit2)+logLik.ppm(fit3)
r_hat <- r
}
}
(i.e. by finding the value of r
that optimizes the sum of the log-likelihood for the 3 fits on my 3 datasets), which runs without warning; however, here I'm fitting 3 independent models on each dataset, while I want my model to be the same for all of them.
I then tried:
ll <- -Inf
r_hat <- 0
for (r in seq(from=0.5, to=10, by=0.05)){
fit <- mppm(Points ~ marks*sqrt(x^2+y^2), data, Strauss(r))
ll_temp <- logLik.mppm(fit)
if(ll_temp > ll) {
ll <- ll_temp
r_hat <- r
}
}
which returns the following warning:
Warning message:
In logLik.mppm(fit) :
log likelihood is not available for non-Poisson model; log-pseudolikelihood returned
Besides this warning, the returned values for r
do not seem to be realistic (they are larger than the average distances between my points). My questions are thus the following:
- Is there a "clean" way to optimize the
r
parameter when usingmppm
? - On the statistics side, can
r
be computed analytically (from, for instance, the distribution of the distances between my points) ?