1

I am running into problems when computing the relative risk estimation (relrisk.ppp) of two point patterns: One with four marks in a rectangular region and the other with two marks in a circular region.

For the first pattern with four marks, I am able to get the relative risk and the resulting object in a large imlist with 4 elements corresponding to each mark.

However, for the second pattern, it gives a list of 10 elements, of which the first matrix v is empty with NA entries. I am breaking my head on what possibly could be wrong when the created point pattern objects seems to be identical. Any help will be appreciated. Thanks.

Ross Jacobs
  • 2,962
  • 1
  • 17
  • 27
user2167741
  • 277
  • 1
  • 10
  • Please provide a reproducible example so we have a chance of helping you. Usually `spatstat` is perfectly capable of calculating relative risks for a point pattern observed in a circular region (really a polygon closely approximating a circle), so we need to know what is special about your data/situation. – Ege Rubak Mar 22 '20 at 23:31
  • Thanks. I understand that. How do I share the data? – user2167741 Mar 23 '20 at 00:23
  • Either you make a fake data example directly in R that has the same structure as your data and gives the same error or you simply post a link to the data and a few lines of code to read in the data and reproduce the error. Try hard to boil the problem down to as small an example as possible. I can recommend the `reprex` package to create this reproducible example. – Ege Rubak Mar 23 '20 at 01:33

1 Answers1

2

For your first dataset, the result is a list of image objects (a list of four objects of class im). For your second dataset, the result of relrisk.ppp is a single image (object of class im). This is the default behaviour when there are only two possible types of points (two possible mark values). See help(relrisk.ppp).

In all cases, you should just be able to plot and print the resulting object. You don't need to examine the internal data of the image.

More explanation: when there are only two possible types of points, the default behaviour of relrisk.ppp is to treat them as case-control data, where the points belonging to the first type are treated as controls (e.g. non-infected people), and the points of the second type are treated as cases (e.g. infected people). The ratio of intensities (cases divided by controls) is estimated as an image.

If you don't want this to happen, set the argument casecontrol=FALSE and then relrisk.ppp will always return a list of images, with one image for each possible mark. Each image gives the spatially-varying probability of that type of point.

It's all explained in help(relrisk.ppp) or in the book.

Adrian Baddeley
  • 2,534
  • 1
  • 5
  • 8
  • Although we are able to plot and print in both cases (which worked in my case), this has implications when using downstream analysis such as `im.apply` or `eval.im`. – user2167741 Mar 23 '20 at 04:04