Search code examples
rspatstat

How to use inhomogeneous models fitted in the calculation of envelopes in spatstat?


This question involves conceptual issues, however, it also involves code. Given a heterogeneous pattern of points, dependent on terrain slope and elevation, for example, obtained from a fit of a poisson model where lambda is equal to a loglinear function of the covariates:

fit<- ppm(X~1+elev+grad, data= bei.extra)

My question is, when intending to calculate a g inhom to test whether these variables can help explain the heterogeneity of the spatial pattern of a false aggregation (virtual aggregation) observed in g, how should I proceed with the code? I think it could be like this:

g<-envelope(fit, pcfinhom, correction="isotropic", divisor="d", lambda=fit, nsim = 199)

The code above runs, but I'd like to know if it's appropriate to put the fit model both as the parsing point pattern and also equal to the lambda, our since fit is a lambda log, I don't know if it's appropriate to use it without transformation. Or if just like this:

g<-envelope(fit, pcfinhom, correction="isotropic", divisor="d", nsim = 199)

Since fit is a lambda log, I don't know if it's appropriate to use it without transformation to ginhom.


Solution

  • The inhomogeneous pair correlation function requires an estimate of the intensity of the point process. In the first command this intensity estimate is obtained from a point process model; in the second command the intensity estimate is obtained by kernel smoothing. So the two commands are doing different things.

    In the first command

    envelope(fit, pcfinhom, lambda=fit, .....)
    

    the argument lambda is passed to pcfinhom. For each simulated point pattern Xsim, the envelope code calls pcfinhom(Xsim, lambda=fit, ...). According to the help file for pcfinhom, the model fit will be re-fitted to the pattern Xsim, and the intensity of this re-fitted or updated model will be used as the intensity lambda for calculation in pcfinhom.

    In the second command

    envelope(fit, pcfinhom, ....)
    

    the argument lambda required by pcfinhom is missing. For each simulated pattern Xsim the envelope code will call pcfinhom(Xsim, ....). According to the help file for pcfinhom, the intensity will be estimated by kernel smoothing of Xsim using density.ppp. The result in this second case could be changed by adding arguments like bw to control the smoothing bandwidth or bandwidth selection rule.

    The first command could be regarded as corresponding to a parametric test of goodness-of-fit, while the second command could be regarded as a nonparametric or semiparametric test of goodness-of-fit, of the same fitted model.

    However in your question you say

    My question is, when intending to calculate a g inhom to test whether these variables can help explain the heterogeneity of the spatial pattern of a false aggregation (virtual aggregation) observed in g

    A simulation envelope is not really the best way to assess such a question. The simulation envelopes correspond to an overall test of goodness-of-fit, and do not provide specific information about variables in the model (such as, which are the variables whose omission causes a lack of fit).

    For this it might be better to use diagnostics such as the residual K function Kres, or the analysis of deviance (likelihood ratio test) anova.ppm. Example:

    fit0 <- ppm(bei ~ 1, data=bei)
    fit1 <- ppm(bei ~ elev + grad, data=bei)
    anova(fit0, fit1, test="Chi")