Package 'socialh'

Title: Rank and Social Hierarchy for Gregarious Animals
Description: Tools developed to facilitate the establishment of the rank and social hierarchy for gregarious animals by the Si method developed by Kondo & Hurnik (1990)<doi:10.1016/0168-1591(90)90125-W>. It is also possible to determine the number of agonistic interactions between two individuals, sociometric and dyadics matrix from dataset obtained through electronic bins. In addition, it is possible plotting the results using a bar plot, box plot, and sociogram.
Authors: Julia de Paula Soares Valente [aut, cre] , Matheus Deniz [aut, ctb] , Karolini Tenffen de Sousa [aut, ctb]
Maintainer: Julia de Paula Soares Valente <[email protected]>
License: GPL-3
Version: 0.1.1
Built: 2024-10-30 06:52:24 UTC
Source: CRAN

Help Index


Sociogram with actor information

Description

Function to obtain the circle diagram with actor relationship from an sociomatrix.

Usage

actorSociogram(smatrix)

Arguments

smatrix

sociomatrix

Details

The function actorSociogram is obtained by the sociometric matrix. Return a circular diagram with actor relationship between the animals, where the arrow shows the direction of the relationship and the line thickness indicates the number of encounters (the thicker the line, the greater the number of encounters).

Value

Circular plot with actor information

Author(s)

Julia P. S. Valente, Matheus Deniz, Karolini T. de Sousa.

Examples

"There is no example"

NULL

Barplot from the variables obtained in the dvalue

Description

Generates a barplot from the variables obtained in the dvalue function (dominance value, social hierarchy and social rank)

Usage

barDom(dvalue, variable)

Arguments

dvalue

Dominance value

variable

the column with social hierarchy or social rank information.

Details

It is a function that plots the social hierarchy or social rank information of a group in a barplot. The function uses the options provided by ggplot2.

Value

histogram of social dominance

Author(s)

Julia P. S. Valente, Matheus Deniz, Karolini T. de Sousa.

Examples

"There is no example"
NULL

Boxplot

Description

Function to obtain the boxplot of social hierarchy categories from dvalue function.

Usage

bpDom(y, x)

Arguments

y

the column with animal information.

x

the column with social hierarchy or social rank information.

Details

It is a simple function that plots the social hierarchy or social rank information of a group in a boxplot. The function uses the options provided by ggplot2.

Value

boxplot of social hierarchy or social rank

Author(s)

Julia P. S. Valente, Matheus Deniz, Karolini T. de Sousa.

Examples

"There is no example"

NULL

Sij dyadic relationship matrix

Description

Function to obtain the Sij dyadic dominance relationship from an sociomatrix.

Usage

dmatrix(smatrix)

Arguments

smatrix

sociomatrix

Details

The dyadic relationship is obtained by the following expression: Sij = (Xij - Xji) / (|Xij - Xji|), where Sij is the social status of the ith animal relative to the jth animal; Xij is the number of times the animal i won the animal j; Xji is the number of times the animal j won the animal i.

Value

Dyadic matrix

Author(s)

Julia P. S. Valente, Matheus Deniz, Karolini T. de Sousa.

References

Kondo, S., & Hurnik, J. F. (1990). Stabilization of social hierarchy in dairy cows. Applied Animal Behaviour Science, 27(4), 287-297.

Examples

