spatstat / spatstat

Umbrella package of the 'spatstat' family................
192 stars 44 forks source link

Specifying custom weights for ppm() #138

Closed idblr closed 4 years ago

idblr commented 4 years ago

My goal is to examine a marked ppp where, for example, instead of individual trees, the locations are tree stands and we have a second numeric mark for the frequency of trees at each point-location:

bei <- spatstat.data::bei
bei.extra <- spatstat.data::bei.extra
spatstat::marks(bei) <- data.frame("freq" = rpois(bei$n, 3))
spatstat::ppm(bei ~ Y + Z,
                        covariates = list(Y = bei.extra[[1]],
                                                   Z = bei.extra[[2]]))

However, I receive an error when running a marked point pattern in ppm()

ppm is not yet implemented for marked point patterns, other than multitype patterns.
baddstats commented 4 years ago

The error message is self-explanatory: ppm is not yet implemented for marked point patterns other than multitype point patterns (i.e. where the marks are a factor).

However, for your purposes, you could simply create an unmarked point pattern which has duplicated points with the multiplicity specified by the freq vector:

 n <- npoints(bei)
 freq <- rpois(n, 3)
 ind <- rep(seq_len(n), freq)
 beibei <- bei[ind]
 ppm(beibei ~ grad+elev, data=bei.extra)

Note that the argument covariates is out of date in ppm.

idblr commented 4 years ago

Thanks, @baddstats, great to know there is a workaround for integer marks! Are there plans to implement ppm for numeric marked point patterns?