parres(model, covariate, ..., smooth.effect=FALSE, subregion=NULL, bw = "nrd0", adjust=1, from = NULL, to = NULL, n = 512, bw.input = c("points", "quad"), bw.restrict=FALSE, covname)
"ppm"
).
"x"
or "y"
referring to the Cartesian coordinates,
or one of the names of the covariates given when model
was fitted,
or a pixel image (object of class "im"
)
or function(x,y)
supplying the
values of a covariate at any location.
"owin"
)
specifying a subset of the spatial domain of the data.
The calculation will be confined to the data in this subregion.
density.default
).
density.default
).
density.default
to
control the number and range of values at which the function
will be estimated.
density.default
.
subregion
.
"fv"
)
containing the values of the smoothed partial residual,
the estimated variance, and the fitted effect of the covariate.
Also belongs to the class "parres"
which has methods for print
and plot
.
bw
. One strategy is to use a coarser
subset of the data to select bw
automatically.
The selected bandwidth can be read off the print output for
parres
.model
must be a fitted Poisson point process model.
The diagnostic works in two different ways:
covariate
may be a character string
which is the name of one of the canonical covariates in the
model.
The canonical covariates are the
functions $Z[j]$ that appear
in the expression for the Poisson point process intensity
$$
\lambda(u) = \exp(\beta_1 Z_1(u) + \ldots + \beta_p Z_p(u))
$$
at spatial location $u$.
Type names(coef(model))
to see the names of the
canonical covariates in model
.
If the selected covariate is $Z[j]$, then
the diagnostic plot concerns the model term
$beta[j] * Z[j](u)$. The plot shows a smooth
estimate of a function $h(z)$ that should replace this linear
term, that is, $beta[j] * Z[j](u)$ should be
replaced by $h(Z[j](u))$. The linear function is
also plotted as a dotted line.
covariate
is a pixel image
(object of class "im"
) or a function(x,y)
,
it is assumed to provide the values of a covariate that is
not present in the model.
Alternatively covariate
can be the name of a
covariate that was supplied when the model was fitted
(i.e. in the call to ppm
)
but which does not feature in the model formula.
In either case we speak of a new covariate $Z(u)$.
If the fitted model intensity is $lambda(u)$
then we consider modifying this to
$lambda(u) * exp(h(Z(u)))$
where $h(z)$ is some function. The diagnostic plot shows
an estimate of $h(z)$.
Warning: in this case the diagnostic is not theoretically
justified. This option is provided for research purposes.
Alternatively covariate
can be one of the character strings
"x"
or "y"
signifying the Cartesian coordinates.
The behaviour here depends on whether the coordinate was one of the
canonical covariates in the model.
If there is more than one canonical covariate in the model
that depends on the specified covariate
, then
the covariate effect is computed using all these canonical covariates.
For example in a log-quadratic model which includes the terms x
and
I(x^2)
, the quadratic effect involving both these terms
will be computed.
There are two choices for the algorithm.
If smooth.effect=TRUE
, the fitted covariate effect (according
to model
) is added to the point process residuals, then
smoothing is applied to these values. If smooth.effect=FALSE
,
the point process residuals are smoothed first, and then the fitted
covariate effect is added to the result.
The smoothing bandwidth is controlled by the arguments
bw
, adjust
, bw.input
and bw.restrict
.
If bw
is a numeric value, then
the bandwidth is taken to be adjust * bw
.
If bw
is a string representing a bandwidth selection rule
(recognised by density.default
)
then the bandwidth is selected by this rule.
The data used for automatic bandwidth selection are
specified by bw.input
and bw.restrict
.
If bw.input="points"
(the default) then bandwidth selection is
based on the covariate values at the points of the original point
pattern dataset to which the model was fitted.
If bw.input="quad"
then bandwidth selection is
based on the covariate values at every quadrature point used to
fit the model.
If bw.restrict=TRUE
then the bandwidth selection is performed
using only data from inside the subregion
.
addvar
,
rhohat
,
rho2hat
X <- rpoispp(function(x,y){exp(3+x+2*x^2)})
model <- ppm(X, ~x+y)
tra <- parres(model, "x")
plot(tra)
plot(parres(model, "x", subregion=square(0.5)))
model2 <- ppm(X, ~x+I(x^2)+y)
plot(parres(model2, "x"))
Z <- setcov(owin())
plot(parres(model2, Z))
Run the code above in your browser using DataLab