Reputation: 15
I am working using the spatstat library in R.
I have several point pattern objects built from my own dataset
. The point patterns contain only the x and y coordinates of the points in them. I wanted to fit the point patterns to a Gibbs process with Strauss interaction to build a model and simulate similar point patterns. I was able to use ppm function for that purpose if I work with one point pattern at a time. I used rmhmodel function on the ppm object returned from the ppm
function. The rmhmodel
function gave me the parameters beta
, gamma
and r
, which I needed to use in rStrauss function further to simulate new point patterns. FYI, I am not using the simulate function directly as I want the new simulated point pattern to have flexible number of points that simulate does not give me.
Now, if I want to work with all the point patterns I have, I can build a hyperframe
of point patterns as described in the replicated point pattern chapter of the Baddeley
textbook, but it requires mppm function instead of ppm function to fit the model and mppm
is not working with rmhmodel
when I am trying to figure out the model parameters beta
, gamma
and r
.
How can I extract the fitted beta
, gamma
and r
from a mppm
object?
Upvotes: 1
Views: 156
Reputation: 1984
There are several ways to do this.
If you print
a fitted model (obtained from ppm
or from mppm
) simply by typing the name of the object, the printed output contains a description of the fitted model including the model parameters.
If you apply the function parameters
to a fitted model obtained from ppm
you will obtain a list of the parameter values with appropriate names.
fit <- ppm(cells ~ 1, Strauss(0.12))
fit
parameters(fit)
For a model obtained from mppm
, there could be different parameter values applying to each row of the hyperframe of data, so you would have to do lapply(subfits(model), parameters)
and the result is a list with one entry for each row of the hyperframe, containing the parameters relevant to each row.
A <- hyperframe(Bugs=waterstriders)
mfit <- mppm(Bugs ~ 1, data=A, Strauss(5))
lapply(subfits(mfit), parameters)
Alternatively you can extract the canonical parameters by coef
and transform them to the natural parameters.
You wrote:
I am not using the
simulate
function directly as I want the new simulated point pattern to have flexible number of points thatsimulate
does not give me.
This cannot be right. The function simulate.mppm
generates simulated realisations with a variable number of points. Try simulate(mfit)
.
Upvotes: 1