rspatialspatstat

When Modeling Cox Spatial point process, for example thomas, LGCP, MatClust,and so on, how can I validate the model fitted?


library(spatstat)

# Definir a janela espacial
Window <- owin(c(0, 10), c(0, 10))

# Definir uma função de intensidade espacial
intensity_function <- function(x, y) {
  # Intensidade aumenta com a distância da origem
  intensity <- 1 + 0.2 * sqrt(x^2 + y^2)
  return(intensity)
}

# Gerar um processo de Poisson não homogêneo
process <- rpoispp(intensity_function, win=Window)

# Plotar o processo
fit <- kppm(process, ~1,"Thomas")    
fit1 <- kppm(process, ~1,"MatClust")  
fit2 <- kppm(process, ~1,"LGCP")  

I trued to use AIC, but they returned errors, I trued to test residuals, but the function diagnose isn´t available, I trued qqplot but also returned error.


Solution

  • It seems that you want to do both model selection (using tools like AIC or anova) and model validation (using residuals and diagnostics).

    For model selection:

    I tried to use AIC, but they returned errors

    (Tip: When posting a question, please include the commands that you typed and the error message that was returned.)

    Presumably the command you typed was AIC(fit). When I try this, the error message says

    Error: logLik is only available for kppm objects fitted with method='palm' or method='clik2'

    That suggests that, in the calls to kppm, you should have set method='palm' or method='clik2'.

    If you type traceback() immediately after the error message, the nested sequence of function calls is printed. We can see that the command AIC(fit) is dispatched to the method AIC.kppm. The help file for AIC.kppm specifically mentions that

    These methods apply only when the model was fitted by maximising a composite likelihood: either the Palm likelihood (Tanaka et al, 2008) or the second order composite likelihood (Guan, 2006), by calling ‘kppm’ with the argument ‘method="palm"’ or ‘method="clik2"’ respectively.

    So, the way to get AIC values for fitted models is to fit the models using the argument method="palm" or method="clik2". Example:

    fitT <- kppm(redwood ~ 1, "Thomas", method="p")
    AIC(fitT)
    

    You will also be able to do things like anova to compare two models when one is a special case of the other.

    For model validation, I'm afraid that the available tools are limited for kppm objects. You can use

    diagnose.ppm(as.ppm(fitT), compute.sd=FALSE)
    

    to get the standard informal diagnostics for the trend component, ignoring the clustering component. Informal validation of fitted cluster process models is still a research area.

    By the way, diagnose is not a defined generic in spatstat, so diagnose(fitT) does not work.