# rho2hat

##### Smoothed Relative Density of Pairs of Covariate Values

Given a point pattern and two spatial covariates $Z_1$ and $Z_2$, construct a smooth estimate of the relative risk of the pair $(Z_1,Z_2)$.

##### Usage

`rho2hat(object, cov1, cov2, ..., method=c("ratio", "reweight"))`

##### Arguments

- object
- A point pattern (object of class
`"ppp"`

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

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

). - cov1,cov2
- The two covariates.
Each argument is either a
`function(x,y)`

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

) providing the values of the covariate at any location, or one of the strings`"x"`

or`"y"`

- ...
- Additional arguments passed to
`density.ppp`

to smooth the scatterplots. - method
- Character string determining the smoothing method. See Details.

##### Details

This is a bivariate version of `rhohat`

.
If `object`

is a point pattern, this command
produces a smoothed version of the scatterplot of
the values of the covariates `cov1`

and `cov2`

observed at the points of the point pattern.

The covariates `cov1,cov2`

must have continuous values.
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_1(u), Z_2(u)) \kappa(u)$$
where $\kappa(u)$ is the intensity of the fitted model
`object`

, and $\rho(z_1,z_2)$ is a function
to be estimated. The algorithm computes a smooth estimate of the
function $\rho$.

The `method`

determines how the density estimates will be
combined to obtain an estimate of $\rho(z_1, z_2)$:

- If
`method="ratio"`

, then$\rho(z_1, z_2)$is estimated by the ratio of two density estimates. The numerator is a (rescaled) density estimate obtained by smoothing the points$(Z_1(y_i), Z_2(y_i))$obtained by evaluating the two covariate$Z_1, Z_2$at the data points$y_i$. The denominator is a density estimate of the reference distribution of$(Z_1,Z_2)$. - If
`method="reweight"`

, then$\rho(z_1, z_2)$is estimated by applying density estimation to the points$(Z_1(y_i), Z_2(y_i))$obtained by evaluating the two covariate$Z_1, Z_2$at the data points$y_i$, with weights inversely proportional to the reference density of$(Z_1,Z_2)$.

##### Value

- A pixel image (object of class
`"im"`

). Also belongs to the special class`"rho2hat"`

which has a plot method.

##### 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.

##### See Also

##### Examples

```
data(bei)
attach(bei.extra)
plot(rho2hat(bei, elev, grad))
fit <- ppm(bei, ~polynom(elev, 3), covariates=bei.extra)
plot(rho2hat(fit, elev, grad))
plot(rho2hat(fit, elev, grad, method="reweight"))
```

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