Exercise

# Violent crime proportion estimation

One method of computing a smooth intensity surface from a set of points is to use *kernel smoothing*.
Imagine replacing each point with a dot of ink on absorbent paper. Each individual ink drop spreads out into a
patch with a dark center, and multiple drops add together and make the paper even darker. With the right amount
of ink in each drop, and with paper of the right absorbency, you can create a fair impression of the density
of the original points. In kernel smoothing jargon, this means computing a *bandwidth* and using a particular
*kernel function*.

To get a smooth map of violent crimes proportion, we can estimate the
intensity surface for violent and non-violent crimes, and take the
ratio. To do this with the `density()`

function in `spatstat`

, we have to
split the points according to the two values of the marks and then
compute the ratio of the violent crime surface to the total. The function
has sensible defaults for the kernel function and bandwidth to guarantee
something that looks at least plausible.

Instructions

**100 XP**

The `preston_crime`

object and `spatstat`

have been loaded.

- The
`split()`

function in`spatstat`

will divide a marked point pattern by a categorical mark and return a list of point patterns. Split`preston_crime`

and assign the result to`crime_splits`

. - Plot
`crime_splits`

by calling`plot()`

, with no other arguments. - The
`density()`

function will work on a list of point patterns and return a list of densities. Calculate the densities of`crime_splits`

and assign the result to`crime_densities`

. - Calculate the density of the fraction of violent crimes.
- You can use
`[[i]]`

indexing to get the`i`

-th density from a split list.. - Basic arithmetic operators (such as
`+`

,`-`

,`*`

and`/`

) can be used on densities. - Assign the result to
`frac_violent_crime_density`

.

- You can use
- Plot
`frac_violent_crime_density`

by calling`plot()`

, with no other arguments.