Title: | Half-Weight Index Gregariousness |
Version: | 0.0.2 |
Description: | The half-weight index gregariousness (HWIG) is an association index used in social network analyses. It extends the half-weight association index (HWI), correcting for level of gregariousness in individuals. It is calculated using group by individual data according to methods described in Godde et al. (2013) <doi:10.1016/j.anbehav.2012.12.010>. |
License: | GPL-3 |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 7.1.2 |
Depends: | R (≥ 2.10) |
Imports: | asnipe, spatsoc, data.table |
Suggests: | testthat |
BugReports: | https://github.com/robitalec/hwig/issues |
URL: | https://gitlab.com/robit.a/hwig, https://github.com/robitalec/hwig |
NeedsCompilation: | no |
Packaged: | 2021-09-30 06:22:36 UTC; alecr |
Author: | Alec L. Robitaille
|
Maintainer: | Alec L. Robitaille <robit.alec@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2021-09-30 11:50:09 UTC |
Example data for input to 'hwig'
Description
Example data for input to 'hwig'
Format
A data.table with 14297 rows and 3 variables:
- ID
individual identifier
- year
integer representing the year
Source
# Load packages library(spatsoc) library(data.table)
# Read 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')
# Spatial grouping with timegroup group_pts( DT, threshold = 5, id = 'ID', coords = c('X', 'Y'), timegroup = 'timegroup' )
fwrite(DT[, .(id = ID, group, yr = year(datetime))], 'inst/extdata/DT.csv')
Examples
# Load data.table
library(data.table)
# Read example data
DT <- fread(system.file("extdata", "DT.csv", package = "hwig"))
Calculate HWI
Description
Calculates the Half-Weight Association Index
Usage
calc_hwi(DT, id, group, by = NULL)
Arguments
DT |
input group membership data, in individual/group format |
id |
column indicating id in DT |
group |
column indicating group in DT |
by |
column(s) to split calculation by. e.g.: year |
Details
Expects an input 'DT' with id and group column, e.g. as returned by group_pts.
Value
HWI data.table or list of data.tables.
See Also
Examples
# Load data.table
library(data.table)
# Load example data
DT <- fread(system.file("extdata", "DT.csv", package = "hwig"))
# Calculate HWI
hwi <- calc_hwi(DT, 'id', 'group', 'yr')
Calculate HWIG
Description
Calculates the Half-Weight Association Index according to the method described in Godde et al. (2013).
Usage
calc_hwig(hwi)
Arguments
hwi |
output of calc_hwi. Either a data.table or a list of data.tables. See Details. |
Details
It is expected that the input 'hwi' is the output from 'calc_hwi'. If 'by' was provided in that function, 'hwi' will be a list of data.tables. Alternatively if ‘by' wasn’t provided, 'hwi' will be a single data.table.
Value
HWIG data.table or list of data.tables.
References
Sophie Godde, Lionel Humbert, Steeve D. Côté, Denis Réale, Hal Whitehead. Correcting for the impact of gregariousness in social network analyses. Animal Behaviour. Volume 85, Issue 3. 2013.
See Also
Examples
# Load data.table
library(data.table)
# Load example data
DT <- fread(system.file("extdata", "DT.csv", package = "hwig"))
# Calculate HWI
hwi <- calc_hwi(DT, 'id', 'group', 'yr')
# Calculate HWIG
hwig <- calc_hwig(hwi)
Get HWI/HWIG names
Description
Helper function, to return names of each matrix
Usage
get_names(DT, by)
Arguments
DT |
input group membership data, in individual/group format |
by |
column(s) to split calculation by. e.g.: year |
Value
names corresponding to values of by for each of the returned list of matrices in calc_hwi and calc_hwig.
See Also
Examples
# Load data.table
library(data.table)
# Load example data
DT <- fread(system.file("extdata", "DT.csv", package = "hwig"))
# Calculate HWI
hwi <- calc_hwi(DT, 'id', 'group', 'yr')
# Calculate HWIG
hwig <- calc_hwig(hwi)
# Set names
nms <- get_names(DT, 'yr')
names(hwig) <- nms