Search code examples
rspatialspatstat

Calculating variance covariance matrix for improved kppm model


I get the following error when I try to improve the intensity estimate of a kppm object, if I include the argument vcov = TRUE in the function improve.kppm:

Error in improve.kppm(object, type = type, rmax = rmax, dimyx = dimyx,  : 
  object 'gminus1' not found

If I don't include the argument, the function runs but I cannot use the summary() function on the improved kppm object. I get the same error message as above. The same thing happens when I use vcov().

The call that I used to create my kppm object was (number of covariates has been reduced for clarity):

a05 = kppm(a2005nests ~ nest + nest2, cluster = "Thomas", covariates = fitcov(2))

where fitcov(2) is a function that returns a list of im objects. Could this be the issue? I've noticed that some spatstat functions on kppm objects throw errors if I used this function in the original kppm call. Usually it says something along the lines of Error: Covariates ‘nest’ and ‘nest2’ were not found.


Solution

  • There is a bug in the logical flow of improve.kppm: if vcov=TRUE and type != "quasi", the variable gminus1 is not defined. We will fix this in the development version of spatstat as soon as possible.

    Did you perhaps select type="clik1" or type="wclik1" in the original call to kppm?

    For the moment, you should be able to avoid the bug by omitting the argument type, or explicitly selecting type="quasi", in calls to kppm and improve.kppm.

    The second problem, in which kppm fails to find the covariates, appears to be a scoping problem, but I can't reproduce it here. It would help if you can supply a minimal working example.