# rhohat

##### Smoothing Estimate of Intensity as Function of a Covariate

Computes a smoothing estimate of the intensity of a point process, as a function of a (continuous) spatial covariate.

##### Usage

`rhohat(object, covariate, ...)`# S3 method for ppp
rhohat(object, covariate, ...,
baseline=NULL, weights=NULL,
method=c("ratio", "reweight", "transform"),
horvitz=FALSE,
smoother=c("kernel", "local"),
dimyx=NULL, eps=NULL,
n = 512, bw = "nrd0", adjust=1, from = NULL, to = NULL,
bwref=bw,
covname, confidence=0.95)

# S3 method for quad
rhohat(object, covariate, ...,
baseline=NULL, weights=NULL,
method=c("ratio", "reweight", "transform"),
horvitz=FALSE,
smoother=c("kernel", "local"),
dimyx=NULL, eps=NULL,
n = 512, bw = "nrd0", adjust=1, from = NULL, to = NULL,
bwref=bw,
covname, confidence=0.95)

# S3 method for ppm
rhohat(object, covariate, ...,
weights=NULL,
method=c("ratio", "reweight", "transform"),
horvitz=FALSE,
smoother=c("kernel", "local"),
dimyx=NULL, eps=NULL,
n = 512, bw = "nrd0", adjust=1, from = NULL, to = NULL,
bwref=bw,
covname, confidence=0.95)

# S3 method for lpp
rhohat(object, covariate, ...,
weights=NULL,
method=c("ratio", "reweight", "transform"),
horvitz=FALSE,
smoother=c("kernel", "local"),
nd=1000, eps=NULL, random=TRUE,
n = 512, bw = "nrd0", adjust=1, from = NULL, to = NULL,
bwref=bw,
covname, confidence=0.95)

# S3 method for lppm
rhohat(object, covariate, ...,
weights=NULL,
method=c("ratio", "reweight", "transform"),
horvitz=FALSE,
smoother=c("kernel", "local"),
nd=1000, eps=NULL, random=TRUE,
n = 512, bw = "nrd0", adjust=1, from = NULL, to = NULL,
bwref=bw,
covname, confidence=0.95)

##### Arguments

- object
A point pattern (object of class

`"ppp"`

or`"lpp"`

), a quadrature scheme (object of class`"quad"`

) or a fitted point process model (object of class`"ppm"`

or`"lppm"`

).- covariate
Either a

`function(x,y)`

or a pixel image (object of class`"im"`

) providing the values of the covariate at any location. Alternatively one of the strings`"x"`

or`"y"`

signifying the Cartesian coordinates.- weights
Optional weights attached to the data points. Either a numeric vector of weights for each data point, or a pixel image (object of class

`"im"`

) or a`function(x,y)`

providing the weights.- baseline
Optional baseline for intensity function. A

`function(x,y)`

or a pixel image (object of class`"im"`

) providing the values of the baseline at any location.- method
Character string determining the smoothing method. See Details.

- horvitz
Logical value indicating whether to use Horvitz-Thompson weights. See Details.

- smoother
Character string determining the smoothing algorithm. See Details.

- dimyx,eps,nd,random
Arguments controlling the pixel resolution at which the covariate will be evaluated. See Details.

- bw
Smoothing bandwidth or bandwidth rule (passed to

`density.default`

).- adjust
Smoothing bandwidth adjustment factor (passed to

`density.default`

).- n, from, to
Arguments passed to

`density.default`

to control the number and range of values at which the function will be estimated.- bwref
Optional. An alternative value of

`bw`

to use when smoothing the reference density (the density of the covariate values observed at all locations in the window).- …
Additional arguments passed to

`density.default`

or`locfit`

.- covname
Optional. Character string to use as the name of the covariate.

- confidence
Confidence level for confidence intervals. A number between 0 and 1.

##### Details

This command estimates the relationship between
point process intensity and a given spatial covariate.
Such a relationship is sometimes called a
*resource selection function* (if the points are organisms
and the covariate is a descriptor of habitat) or
a *prospectivity index* (if the points are mineral deposits
and the covariate is a geological variable).
This command uses a nonparametric smoothing method which does not assume a
particular form for the relationship.

If `object`

is a point pattern, and `baseline`

is missing or
null, this command assumes that `object`

is a realisation of a
Poisson point process with intensity function
\(\lambda(u)\) of the form
$$\lambda(u) = \rho(Z(u))$$
where \(Z\) is the spatial
covariate function given by `covariate`

, and
\(\rho(z)\) is a function to be estimated. This command
computes estimators of \(\rho(z)\) proposed by Baddeley and
Turner (2005) and Baddeley et al (2012).

The covariate \(Z\) must have continuous values.

If `object`

is a point pattern, and `baseline`

is given,
then the intensity function is assumed to be
$$\lambda(u) = \rho(Z(u)) B(u)$$
where \(B(u)\) is the baseline intensity at location \(u\).
A smoothing estimator of the relative intensity \(\rho(z)\)
is computed.

