33#
44# Point process models on a linear network
55#
6- # $Revision: 1.68 $ $Date: 2025/12 /19 07:50:29 $
6+ # $Revision: 1.69 $ $Date: 2026/01 /19 05:49:47 $
77#
88
99lppm <- function (X , ... ) {
@@ -126,12 +126,29 @@ predict.lppm <- local({
126126 X <- object $ X
127127 fit <- object $ fit
128128 L <- as.linnet(X )
129-
129+
130+ # # functions to evaluate the local covariates
131+ LocalCoords <- list (seg = linfun(function (x ,y ,seg ,tp ) { seg }, L ),
132+ tp = linfun(function (x ,y ,seg ,tp ) { seg }, L ))
133+
130134 if (! is.null(locations )) {
131- # ' locations given; return a vector/matrix of predicted values
132- if (is.lpp(locations )) locations <- as.ppp(locations )
135+ # # determine whether 'locations' includes local coordinates
136+ if (is.data.frame(locations )) {
137+ # # data frame of spatial locations
138+ gotlocal <- all(c(" seg" , " tp" ) %in% names(locations ))
139+ } else if (is.lpp(locations )) {
140+ # # point pattern on network
141+ gotlocal <- TRUE
142+ loci <- locations
143+ locations <- as.ppp(locations )
144+ attr(locations , " situ" ) <- loci
145+ } else {
146+ # # other spatial data
147+ gotlocal <- FALSE
148+ }
133149 values <- predict(fit , locations = locations , covariates = covariates ,
134- type = type , se = se , new.coef = new.coef )
150+ type = type , se = se , new.coef = new.coef ,
151+ extracovariates = if (! gotlocal ) LocalCoords else NULL )
135152 return (values )
136153 }
137154
@@ -157,7 +174,8 @@ predict.lppm <- local({
157174 if (! is.multitype(fit )) {
158175 # ' unmarked
159176 values <- predict(fit , locations = projloc , covariates = covariates ,
160- type = type , se = se , new.coef = new.coef )
177+ type = type , se = se , new.coef = new.coef ,
178+ extracovariates = LocalCoords )
161179 if (! se ) {
162180 out <- putvalues(values , lineimage , pixelcentres , projdata , L )
163181 } else {
@@ -175,7 +193,8 @@ predict.lppm <- local({
175193 markk <- factor (lev [k ], levels = lev )
176194 locnk <- cbind(projloc , data.frame (marks = markk ))
177195 values <- predict(fit , locations = locnk , covariates = covariates ,
178- type = type , se = se , new.coef = new.coef )
196+ type = type , se = se , new.coef = new.coef ,
197+ extracovariates = LocalCoords )
179198 if (! se ) {
180199 out [[k ]] <- putvalues(values , lineimage , pixelcentres , projdata , L )
181200 } else {
@@ -512,6 +531,6 @@ eem.lppm <- function(fit, ...) {
512531
513532residuals.lppm <- function (object , type = " raw" , ... ) {
514533 res <- residuals(as.ppm(object ), type = type , ... )
515- attr(res , " plekken " ) <- attr(quad.ppm(object ), " plekken " )
534+ attr(res , " situ " ) <- attr(quad.ppm(object ), " situ " )
516535 return (res )
517536}
0 commit comments