github.com-jerryratcliffe-aoristic_-_2021-01-31_22-30-35
Item Preview
Share or Embed This Item
Flag this item for
- Publication date
- 2021-01-31
R package for aoristic analysis
aoristic
The goal of aoristic is to make sense of temporally vague data. It cansometimes be difficult to ascertain when some events (such as propertycrime) occur because the victim is not present when the crime happens Asa result, police databases often record a start (or from) date andtime, and an end (or to) date and time. The start datetime usuallyreferences when the victim last saw their stolen property, and the todate-time records when they first discovered their property missing. Theperiod between the start datetime and end date-time is referred toas the event’s time span.
The time span between these date-times can be minutes, hours, orsometimes days: hence the term ‘Aoristic’, a word meaning “denotingsimple occurrence of an action without reference to its completeness,duration, or repetition”. It has its origins in the Greek wordaoristos which means undefined. For events with a location describeswith either a latitude/longitude or X,Y coordinate pair, and a start andend date-time, this package generates an aoristic data frame withaoristic weighted probability values for each hour of the week, for eachrow. Various descriptive and graphic outputs are available.
What’s new in Version 1.1.0?
- This version removes a convoluted process of outputting a formattedtable to a jpeg with a simpler mechanism. This avoids the userdownloading a third-party software package. The change occurs in the‘aoristic.summary’ function.
- Adds a simple plot output option with new function ‘aoristic.plot’
Previous versions
Version 1.0.0
Version 0.6 was originally released on CRAN in 2015 by Dr. GeorgeKikuchi then of Fresno State University and now at the PhiladelphiaPolice Department. Given his extensive responsibilities he has beenunable to maintain and update the program since the initial release.With his permission, the package has been taken over in 2020 and updatedby Dr. Jerry Ratcliffe of Temple University.
Much of the original functionality has been discontinued and replaced bythis updated package. In particular, version 1.0.0 onwards dispenseswith rounding to the nearest hour for time spans, and uses aminute-by-minute method. In earlier versions (as was common in aoristicapproaches until recently) time spans were rounded to the hour. So anevent that happened between 10.55am and 11.55am would have an aoristicweight of 0.5 assigned to each hour, 1000-1059 and 1100-1159. This isdespite the majority of the event occurring in the 11am hour. Thatrounding is removed in version 1.0.0 and aoristic weightings areassigned by the minute.
The kml mapping function from v0.6 is replaced here with a simpler plotfunction that maps the individual points for an user-selected hour. See?aoristic.map
There is a new graph function that plots the overall aoristicdistribution for an entire week, as well as each individual day of theweek. see ?aoristic.graph
There is some rudimentary data checking in aoristic; however, most userswill find that their effort is getting the date-time variables into thecorrect format. See the formatting example below for guidance.
Installation
You can install the released version of aoristic fromCRAN with:
rinstall.packages("aoristic")
And the development version from GitHub with:
``` r
install.packages("devtools")
devtools::install_github("jerryratcliffe/aoristic")```
Data formatting example
The package has some limited error checking; however, the main challengethat users will face is getting the data into the correct datetimeformat. Most of the heavy lifting is done by the aoristic.df() function.The user passes the name of a data frame and four parametersrepresenting columns that contain
Xcoord a vector of the event X coordinate or latitude (passedthrough for user)
Ycoord a vector of the event Y coordinate or longitude (passedthrough for user)
DateTimeFrom a vector for the ‘From’ datetime (POSIXct date-timeobject)
DateTimeTo a vector for the ‘To’ datetime (POSIXct date-timeobject)
The package ‘lubridate’ is recommended as a way to more easily get thedate time data into the correct format. As a demonstration, consider oneof the datasets available in the aoristic package.
``` rlibrary(aoristic)data(NYburg)head(NYburg)
> CMPLNTFRDT CMPLNTFRTM CMPLNTTODT CMPLNTTOTM XCOORDCD YCOORDCD
> 30 2019-01-04 0.6180556 2019-01-04 0.6444444 982546 206109
> 78 2019-01-01 0.7847222 2019-01-01 0.7909722 985962 202878
> 127 2019-01-01 0.3125000 2019-01-01 0.3361111 999874 238251
> 203 2019-01-02 0.5416667 2019-01-02 0.7708333 1001526 243602
> 216 2019-01-04 0.7500000 2019-01-04 0.8333333 983355 211219
> 233 2019-01-01 0.2083333 2019-01-01 0.3361111 999874 238251
```
The data consist of the crime from date (CMPLNT_FR_DT) and time(CMPLNT_FR_TM), the crime to date and time (CMPLNT_TO_DT andCMPLNT_TO_TM), and X and Y coordinates of the crime event. Datapreparation in this case will involve three steps (for START and ENDdate-times): 1. Convert the times from (Excel originated) fractions ofthe day 2. Combine the dates and times into a new variable 3. Convertthe new variable into a date-time format
1. Convert times
The two time variables are in fractions of the day. We can replace theexisting variables by recasting them in a more readable format, and viewthe result.
``` rNYburg$CMPLNTFRTM <- format(as.POSIXct((NYburg$CMPLNTFRTM) * 86400, origin = "1970-01-01"), "%H:%M")NYburg$CMPLNTTOTM <- format(as.POSIXct((NYburg$CMPLNTTOTM) * 86400, origin = "1970-01-01"), "%H:%M")head(NYburg)
> CMPLNTFRDT CMPLNTFRTM CMPLNTTODT CMPLNTTOTM XCOORDCD YCOORDCD
> 30 2019-01-04 09:50 2019-01-04 10:28 982546 206109
> 78 2019-01-01 13:50 2019-01-01 13:59 985962 202878
> 127 2019-01-01 02:30 2019-01-01 03:03 999874 238251
> 203 2019-01-02 08:00 2019-01-02 13:30 1001526 243602
> 216 2019-01-04 13:00 2019-01-04 15:00 983355 211219
> 233 2019-01-01 00:00 2019-01-01 03:03 999874 238251
```
2. Combine dates and times
The aoristic functions expect the date and time variables to be in asingle column, with a space separating them. We can do that with thiscode, which creates two new variables:
``` rNYburg$STARTDateTime <- paste(NYburg$CMPLNTFRDT,NYburg$CMPLNTFRTM, sep=' ')NYburg$ENDDateTime <- paste(NYburg$CMPLNTTODT,NYburg$CMPLNTTOTM, sep=' ')head(NYburg)
> CMPLNTFRDT CMPLNTFRTM CMPLNTTODT CMPLNTTOTM XCOORDCD YCOORDCD
> 30 2019-01-04 09:50 2019-01-04 10:28 982546 206109
> 78 2019-01-01 13:50 2019-01-01 13:59 985962 202878
> 127 2019-01-01 02:30 2019-01-01 03:03 999874 238251
> 203 2019-01-02 08:00 2019-01-02 13:30 1001526 243602
> 216 2019-01-04 13:00 2019-01-04 15:00 983355 211219
> 233 2019-01-01 00:00 2019-01-01 03:03 999874 238251
> STARTDateTime ENDDateTime
> 30 2019-01-04 09:50 2019-01-04 10:28
> 78 2019-01-01 13:50 2019-01-01 13:59
> 127 2019-01-01 02:30 2019-01-01 03:03
> 203 2019-01-02 08:00 2019-01-02 13:30
> 216 2019-01-04 13:00 2019-01-04 15:00
> 233 2019-01-01 00:00 2019-01-01 03:03
```
3. Convert new variables into date-time objects
The past stage is to use the convenience of the lubridate package toconvert the string of dates and times into a date-time object:
``` rlibrary(lubridate)
>
> Attaching package: 'lubridate'
> The following objects are masked from 'package:base':
>
> date, intersect, setdiff, union
NYburg$STARTDateTime <- ymdhm(NYburg$STARTDateTime, tz = "")NYburg$ENDDateTime <- ymdhm(NYburg$ENDDateTime, tz = "")
> Warning: 49 failed to parse.
```
You get a warning that 49 observations failed to parse, because they aremissing data (= NA). This sometimes happens when the police knowexactly when the crime took place, and they only record the startdate-time. We can see the final result of all this formatting:
``` rhead(NYburg)
> CMPLNTFRDT CMPLNTFRTM CMPLNTTODT CMPLNTTOTM XCOORDCD YCOORDCD
> 30 2019-01-04 09:50 2019-01-04 10:28 982546 206109
> 78 2019-01-01 13:50 2019-01-01 13:59 985962 202878
> 127 2019-01-01 02:30 2019-01-01 03:03 999874 238251
> 203 2019-01-02 08:00 2019-01-02 13:30 1001526 243602
> 216 2019-01-04 13:00 2019-01-04 15:00 983355 211219
> 233 2019-01-01 00:00 2019-01-01 03:03 999874 238251
> STARTDateTime ENDDateTime
> 30 2019-01-04 09:50:00 2019-01-04 10:28:00
> 78 2019-01-01 13:50:00 2019-01-01 13:59:00
> 127 2019-01-01 02:30:00 2019-01-01 03:03:00
> 203 2019-01-02 08:00:00 2019-01-02 13:30:00
> 216 2019-01-04 13:00:00 2019-01-04 15:00:00
> 233 2019-01-01 00:00:00 2019-01-01 03:03:00
```
With the data formatted properly, we can start to use the aoristicfunctions. For example, you should always check the data to familiarizeyourself with any missing data, or to see if any observations havelogical errors where the from date-time occurs before the to date-time.The aoristic.df function can handle this, but it is always good to knowyour data.
``` raor.chk.df <- aoristic.datacheck(NYburg, 'XCOORDCD', 'YCOORDCD', 'STARTDateTime', 'ENDDateTime')
>
> ---- Aoristic data check -------------------------------------------
> 49 rows were missing END/TO datetime values.
> 40 rows had END/TO datetimes before START/FROM datetimes.
> In the aoristic.datacheck data frame these rows are indicated
> with missing end datetimes = 1 and start/end logical errors = 2
> See the aoristic.datacheck column. Also see ?aoristic.datacheck
> Coordinates check:
> No missing or zero coordinates.
```
To restore the repository download the bundle
wget https://archive.org/download/github.com-jerryratcliffe-aoristic_-_2021-01-31_22-30-35/jerryratcliffe-aoristic_-_2021-01-31_22-30-35.bundle
and run: git clone jerryratcliffe-aoristic_-_2021-01-31_22-30-35.bundle
Source: https://github.com/jerryratcliffe/aoristic
Uploader: jerryratcliffe
Upload date: 2021-01-31
- Addeddate
- 2021-07-06 16:31:32
- Identifier
- github.com-jerryratcliffe-aoristic_-_2021-01-31_22-30-35
- Originalurl
-
https://github.com/jerryratcliffe/aoristic
- Pushed_date
- 2021-01-31 22:30:35
- Scanner
- Internet Archive Python library 1.9.9
- Uploaded_with
- iagitup - v1.6.2
- Year
- 2021