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.
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:
(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 saysThat suggests that, in the calls to
kppm, you should have setmethod='palm'ormethod='clik2'.If you type
traceback()immediately after the error message, the nested sequence of function calls is printed. We can see that the commandAIC(fit)is dispatched to the methodAIC.kppm. The help file forAIC.kppmspecifically mentions thatSo, the way to get AIC values for fitted models is to fit the models using the argument
method="palm"ormethod="clik2". Example:You will also be able to do things like
anovato 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
kppmobjects. You can useto 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,
diagnoseis not a defined generic inspatstat, sodiagnose(fitT)does not work.