-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added and abstracted spatial interaction functions
- Loading branch information
Showing
12 changed files
with
239 additions
and
316 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
# Author: Darren Colby | ||
# Date: 8/31/2021 | ||
# Purpose: To create spatial interaction functions for the NetSim class | ||
|
||
# Spatial interaction functions ------------------------------------------- | ||
|
||
|
||
#' Standard power law function | ||
#' | ||
#' @description helper function to estimate tie probability using a standard | ||
#' power law | ||
#' | ||
#' @usage standard(dist, base_prob, scale, power) | ||
#' | ||
#' @details This function should not be called directly | ||
#' | ||
#' @param dist the distance between a pair of points | ||
#' | ||
#' @return A numeric object representing the proability of two nodes sharing a | ||
#' connection | ||
#' | ||
#' @author Darren Colby | ||
#' Email: dscolby17@@gmail.com | ||
#' @noRd | ||
standard <- function(dist, base_prob, scale, power) { | ||
|
||
prob <- (base_prob / ((1 + (scale * dist)) ^ abs(power))) | ||
|
||
return(prob) | ||
|
||
} | ||
|
||
|
||
|
||
#' Attenuated power law function | ||
#' | ||
#' @description helper function to estimate tie probability using an attenuated | ||
#' power law | ||
#' | ||
#' @usage attenuated(dist, base_prob, scale, power) | ||
#' | ||
#' @details This function should not be called directly | ||
#' | ||
#' @param dist the distance between a pair of points | ||
#' | ||
#' @return A numeric object representing the proability of two nodes sharing a | ||
#' connection | ||
#' | ||
#' @author Darren Colby | ||
#' Email: dscolby17@@gmail.com | ||
#' @noRd | ||
attenuated <- function(dist, base_prob, scale, power) { | ||
|
||
prob <- (base_prob / (1 + (scale * dist) ^ abs(power))) | ||
|
||
|
||
return(prob) | ||
|
||
} | ||
|
||
|
||
#' Arctangent probability law | ||
#' | ||
#' @description helper function to estimate tie probability using an arctangent | ||
#' probability law | ||
#' | ||
#' @usage arctan(dist, base_prob, scale, power) | ||
#' | ||
#' @details This function should not be called directly | ||
#' | ||
#' @param dist the distance between a pair of points | ||
#' | ||
#' @return A numeric object representing the proability of two nodes sharing a | ||
#' connection | ||
#' | ||
#' @author Darren Colby | ||
#' Email: dscolby17@@gmail.com | ||
#' @noRd | ||
arctan <- function(dist, base_prob, scale, power) { | ||
|
||
prob <- base_prob * (1 - ((2 / pi) * atan((scale * dist)))) | ||
|
||
return(prob) | ||
|
||
} | ||
|
||
|
||
#' Exponential decay law | ||
#' | ||
#' @description helper function to estimate tie probability using an exponential | ||
#' decay law | ||
#' | ||
#' @usage decay(dist, base_prob, scale, power) | ||
#' | ||
#' @details This function should not be called directly | ||
#' | ||
#' @param dist the distance between a pair of points | ||
#' | ||
#' @return A numeric object representing the proability of two nodes sharing a | ||
#' connection | ||
#' | ||
#' @author Darren Colby | ||
#' Email: dscolby17@@gmail.com | ||
#' @noRd | ||
decay <- function(dist, base_prob, scale, power) { | ||
|
||
prob <- base_prob / exp((dist * scale)) | ||
|
||
return(prob) | ||
|
||
} | ||
|
||
|
||
#' Logistic probability law | ||
#' | ||
#' @description helper function to estimate tie probability using a logistic | ||
#' probability law | ||
#' | ||
#' @usage logistic(dist, base_prob, scale, power) | ||
#' | ||
#' @details This function should not be called directly | ||
#' | ||
#' @param dist the distance between a pair of points | ||
#' | ||
#' @return A numeric object representing the proability of two nodes sharing a | ||
#' connection | ||
#' | ||
#' @author Darren Colby | ||
#' Email: dscolby17@@gmail.com | ||
#' @noRd | ||
logistic <- function(dist, base_prob, scale, power) { | ||
|
||
prob <- (2 * base_prob) / (1 + (exp(dist * scale))) | ||
|
||
return(prob) | ||
} | ||
|
Oops, something went wrong.