x <- matrix(c(0,0,1,0,0,1,0,0,2,0,0,0,0,1,0,0,0,1,0,0,2,
             0,0,0,0,1,1,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,
             1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
             nrow=8,byrow=TRUE,)
colnames(x) <- c(1,2,3,4,5,6,8,9)

rownames(x) <- c(1,2,3,4,5,6,8,9)

dyadic <- dmatrix(x)

print(dyadic)

Dominance value

Description

Function to obtain the dominance value, social rank and hierarchy from Sij dyadic relationship matrix.

Usage

dvalue(dmatrix)

Arguments

dmatrix

Sij dyadic relationship matrix

Details

The social categories (rank and hierarchy) are define according to dominance value and is obtained by the following expression: SH =(|Distance between highest(+ X) and lowest(- Y) dominance value| + 1) /(2 or 3), where "SH" is the rank or hierarchy. The rank (high and lower) and social category (dominant, intermediate and subordinate) are determined assigned according to dominance value. The choice for divide the group by rank or social category depends of the study objective. Both rank and social category are estimated by the distance between the highest (+ X) and the lowest (- Y) dominance value, plus 1 (corresponds to the dominance value zero), which determines the number of points in the range.

Value

dominance value, social rank and social hierarchy

Author(s)

Julia P. S. Valente, Matheus Deniz, Karolini T. de Sousa.

References

Coimbra, P. A. D., Machado Filho, L. C. P., & Hötzel, M. J. (2012). Effects of social dominance, water trough location and shade availability on drinking behaviour of cows on pasture. Applied Animal Behaviour Science, 139(3-4), 175-182.

Examples

x <- matrix(c(0,-1,1,0,-1,1,0,0,1,0,-1,-1,0,1,0,0,
             -1,1,0,-1,1,-1,0,0,0,1,1,0,-1,0,0,0,
             1,0,-1,1,0,0,1,0,-1,-1,1,0,0,0,0,1,
             0,0,0,0,-1,0,0,0,0,0,0,0,0,-1,0,0),
             nrow=8,byrow=TRUE,)
             
colnames(x) <- c(1,2,3,4,5,6,8,9)

rownames(x) <- c(1,2,3,4,5,6,8,9)

dominance <- dvalue(x)

print(dominance)

Feeding event data from Nellore cattle

Description

A database obtained from feed efficiency test of beef cattle to illustrate the functions of the socialh package.

Usage

feeding_event_data

Format

A data frame with 90211 rows and 7 variables:

equip_id

equipament identification

animal_id

animal identification

IN

date and time (dd/mm/yyyy and hour:minutes:seconds) when the animal entered at the electronic bin

OUT

date and time (dd/mm/yyyy and hour:minutes:seconds) when the animal left the electronic bin

duration (s)

duration of the feeding event in seconds

consumption (g)

amount of food consumed during the visit to the bin in grams

pen

pen identification

Source

https://www.kaggle.com/datasets/juliavalente/data-from-visits-to-the-trough-of-nellore-cattle

Examples

data(feeding_event_data)

Frequency of an animal was actor

Description

Function to identify frequency that one animal was actor regarding the herd at bins.

Usage

freqActor(x)

Arguments

x

dataset with replacements information.

Details

freqActor is only applied for dataset with columns ordained and named as follows: actor and reactor.

Value

Frequency of an animal was an actor

Author(s)

Julia P. S. Valente, Matheus Deniz, Karolini T. de Sousa.

Examples

x <- data.frame(actor = c(6,3,5,4,2,1,3,5,8,6,9,3,2,1,1),
               reactor = c(2,6,3,5,4,2,1,3,5,1,6,4,3,2,5))                
                                   
freqA <- freqActor(x)                                                
                                                           
print(freqA)

Frequency of an animal was reactor

Description

Function to identify frequency that one animal was reactor regarding the herd at bins.

Usage

freqReactor(x)

Arguments

x

dataset with replacements information.

Details

freqReactor is only applied for dataset with columns ordained and named as follows: actor and reactor.

Value

Frequency of an animal was an reactor

Author(s)

Julia P. S. Valente, Matheus Deniz, Karolini T. de Sousa.

Examples

x <- data.frame(actor = c(6,3,5,4,2,1,3,5,8,6,9,3,2,1,1),
               reactor = c(2,6,3,5,4,2,1,3,5,1,6,4,3,2,5))                
                                   
freqR <- freqReactor(x)                                                
                                                           
print(freqR)

Improved linearity index

Description

Function to obtain the linearity index improved by de Vries (1995).

Usage

improved_index(dmatrix, smatrix)

Arguments

dmatrix

dyatic matrix

smatrix

sociomatrix

Details

The function improved_index is obtained by the following expression: h' = h(6/(n^3-n)*u), where "h'" is the linearity index, "n" is the total of animals, "u" is the unknown or tied relationships.

Value

h' index

Author(s)

Julia P. S. Valente, Matheus Deniz, Karolini T. de Sousa.

References

de Vries, H. (1995). An improved test of linearity in dominance hierarchies containing unknown or tied relationships. Animal Behaviour, 50(5), 1375–1389.

See Also

dmatrix, smatrix


Landau index

Description

Function to obtain the linearity index developed by Landau (1951).

Usage

landau_index(dmatrix)

Arguments

dmatrix

dyadic matrix

Details

The function landau_index is obtained by the following expression: h = (12/n^3-n)* sum(Va - ((n-1)/2))^2, where "h" is the linearity index, "n" is the total of animals, "Va" is the total of times that animal "i" dominated other animals.

Value

h index

Author(s)

Julia P. S. Valente, Matheus Deniz, Karolini T. de Sousa.

References

Landau, H. G. (1951). On dominance relations and the structure of animal societies: I. Effect of inherent characteristics. Bulletin of Mathematical Biophysics, 13, 1-19.

See Also

dmatrix


Sociogram plot with reactor information

Description

Function to obtain the circle diagram with reactor relationship from an sociomatrix.

Usage

reactorSociogram(smatrix)

Arguments

smatrix

sociomatrix

Details

The function reactorCircleDiagram is obtained by the sociometric matrix. Return a circular diagram with reactor relationship between the animals, where the arrow shows the direction of the relationship and the line thickness indicates the number of encounters (the thicker the line, the greater the number of encounters).

Value

Circular plot with reactor information

Author(s)

Julia P. S. Valente, Matheus Deniz, Karolini T. de Sousa.

Examples

"There is no example"

NULL

Frequency of replacements by bin

Description

Function to identify frequency of replacements by bin from electronic bin data.

Usage

repByBin(x, sec)

Arguments

x

dataset with electronic bins information.

sec

optimal interval (in seconds) between two different animals sequentially visited the same bin (feeder or drinker) to identify a replacement;

Details

repByBin is only applied for dataset with columns named as follows: equip_id (bin identification), animal_id (animal identification), IN (date - dd/mm/yyyy - and time - hh:mm:ss - when the animal entry in the bin), OUT (date - dd/mm/yyyy - and time - hh:mm:ss - when the animal left the bin).

Value

Frequency of replacements by bin

Author(s)

Julia P. S. Valente, Matheus Deniz, Karolini T. de Sousa.

Examples

x <- data.frame(equip_id = as.numeric("0001"), 
               animal_id = c(1,2,6,3,5,4,2,1,3,5,8,1,6,9,4,3,2,1,5,1))

x$IN <-  c("01/08/2017 00:03:42","01/08/2017 00:05:26","01/08/2017 00:07:04","01/08/2017 00:08:15",
          "01/08/2017 00:10:35","01/08/2017 00:15:07","01/08/2017 00:18:13","01/08/2017 00:21:48",
          "01/08/2017 00:23:55","01/08/2017 00:30:14","01/08/2017 00:35:00","01/08/2017 00:38:11",
          "01/08/2017 00:39:05","01/08/2017 00:40:20","01/08/2017 00:42:08","01/08/2017 00:46:00",
          "01/08/2017 00:48:12","01/08/2017 00:49:40","01/08/2017 00:50:57","01/08/2017 00:52:36")

x$OUT <-c("01/08/2017 00:05:24","01/08/2017 00:06:56","01/08/2017 00:08:12","01/08/2017 00:10:32",
         "01/08/2017 00:15:04","01/08/2017 00:18:10","01/08/2017 00:21:41","01/08/2017 00:23:53",
         "01/08/2017 00:30:10","01/08/2017 00:34:56","01/08/2017 00:37:32","01/08/2017 00:39:03",
         "01/08/2017 00:40:10","01/08/2017 00:41:51","01/08/2017 00:45:56","01/08/2017 00:48:10",
         "01/08/2017 00:49:36","01/08/2017 00:50:33","01/08/2017 00:52:32","01/08/2017 00:55:34")

bins <- repByBin(x,10)

print(bins)

Identification of replacements between two animals

Description

Function to identify replacements between actor and reactor from electronic bins data.

Usage

replacement(x, sec)

Arguments

x

dataset with electronic bins information.

sec

optimal interval (in seconds) between two different animals sequentially visited the same bin (feeder or drinker) to identify a replacement;

Details

replacement is only applied for dataset with columns named as follows: equip_id (bin identification), animal_id (animal identification), IN (date - dd/mm/yyyy - and time - hh:mm:ss - when the animal entry in the bin), OUT (date - dd/mm/yyyy - and time - hh:mm:ss - when the animal left the bin).

Value

Replacement between two animals

Author(s)

Julia P. S. Valente, Matheus Deniz, Karolini T. de Sousa.

Examples

x <- data.frame(equip_id = as.numeric("0001"), 
               animal_id = c(1,2,6,3,5,4,2,1,3,5,8,1,6,9,4,3,2,1,5,1))

x$IN <-  c("01/08/2017 00:03:42","01/08/2017 00:05:26","01/08/2017 00:07:04","01/08/2017 00:08:15",
          "01/08/2017 00:10:35","01/08/2017 00:15:07","01/08/2017 00:18:13","01/08/2017 00:21:48",
          "01/08/2017 00:23:55","01/08/2017 00:30:14","01/08/2017 00:35:00","01/08/2017 00:38:11",
          "01/08/2017 00:39:05","01/08/2017 00:40:20","01/08/2017 00:42:08","01/08/2017 00:46:00",
          "01/08/2017 00:48:12","01/08/2017 00:49:40","01/08/2017 00:50:57","01/08/2017 00:52:36")

x$OUT <-c("01/08/2017 00:05:24","01/08/2017 00:06:56","01/08/2017 00:08:12","01/08/2017 00:10:32",
         "01/08/2017 00:15:04","01/08/2017 00:18:10","01/08/2017 00:21:41","01/08/2017 00:23:53",
         "01/08/2017 00:30:10","01/08/2017 00:34:56","01/08/2017 00:37:32","01/08/2017 00:39:03",
         "01/08/2017 00:40:10","01/08/2017 00:41:51","01/08/2017 00:45:56","01/08/2017 00:48:10",
         "01/08/2017 00:49:36","01/08/2017 00:50:33","01/08/2017 00:52:32","01/08/2017 00:55:34")

replace <- replacement(x,14)

print(replace)

Sociomatrix

Description

Function to obtain the square matrix contained dyadic frequency of dominance-related behaviors (actor and reactor).

Usage

smatrix(x)

Arguments

x

Replacement or agonistic interaction data table.

Details

The fuction smatrix is only applied for data set with columns named as follows: actor and reactor. The function form a square matrix, in which the number of "n" actors is also the number of "n" reactors.

Value

Sociomatrix

Author(s)

Julia P. S. Valente, Matheus Deniz, Karolini T. de Sousa.

Examples

x <- data.frame(actor = c(6,3,5,4,2,1,3,5,8,6,9,3,2,1,1),
               reactor = c(2,6,3,5,4,2,1,3,5,1,6,4,3,2,5))                
                                   
sociomatrix <- smatrix(x)                                                
                                                           
print(sociomatrix)