fn_prepare_suspect_data: Prepare suspect data for GP-SMART

View source: R/fn_prepare_suspect_data.R

fn_prepare_suspect_dataR Documentation

Prepare suspect data for GP-SMART

Description

Checks that the minimum necessary variables are present and calculates additional attributes needed for fn_gpsmart().

Usage

fn_prepare_suspect_data(input_suspects_raw)

Arguments

input_suspects_raw

A data frame with at least one row and 14 columns:

person_id

A unique reference number for the suspect. Can be a character or numeric vector.

death_date

Suspect's date of death if deceased. A date in format "YYYY-MM-DD"

x

Easting coordinate. Must be in metres to enable distance calculations.

y

Northing coordinate. Must be in metres to enable distance calculations.

node_category

The general category of the activity location. A character vector with values "span" or "event". Span and event nodes are treated differently when calculating activity node attributes.

node_type

The type of activity location. A factor with levels "home", "family_immediate", "family_ip", "family_other", "school", "work", "offence", "victim_witness", "incident", "police_other". Node type determines some activity node attribute values.

prior_offence_type

The type of offence, if it's an offence activity location and one of the crime types for which GP-SMART is currently calibrated. A factor with levels "burglary", "robbery" or "sex", being the crimes GP-SMART is calibrated for. Used for calculating behaviour similarity.

span_start_date

Start date of the activity location, if a span node. A date in format "YYYY-MM-DD".

span_end_date

End date of the activity location, if an event node. A date in format "YYYY-MM-DD".

event_start_date

Start date of the event, if an event node. A date in format "YYYY-MM-DD".

event_end_date

End date of the event, if an event node. A date in format "YYYY-MM-DD".

event_start_time

Start time of the event, if an event node. A difftime in format "HH:MM:SS". Time is not present for "police_other" event nodes in the package data.

event_end_time

End time of the event, if an event node. A difftime in format "HH:MM:SS". Time is not present for "police_other" event nodes in the package data.

location_type

The type of location in which the crime was committed. A factor with levels "residential", "commercial", "public", "street" or "unknown".

Details

  • The function will return an error if the input does not contain the correct columns in the correct format.

  • Season variables are based on Southern Hemisphere.

Value

A data frame the same as the input with 7 additional columns:

  • event_date_time_randomRandom date-time generated for event nodes.

  • daypartThe day part of the node. A factor with levels "daytime", "evening", "night" or "all".

  • weekpartThe week part of the activity node. A factor with levels "weekday", "weekend" or "both".

  • springWhether the node dates include any days in spring (1 = yes, 0 = no)

  • summerWhether the node dates include any days in summer (1 = yes, 0 = no)

  • autumnWhether the node dates include any days in autumn (1 = yes, 0 = no)

  • winterWhether the node dates include any days in winter (1 = yes, 0 = no)

Author(s)

Sophie Curtis-Ham

See Also

  • fn_prepare_input_crime() checks that the minimum necessary variables are present and creates the input_crime data frame for use in fn_gpsmart().

  • fn_gpsmart() filters and ranks input_suspects based on their probability of committing the input_crime.

Examples

## Not run: 
data(example_input_suspects_raw)
fn_prepare_supect_data(example_input_suspects_raw)

## End(Not run)


Sophie-c-h/gpsmartr documentation built on April 13, 2022, 5:51 p.m.