If `object`

is a fitted point process model, suppose `X`

is
the original data point pattern to which the model was fitted. Then
this command assumes `X`

is a realisation of a Poisson point
process with intensity function of the form
$$
\lambda(u) = \rho(Z(u)) \kappa(u)
$$
where \(\kappa(u)\) is the intensity of the fitted model
`object`

. A smoothing estimator of \(\rho(z)\) is computed.

The estimation procedure is determined by the character strings
`method`

and `smoother`

and the argument `horvitz`

.
The estimation procedure involves computing several density estimates
and combining them.
The algorithm used to compute density estimates is
determined by `smoother`

:

If

`smoother="kernel"`

, each the smoothing procedure is based on fixed-bandwidth kernel density estimation, performed by`density.default`

.If

`smoother="local"`

, the smoothing procedure is based on local likelihood density estimation, performed by`locfit`

.

The `method`

determines how the density estimates will be
combined to obtain an estimate of \(\rho(z)\):

If

`method="ratio"`

, then \(\rho(z)\) is estimated by the ratio of two density estimates. The numerator is a (rescaled) density estimate obtained by smoothing the values \(Z(y_i)\) of the covariate \(Z\) observed at the data points \(y_i\). The denominator is a density estimate of the reference distribution of \(Z\).If

`method="reweight"`

, then \(\rho(z)\) is estimated by applying density estimation to the values \(Z(y_i)\) of the covariate \(Z\) observed at the data points \(y_i\), with weights inversely proportional to the reference density of \(Z\).If

`method="transform"`

, the smoothing method is variable-bandwidth kernel smoothing, implemented by applying the Probability Integral Transform to the covariate values, yielding values in the range 0 to 1, then applying edge-corrected density estimation on the interval \([0,1]\), and back-transforming.

If `horvitz=TRUE`

, then the calculations described above
are modified by using Horvitz-Thompson weighting.
The contribution to the numerator from
each data point is weighted by the reciprocal of the
baseline value or fitted intensity value at that data point;
and a corresponding adjustment is made to the denominator.

The covariate will be evaluated on a fine grid of locations,
with spatial resolution controlled by the arguments
`dimyx,eps,nd,random`

.
In two dimensions (i.e.
if `object`

is of class `"ppp"`

, `"ppm"`

or
`"quad"`

) the arguments `dimyx, eps`

are
passed to `as.mask`

to control the pixel
resolution. On a linear network (i.e. if `object`

is of class
`"lpp"`

) the argument `nd`

specifies the
total number of test locations on the linear
network, `eps`

specifies the linear separation between test
locations, and `random`

specifies whether the test locations
have a randomised starting position.

If the argument `weights`

is present, then the contribution
from each data point `X[i]`

to the estimate of \(\rho\) is
multiplied by `weights[i]`

.

##### Value

A function value table (object of class `"fv"`

)
containing the estimated values of \(\rho\) for a sequence
of values of \(Z\).
Also belongs to the class `"rhohat"`

which has special methods for `print`

, `plot`

and `predict`

.

##### Categorical and discrete covariates

This technique assumes that the covariate has continuous values.
It is not applicable to covariates with categorical (factor) values
or discrete values such as small integers.
For a categorical covariate, use
`intensity.quadratcount`

applied to the result of
`quadratcount(X, tess=covariate)`

.

##### References

Baddeley, A., Chang, Y.-M., Song, Y. and Turner, R. (2012)
Nonparametric estimation of the dependence of a point
process on spatial covariates.
*Statistics and Its Interface* **5** (2), 221--236.

Baddeley, A. and Turner, R. (2005)
Modelling spatial point patterns in R.
In: A. Baddeley, P. Gregori, J. Mateu, R. Stoica, and D. Stoyan,
editors, *Case Studies in Spatial Point Pattern Modelling*,
Lecture Notes in Statistics number 185. Pages 23--74.
Springer-Verlag, New York, 2006.
ISBN: 0-387-28311-0.

##### See Also

`rho2hat`

,
`methods.rhohat`

,
`parres`

.

See `ppm`

for a parametric method for the same problem.

##### Examples

```
# NOT RUN {
X <- rpoispp(function(x,y){exp(3+3*x)})
rho <- rhohat(X, "x")
rho <- rhohat(X, function(x,y){x})
plot(rho)
curve(exp(3+3*x), lty=3, col=2, add=TRUE)
rhoB <- rhohat(X, "x", method="reweight")
rhoC <- rhohat(X, "x", method="transform")
# }
# NOT RUN {
fit <- ppm(X, ~x)
rr <- rhohat(fit, "y")
# linear network
Y <- runiflpp(30, simplenet)
rhoY <- rhohat(Y, "y")
# }
```

*Documentation reproduced from package spatstat, version 1.49-0, License: GPL (>= 2)*