Skip to content

Commit f9dfd5f

Browse files
committed
Bug fix in intensity.zclustermodel
1 parent bb6ef4d commit f9dfd5f

File tree

8 files changed

+88
-8
lines changed

8 files changed

+88
-8
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: spatstat.model
2-
Version: 3.3-5.001
2+
Version: 3.3-5.002
33
Date: 2025-04-18
44
Title: Parametric Statistical Modelling and Inference for the 'spatstat' Family
55
Authors@R: c(person("Adrian", "Baddeley",

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,7 @@ export("simulate.mppm")
636636
export("simulate.ppm")
637637
export("simulate.profilepl")
638638
export("simulate.slrm")
639+
export("simulate.zclustermodel")
639640
export("slrAssemblePixelData")
640641
export("slrm")
641642
export("slrmInfluence")
@@ -1109,6 +1110,7 @@ S3method("shift", "msr")
11091110
S3method("simulate", "ppm")
11101111
S3method("simulate", "profilepl")
11111112
S3method("simulate", "slrm")
1113+
S3method("simulate", "zclustermodel")
11121114
S3method("Smooth", "influence.ppm")
11131115
S3method("Smooth", "leverage.ppm")
11141116
S3method("Smooth", "msr")

NEWS

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11

2-
CHANGES IN spatstat.model VERSION 3.3-5.001
2+
CHANGES IN spatstat.model VERSION 3.3-5.002
33

44
OVERVIEW
55

6-
o Documentation improvements.
6+
o Simulation of 'zclustermodel' objects.
77

8+
o Documentation improvements and bug fixes.
9+
10+
NEW FUNCTIONS
11+
12+
o simulate.zclustermodel
13+
Method for simulating objects of class 'zclustermodel'.
14+
15+
BUG FIXES
16+
17+
o intensity.zclustermodel
18+
Always returned the value zero.
19+
Fixed.
820

921
CHANGES IN spatstat.model VERSION 3.3-5
1022

R/simulatekppm.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ condSimCox <- function(object, nsim=1,
150150
giveup=1000, maxchunk=100,
151151
saveLambda=FALSE,
152152
verbose=TRUE, drop=FALSE) {
153-
stopifnot(is.kppm(object))
153+
if(!inherits(object, c("kppm", "zclustermodel")))
154+
stop("object should belong to class 'kppm' or 'zclustermodel'", call=FALSE)
154155
shortcut <- isFALSE(object$isPCP)
155156

156157
w.sim <- as.owin(window)

R/zclustermodel.R

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#'
44
#' Experimental
55
#'
6-
#' $Revision: 1.11 $ $Date: 2023/09/11 04:13:58 $
6+
#' $Revision: 1.12 $ $Date: 2025/04/18 08:13:38 $
77
#'
88

99
zclustermodel <- function(name="Thomas", ..., mu, kappa, scale) {
@@ -83,7 +83,7 @@ Kmodel.zclustermodel <- function(model, ...) {
8383
}
8484

8585
intensity.zclustermodel <- function(X, ...) {
86-
X$par[["kappa"]] * X$mu
86+
X$par.std[["kappa"]] * X$mu
8787
}
8888

8989
predict.zclustermodel <- function(object, ...,
@@ -122,3 +122,57 @@ reach.zclustermodel <- function(x, ..., epsilon) {
122122
}
123123

124124
is.poissonclusterprocess.zclustermodel <- function(model) { TRUE }
125+
126+
simulate.zclustermodel <- function(object, nsim=1, ..., win=unit.square()) {
127+
with(object, {
128+
switch(name,
129+
Thomas = {
130+
rThomas(kappa=par.std[["kappa"]],
131+
scale=par.std[["scale"]],
132+
mu=mu,
133+
win=win,
134+
nsim=nsim,
135+
...)
136+
},
137+
MatClust = {
138+
rMatClust(kappa=par.std[["kappa"]],
139+
scale=par.std[["scale"]],
140+
mu=mu,
141+
win=win,
142+
nsim=nsim,
143+
...)
144+
},
145+
Cauchy = {
146+
rCauchy(kappa=par.std[["kappa"]],
147+
scale=par.std[["scale"]],
148+
mu=mu,
149+
win=win,
150+
nsim=nsim,
151+
...)
152+
},
153+
VarGamma = {
154+
do.call(rVarGamma,
155+
resolve.defaults(
156+
list(kappa=par.std[["kappa"]],
157+
scale=par.std[["scale"]],
158+
mu=mu,
159+
win=win,
160+
nsim=nsim,
161+
...),
162+
clustargs))
163+
},
164+
LGCP = {
165+
do.call(rLGCP,
166+
resolve.defaults(
167+
list(kappa=par.std[["kappa"]],
168+
scale=par.std[["scale"]],
169+
mu=mu,
170+
win=win,
171+
nsim=nsim,
172+
...),
173+
clustargs))
174+
},
175+
stop(paste("Unrecognised model name", sQuote(object$name)),
176+
call.=FALSE)
177+
)})
178+
}

inst/doc/packagesizes.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ date version nhelpfiles nobjects ndatasets Rlines srclines
1919
"2024-11-19" "3.3-3" 269 726 0 39066 1155
2020
"2025-01-20" "3.3-4" 269 726 0 39070 1155
2121
"2025-03-22" "3.3-5" 269 726 0 39076 1155
22-
"2025-04-18" "3.3-5.001" 269 726 0 39076 1155
22+
"2025-04-18" "3.3-5.002" 269 727 0 39131 1155

inst/info/packagesizes.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ date version nhelpfiles nobjects ndatasets Rlines srclines
1919
"2024-11-19" "3.3-3" 269 726 0 39066 1155
2020
"2025-01-20" "3.3-4" 269 726 0 39070 1155
2121
"2025-03-22" "3.3-5" 269 726 0 39076 1155
22-
"2025-04-18" "3.3-5.001" 269 726 0 39076 1155
22+
"2025-04-18" "3.3-5.002" 269 727 0 39131 1155

man/methods.zclustermodel.Rd

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
\alias{print.zclustermodel}
88
\alias{clusterradius.zclustermodel}
99
\alias{reach.zclustermodel}
10+
\alias{simulate.zclustermodel}
1011
\title{
1112
Methods for Cluster Models
1213
}
@@ -28,6 +29,8 @@
2829
\method{clusterradius}{zclustermodel}(model,\dots,thresh=NULL, precision=FALSE)
2930

3031
\method{reach}{zclustermodel}(x, \dots, epsilon)
32+
33+
\method{simulate}{zclustermodel}(object, nsim=1, \dots, win=unit.square())
3134
}
3235
\arguments{
3336
\item{model,object,x,X}{
@@ -51,6 +54,13 @@
5154
\item{precision}{
5255
Logical value stipulating whether the precision should also be returned.
5356
}
57+
\item{win}{
58+
Window (object of class \code{"owin"}) in which the simulated
59+
pattern should be generated.
60+
}
61+
\item{nsim}{
62+
Number of simulated patterns to be generated.
63+
}
5464
}
5565
\details{
5666
Experimental.
@@ -77,6 +87,7 @@
7787
Z2 <- predict(m2, locations=square(1))
7888
varcount(m, square(1))
7989
varcount(m2, square(1))
90+
X <- simulate(m)
8091
}
8192
\keyword{spatial}
8293
\keyword{models}

0 commit comments

Comments
 (0)