update.ppm | R Documentation |
update
method for class "ppm"
.
## S3 method for class 'ppm'
update(object, ..., fixdummy=TRUE, use.internal=NULL,
envir=environment(terms(object)))
object |
An existing fitted point process model,
typically produced by |
... |
Arguments to be updated in the new call to |
fixdummy |
Logical flag indicating whether the quadrature scheme for the
call to |
use.internal |
Optional. Logical flag indicating whether the model should be
refitted using the internally saved data ( |
envir |
Environment in which to re-evaluate the call to |
This is a method for the generic function update
for the class "ppm"
. An object of class "ppm"
describes a fitted point process model. See ppm.object
)
for details of this class.
update.ppm
will modify the point process model
specified by object
according to the new arguments given,
then re-fit it.
The actual re-fitting is performed by the model-fitting
function ppm
.
If you are comparing several model fits to the same data,
or fits of the same model to different data, it is
strongly advisable to use update.ppm
rather than trying to fit them by hand.
This is because update.ppm
re-fits the model
in a way which is comparable to the original fit.
The arguments ...
are matched to the formal arguments
of ppm
as follows.
First, all the named arguments in ...
are matched
with the formal arguments of ppm
.
Use name=NULL
to remove the argument name
from the
call.
Second, any unnamed arguments in ...
are
matched with formal arguments of ppm
if the matching
is obvious from the class of the object. Thus ...
may contain
exactly one argument of class "ppp"
or "quad"
,
which will be interpreted as the named argument Q
;
exactly one argument of class "formula"
, which will be
interpreted as the named argument trend
(or as specifying
a change to the trend formula);
exactly one argument of class "interact"
, which will be
interpreted as the named argument interaction
;
exactly one argument of class "data.frame"
, which will be
interpreted as the named argument covariates
.
The trend
argument can be a formula that specifies a
change to the current trend formula. For example, the
formula ~ . + Z
specifies that the additional covariate
Z
will be added to the right hand side of the trend
formula in the existing object
.
The argument fixdummy=TRUE
ensures comparability of the
objects before and after updating.
When fixdummy=FALSE
, calling update.ppm
is exactly the same as calling ppm
with the updated
arguments. However, the original and updated models
are not strictly comparable (for example, their pseudolikelihoods
are not strictly comparable) unless they used the same set of dummy
points for the quadrature scheme. Setting fixdummy=TRUE
ensures that the re-fitting will be performed using the same set
of dummy points. This is highly recommended.
The value of use.internal
determines where to find data
to re-evaluate the model (data for the arguments mentioned in
the original call to ppm
that are not overwritten by
arguments to update.ppm
).
If use.internal=FALSE
, then arguments
to ppm
are re-evaluated in the frame where you
call update.ppm
. This is like the behaviour of the
other methods for update
. This means that if you have changed
any of the objects referred to in the call, these changes will be
taken into account. Also if the original call to ppm
included
any calls to random number generators, these calls will be recomputed,
so that you will get a different outcome of the random numbers.
If use.internal=TRUE
, then arguments to ppm
are extracted
from internal data stored inside the current fitted
model object
. This is useful if you don't want to
re-evaluate anything. It is also necessary if
if object
has been restored from a dump file
using load
or source
. In such cases,
we have lost the environment in which object
was fitted,
and data cannot be re-evaluated.
By default, if use.internal
is missing, update.ppm
will
re-evaluate the arguments if this is possible, and use internal data
if not.
Another fitted point process model (object of class "ppm"
).
and \rolf
data(cells)
# fit the stationary Poisson process
fit <- ppm(nztrees, ~ 1)
# fit a nonstationary Poisson process
fitP <- update(fit, trend=~x)
fitP <- update(fit, ~x)
# change the trend formula: add another term to the trend
fitPxy <- update(fitP, ~ . + y)
# change the trend formula: remove the x variable
fitPy <- update(fitPxy, ~ . - x)
# fit a stationary Strauss process
fitS <- update(fit, interaction=Strauss(13))
fitS <- update(fit, Strauss(13))
# refit using a different edge correction
fitS <- update(fitS, correction="isotropic")
# re-fit the model to a subset
# of the original point pattern
nzw <- owin(c(0,148),c(0,95))
nzsub <- nztrees[,nzw]
fut <- update(fitS, Q=nzsub)
fut <- update(fitS, nzsub)
# WARNING: the point pattern argument is called 'Q'
ranfit <- ppm(rpoispp(42), ~1, Poisson())
ranfit
# different random data!
update(ranfit)
# the original data
update(ranfit, use.internal=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.