I understand the problem is that the function is trying to sum non-finite values and I think I can fix the issue by removing those values from the ppm object, however I'm having a hard time locating all the specific components the function is trying to use.
I've tried looking at the source code on the Github (and in R) to trace the logic backwards, and it looks like it might be a problem for the Kinhom function but I'm having trouble following it all the way back to the PPM object as there are a lot of big intermediary internal functions.
Can anybody point me to the specific component of the PPM object that is causing the error, and perhaps how to remove it? Any help would be greatly appreciated!
Edit: To clarify I know there are two points in the glmdata (4430, 4524) that have undefined covariate values and I suspect they are causing this problem. I added the str() command to show where I suspect the problem value is stored.
Kinhom function Spatstat page on Github https://github.com/spatstat/spatstat/blob/7ee141dc21d945fb35163868b813dbef6ad5dd90/R/Kinhom.R
PPM class object Spatstat page on Github https://github.com/spatstat/spatstat/blob/master/R/ppmclass.R
Here is my ppm model data:
https://www.dropbox.com/sh/ayyozo1dnhbqmvg/AACRqzAu617u0Sq_fk8RqUiJa?dl=0
Just a warning it's a pretty large ppm object (around 40MB)
Here is the code
library(spatstat)
load(file="SamplePPM.RData")
summary(ppm16.reduced2.offset.densavg) # info on the ppm object
Kres(ppm16.reduced2.offset.densavg)
# I suspect the problem value is somewhere in here
str(ppm16.reduced2.offset.densavg$internal$glmfit)
Here was the full error message:
Error in Kwtsum(dIJ[okI], bI[okI], wcIJ[okI], b[Z & USED], rep.int(1, : Weights in K-function were infinite or NA In addition: Warning message: Some infinite, NA or NaN increments were removed
And traceback command:
4: stop("Weights in K-function were infinite or NA") 3: Kwtsum(dIJ[okI], bI[okI], wcIJ[okI], b[Z & USED], rep.int(1, npts.used), breaks) 2: Kcom(object, ...) 1: Kres(ppm16.reduced2.offset.densavg)
Thanks ahead of time!