Problem with the inclusion of lintess objects in lppm
Closed this issue · 5 comments
Dear all, I think I've found a possible problem with the inclusion of lintess
objects in a model estimated by lppm
. For example:
library(spatstat)
#> Loading required package: spatstat.data
#> Loading required package: spatstat.geom
#> spatstat.geom 3.2-2
#> Loading required package: spatstat.random
#> spatstat.random 3.1-5
#> Loading required package: spatstat.explore
#> Loading required package: nlme
#> spatstat.explore 3.2-1
#> Loading required package: spatstat.model
#> Loading required package: rpart
#> spatstat.model 3.2-4
#> Loading required package: spatstat.linnet
#> spatstat.linnet 3.1-1
#>
#> spatstat 3.0-6
#> For an introduction to spatstat, type 'beginner'
toy_points <- rpoislpp(20, simplenet)
toy_tess <- lintess(
L = simplenet,
df = data.frame(
seg = 1:10,
t0 = 0,
t1 = 1,
tile = c("A", "B")
)
)
lppm(toy_points ~ toy_tess)
#> Error in mpl.get.covariates(covariates, P, Pname, covfunargs): Each entry in the list 'covariates' should be an image, a function, a window, a tessellation or a single number
A possible workaround I've found:
toy_linfun <- as.linfun(toy_tess)
lppm(toy_points ~ toy_linfun)
#> Point process model on linear network
#> Fitted to point pattern dataset 'toy_points'
#>
#> Nonstationary Poisson process
#>
#> Log intensity: ~toy_linfun
#>
#> Fitted trend coefficients:
#> (Intercept) toy_linfunB
#> 3.311431 0.123307
#>
#> Estimate S.E. CI95.lo CI95.hi Ztest Zval
#> (Intercept) 3.311431 0.1601282 2.9975856 3.625276 *** 20.6798800
#> toy_linfunB 0.123307 0.2176698 -0.3033181 0.549932 0.5664863
#>
#> Domain: Linear network with 10 vertices and 10 lines
#> Enclosing window: rectangle = [0, 1] x [0, 1] units
Created on 2023-07-12 with reprex v2.0.2
Am I doing something wrong in the first call to lppm
? Is the workaround ok? In any case, thank you very much for maintaining this amazing set of packages.
Hi Andrea,
Sorry for the radio silence. This is just to confirm that I can reproduce the problem and we will fix it for the next release. Thanks for reporting!
Best,
Ege
Currently lppm
does not support covariates which are objects of class lintess
. The documentation does not say that these are supported (although admittedly the help for lppm
does mention "tessellations", it means that objects of class tess
are supported). I agree that it would be nice if lppm
handled lintess
covariates.
The problem is related to the split-up of spatstat
into multiple sub-packages. Models are fitted using the internal code of ppm
.
I am not as confident as Ege that this can be fixed soon. I do not promise to fix it by the next release. However I will try.
I have found a "hack" solution. Please install spatstat.model
development version 3.2-4.001
or later. Then it should work.
Works perfectly, thank you very much for the speedy fix!