-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accuracy / confidence interval? #15
Comments
A (crude and somewhat contrived) example could be:
|
Hey @RomanAbashin! Interesting, so you'd hope to combine the accuracy of pairs of individuals and add that to the distance matrix, before considering the threshold? This is a ± accuracy right? What kind of GPS data is this? |
I have another idea, what about combining your accuracy columns with I'm hoping to (optionally) return the distances between individuals with
Then you could merge your accuracy values, e.g.:
generating:
and finally, you could sum the accuracy and see if the distance is within the accuracy and the actual threshold, maybe setting the threshold in the Does that make sense? |
Hi @robitalec , The data I'm working with is basically dumped smartphone location data. It looks roughly like this:
Let's take row 4: it means that, at 12:17:28, User A was somewhere in a radius of 16.1 meters around the lon / lat coordinates As you see, every observation of each user's position has its own accuracy (= radius). Therefore, the method mentioned above (with a fixed accuracy parameter) would not work, right? You are, however, right on the money with the end goal: I would like to build dyadic groups of users — but the varying accuracy of observations (which is inevitable due to different environmental and technological factors) is a pain in the behind. |
@RomanAbashin, if every row has a different accuracy measurement than you could do the same join I describe above, but making sure to include the timegroup in the join. To update you, I just merged the optional distance return for e.g.: library(spatsoc)
library(data.table)
# Read package example data
DT <- fread(system.file("extdata", "DT.csv", package = "spatsoc"))
# Cast the character column to POSIXct
DT[, datetime := as.POSIXct(datetime, tz = 'UTC')]
# Temporal grouping
group_times(DT, datetime = 'datetime', threshold = '20 minutes')
# !! --- Fake an accuracy column, which differs for each individual and fix ---
DT[, accuracy := runif(.N, 3, 50)]
# Edge list generation
edges <- edge_dist(
DT,
threshold = 100,
id = 'ID',
coords = c('X', 'Y'),
timegroup = 'timegroup',
returnDist = TRUE,
fillNA = TRUE
)
# !! --- Merge ---
m1 <- merge(
edges,
DT[, .(ID, timegroup, accuracy1 = accuracy)],
by.x = c('ID1', 'timegroup'),
by.y = c('ID', 'timegroup')
)
m2 <- merge(
m1,
DT[, .(ID, timegroup, accuracy2 = accuracy)],
by.x = c('ID2', 'timegroup'),
by.y = c('ID', 'timegroup')
)
Then you could combine your accuracy measurements with the distance between individuals. And this is where I was talking about selecting a threshold for your case, maybe it being a combination of the maximum combination of possible pairs of accuracies and the intended threshold, then subsetting by the accuracy adjusted distances afterwards. Let me know how that sounds! |
@robitalec — Ha, this is fantastic! This is pretty much what I'm doing by hand with left joins and one run of an adapted |
Having that in mind, would maybe something like a |
You're welcome. (I'll respond there) |
Hey guys, fantastic package. Love the use of data.table.
One question: I am working with semi-processed GPS data that has an accuracy variable attached. This accuracy variable indicates the 95% confidence interval (in meters radius) around the unprojected lon / lat coordinates.
For example, with coordinates of
c(5, 42)
andacc = 15
the subject was somewhere ±15 meters around the specified coordinates. This accuracy can also change with every observation of every subject. Essentially, this can be thought of as extending the threshold of one subject-observation tothresh <- thresh + 2 * acc
.Is there a way to deal with this complication in your package?
The text was updated successfully, but these errors were encountered: