Title Analyzing Social Hierarchies Type Package Version 0.1 Package copete August 29, 2016 Author c(person(``jaes P.'', ``Curley'', role = c(``aut'', ``cre''), eail = ``jc3181@colubia.edu'') Maintainer Jaes P. Curley <jc3181@colubia.edu> Organizing and Analyzing Social Doinance Hierarchy Data. Depends R (>= 3.1.0) License GPL-3 LazyData true Iports graphics, igraph, sna, stats, utils URL https://github.co/jalapic/copete BugReports https://github.co/jalapic/copete RoxygenNote 5.0.1 NeedsCopilation no Repository CRAN Date/Publication 2016-06-17 21:12:20 R topics docuented: bonobos........................................... 2 caribou........................................... 3 dci.............................................. 4 dc_test............................................ 5 devries............................................ 6 ds.............................................. 7 el.............................................. 7 get_di_atrix........................................ 8 get_wl_df.......................................... 9 1
2 bonobos get_wl_atrix........................................ 10 isi13............................................. 10 isi98............................................. 11 ouse............................................ 12 org_atrix.......................................... 13 people............................................ 14 phi.............................................. 14 randotourney....................................... 15 rshps............................................. 16 sparseness.......................................... 16 ttri.............................................. 17 ttri_test........................................... 18 unknowns.......................................... 18 Index 20 bonobos Bonobo socioatrix A win-loss socioatrix with each row being the nuber of wins against individual bonobos in each colun. bonobos Forat Details A data frae with 6 rows and 6 variables: Dz The nuber of losses by bonobo Dz against all other bonobos He The nuber of losses by bonobo He against all other bonobos De The nuber of losses by bonobo De against all other bonobos Ho The nuber of losses by bonobo Ho against all other bonobos Lu The nuber of losses by bonobo Lu against all other bonobos Ki The nuber of losses by bonobo Ki against all other bonobos Reference: Vervaecke, H., de Vries, H. & van Elsacker, L. 2000. Doinance and its behavioral easures in a captive group of bonobos (Pan paniscus). International Journal of Priatology, 21, 47-68.
caribou 3 caribou Caribou socioatrix Forat Details A win-loss socioatrix with each row being the nuber of wins against individual bonobos in each colun. caribou A data frae with 20 rows and 20 variables: a The nuber of losses by caribou a against all other caribou b The nuber of losses by caribou b against all other caribou c The nuber of losses by caribou c against all other caribou d The nuber of losses by caribou d against all other caribou e The nuber of losses by caribou e against all other caribou f The nuber of losses by caribou f against all other caribou g The nuber of losses by caribou g against all other caribou h The nuber of losses by caribou h against all other caribou i The nuber of losses by caribou i against all other caribou j The nuber of losses by caribou j against all other caribou k The nuber of losses by caribou k against all other caribou l The nuber of losses by caribou l against all other caribou The nuber of losses by caribou against all other caribou n The nuber of losses by caribou n against all other caribou o The nuber of losses by caribou o against all other caribou p The nuber of losses by caribou p against all other caribou q The nuber of losses by caribou q against all other caribou r The nuber of losses by caribou r against all other caribou s The nuber of losses by caribou s against all other caribou t The nuber of losses by caribou t against all other caribou Reference: Barrette, C. & Vandal, D. 1986. Social rank, doinance, antler size, and access to food in snow-bound wild woodland caribou. Behaviour, 97, 118-146.
4 dci dci Get the directional consistency index (DCI) of a socioatrix. Get the directional consistency index (DCI) of a socioatrix. dci() A atrix with individuals ordered identically in rows and coluns. The directional consistency of. References Van Hooff JARAM, Wensing JAB. 1987. Doinance and its behavioural easures in a captive wolf pack. In: Frank HW, editor. Man and Wolf. Dordrecht, Olanda (Netherlands): Junk Publishers pp.219-252. The DCI represents the proportion of occurrences of a behavior that occurs across all dyads in a group fro the individual within each dyad perforing the behavior with a higher frequency (H) to the individual within each dyad perforing the behavior with a lower frequency (L). It is calculated by averaging the following forula across all dyads: DCI = (H - L)/(H + L). The DCI ranges fro 0 (no directional asyetry) to 1 (copletely unidirectional). <- atrix(c(na,2,30,6,19,122,0,na,18, 0,19,85,0,1,NA,3,8,84,0,0,0,NA,267,50,0, 0,0,5,NA,10,1,0,4,4,1,NA), ncol=6) #table 2, Vervaecke et al. 2000 dci() - fleeing in bonobos
dc_test 5 dc_test Randoization Test of DC and Skew-Syetry of a Socioatrix. Randoization Test of DC and Skew-Syetry of a Socioatrix. dc_test(, N = 20, nties = 10000) N nties A atrix with individuals ordered identically in rows and coluns. The nuber of behaviors for each dyad Nuber of siulations A list containing p-value of each test, observed values and descriptive easures of randoized data. References Leiva D et al, 2008, Testing reciprocity in social interactions: A coparison between the directional consistency and skew-syetry statistics, Behav Res Methods. This is a one-sided significance test i.e. that observed values are higher than expected <- atrix(c(na,2,30,6,19,122,0,na,18, 0,19,85,0,1,NA,3,8,84,0,0,0,NA,267,50,0, 0,0,5,NA,10,1,0,4,4,1,NA), ncol=6) #table 2, Vervaecke et al. 2000 - fleeing in bonobos dc_test() = atrix(c(0,9,3,6,12,18,13,0,7,17,45,6,7,2,0,5,8,0,11,26, 12,0,8,6,4,3,0,1,0,2,2,5,0,1,0,0),6,6,TRUE) dc_test(,n=16)
6 devries devries Calculate the linearity of a doinance hierarchy - De Vries ethod Calculate the linearity of a doinance hierarchy - De Vries ethod devries(, Npers = 10000, history = FALSE, plot = FALSE) Npers history plot A atrix with individuals ordered identically in rows and coluns. Nuber of randoizations Whether to store results of randoization Whether to plot results of randoization The odified Landau s h value of, the associated p-value References Han de Vries (1995) An iproved test of linearity in doinance hierarchies containing unknown or tied relationships. Anial Behaviour 50 pp. 1375-1389. This code is an edited and faster version of code originally written by Dai Shizuka. http://biosci.unl.edu/daizaburoshizuka Note that plot will only be shown if history=f devries(bonobos) devries(ouse,plot=true) devries(people,history=true)
ds 7 ds Get David s Scores of Individuals Get David s Scores of Individuals ds(, nor = FALSE, type = "D") nor type A atrix with individuals ordered identically in rows and coluns. whether to noralize scores either ethod="d" for Dij or ethod="p" for Pij. a vector of David scores in sae order as naes of. References Gaell et al, 2003, David s score: a ore appropriate doinance ranking ethod than Clutton- Brock et al. s index, Anial Behaviour. <- atrix(c(na,2,30,6,19,122,0,na,18, 0,19,85,0,1,NA,3,8,84,0,0,0,NA,267,50,0, 0,0,5,NA,10,1,0,4,4,1,NA), ncol=6) #table 2, Vervaecke et al. 2000 - fleeing in bonobos ds() ds(,type="p") ds(,nor=true) el Winner-Loser Edgelist A two variable datafrae with coluns winner and loser el
8 get_di_atrix Forat A data frae with 2397 rows and 2 variables: winner The winner of an individual contest loser The loser of an individual contest get_di_atrix Transfors a frequency interaction socioatrix (valued data) into a dichotoized 1/0 atrix Transfors a frequency interaction socioatrix (valued data) into a dichotoized 1/0 atrix get_di_atrix(, type = "wl") type A atrix with individuals ordered identically in rows and coluns. Deterines the type of dichotoized atrix to be returned. type="wl" is the default which returns a win-loss atrix with a 1 representing a consistent winner and a 0 representing a consistent loser for each dyad of the atrix. A consistent winner is defined as being the individual in each dyad that has absolutely ore wins than defeats. In the default condition if copetitors have the sae nuber of wins each, they both receive a 0. If type="wlties" the default dichotoized win-loss atrix will be returned but it will also return 0.5 into cells for tied relationships. If type="wlties0" the default dichotoized win-loss atrix will be returned but it will also return 0.5 into cells for tied relationships. Additionally, if two copetitors never interacted both cells for that relationship will be returned with a 0. If type="wlbino" every relationship within the win-loss atrix is assessed for whether one copetitor significantly wins ore copetitive interactions than the other copetitor. Significance is calculated using a binoial test with probability of p=0.05. A 1 is given to significant winners within a relationship and a 0 is given to significant losers or if neither individual is a winner. If type="wlbinoties" The sae procedure is done as for type="wlbino", but if no signficiant winner/loser can be deterined then a 0.5 is returned rather than a 0. If type="pa" the inputted atrix will be turned into a dichotoized presence-absence atrix, with a 1 indicating that the copetitor in a the row of the atrix beat the copetitor in the colun at least once. A 0 indicates that that copetitor never beat the other copetitor. If type="do" the inputted atrix will be turned into a doinance score atrix, with a 1 indicating that the copetitor in a the row of the atrix doinates the copetitor in the colun. A -1 indicates that that copetitor in a row is subordinate to the copetitor in the colun. A 0.5 indicates a tie. A 0 indicates an observational or structural zero.
get_wl_df 9 A dichotoized win/loss or presence/absence atrix. References Appleby, M. C. 1983. The probability of linearity in hierarchies. Anial Behaviour, 31, 600-608. get_di_atrix(bonobos) get_di_atrix(ouse) get_wl_df Converts results datafrae to win-loss datafrae Converts results datafrae to win-loss datafrae get_wl_df(df, ties = "reove") df ties A results datafrae How to handle ties, default is ties="reove" Alternative is ties="keep" A win-loss datafrae A results datafrae first 3 variables are id1, id2, result. Results can be "W", "L", or "T" or "1", "0", "0.5". The output will be a win-loss datafrae that will reorganize the first 3 variables into winner, loser and result (=1 for Win or =0.5 for ties). get_wl_df(randotourney(8))
10 isi13 get_wl_atrix Converts win-loss datafrae to win-loss atrix Converts win-loss datafrae to win-loss atrix get_wl_atrix(df, ties = "reove") df ties A results or win-loss datafrae How to handle ties, default is ties="reove" Alternative is ties="keep" A win-loss atrix Input datafraes or atrices with only 2 coluns are considered to be winners in colun 1 and losers in colun 2. If input datafrae has three coluns, the third colun will be the result of the interaction between colun 1 subject and colun 2 subject. The result can be in the "W/L/T" forat or "1/0/0.5" forat. See get_wl_df: for further info. get_wl_atrix(randotourney(8)) get_wl_atrix(randotourney(15,pties=.15)) get_wl_atrix(randotourney(15,pties=.15),ties="keep") get_wl_atrix(el) isi13 Copute best ranked atrixed based on new I&SI ethod Copute best ranked atrixed based on new I&SI ethod isi13(, p = c(1, 0, 0, 0), a_ax = 50, ntries = 30, p2 = 0.5, rando = FALSE)
isi98 11 p a_ax ntries p2 rando A win-loss atrix A vector of probabilities for each of 4 ethods Nuber of tries Nuber of iterations probability for last ethod Whether to randoize initial atrix order A coputed ranked atrix best_atrix best_ranking I and SI, and rs - the Spearan correlation between best order and David s Scores. Code based on algorith described by Schid & de Vries 2013, Finding a doinance order ost consistent with a linear hierarchy: An iproved algorith for the I&SI ethod, Anial Behaviour 86:1097-1105. This first ipleentation of this algorith is not very fast. The code is written in R and is fairly slow. It will be replaced by a function written in C++ soon. The nuber of tries should be very high and/or the function should be run several ties to detect the optial atrix or atrices. It ay take several runs to find the atrix with the lowest SI, especially for very large atrices. For sall atrices it ay be ore efficient to use the older algorith. See isi98: for further info. If the algorith can no longer iprove on reducing the I and SI it will return the order found. For soe sparse atrices any orders ay have an equal I and SI. The best atrix found here will therefore be dependent upon the initial order of individuals in the atrix. By using rando=true it is possible to randoize the initial order of individuals in the atrix. This can be helpful in identifying other potentially better fits. For solutions with identical I and SI, better fits have a higher value of rs. isi13(people,ntries=10) isi98 Copute best ranked atrixed based on original I&SI ethod Copute best ranked atrixed based on original I&SI ethod isi98(, ntries = 100, rando = FALSE)
12 ouse ntries rando A win-loss atrix Nuber of tries to find best order Whether to randoize initial atrix order A atrix with best ranking of I and SI plus the correlation (rs) between found ranking and David s Scores Code based on algorith described by de Vries, H. 1998. Finding a doinance order ost consistent with a linear hierarchy: a new procedure and review. Anial Behaviour, 55, 827-843. The code is written in R and is fairly slow. It will be replaced by a function written in C++ soon. The nuber of iterations should be very high and/or the function should be run several ties to detect the optial atrix or atrices. It ay take several runs to find a atrix with the lowest SI, especially for very large atrices. The function will stop once it finds a atrix with an I or SI that it can no longer iprove upon. The order of this atrix will be dependent upon the input nae order of the original atrix. To find further solutions, try using rando==true to shuffle the nae order of the initial atrix. For solutions with identical I and SI, better fits have a higher value of rs. See isi13: for further info. isi98(ouse,ntries=50) isi98(people, rando=true) ouse Mouse socioatrix A win-loss socioatrix with each row being the nuber of wins against individual ice in each colun. ouse Forat A data frae with 12 rows and 12 variables: A The nuber of losses by ouse A against all other ice B The nuber of losses by ouse B against all other ice C The nuber of losses by ouse C against all other ice
org_atrix 13 D The nuber of losses by ouse D against all other ice E The nuber of losses by ouse E against all other ice F The nuber of losses by ouse F against all other ice G The nuber of losses by ouse G against all other ice H The nuber of losses by ouse H against all other ice I The nuber of losses by ouse I against all other ice J The nuber of losses by ouse J against all other ice K The nuber of losses by ouse K against all other ice L The nuber of losses by ouse L against all other ice org_atrix Organize rows and coluns of a atrix Organize rows and coluns of a atrix org_atrix(, ethod = "alpha") ethod A atrix with individuals ordered identically in rows and coluns. The ethod to be used to reorganize the atrix. ethod="alpha" is the default and will organize rows/coluns based on alphanueric order of rownaes/colnaes. ethod="wins" will return a atrix ordered in descending order of sued rows (i.e. total copetitive interactions won). If rows have tied nuber of total wins, they will be returned in the order of the inputted atrix. ethod="ds" Will return a atrix ordered by David s Score. The sae atrix with reordered rows/coluns org_atrix(bonobos) org_atrix(ouse, ethod="wins") org_atrix(people, ethod="ds")
14 phi people Huan socioatrix Forat A win-loss socioatrix with each row being the nuber of wins against individual huans in each colun. people A data frae with 6 rows and 6 variables: Ada The nuber of losses by huan Ada against all other huans Bryan The nuber of losses by huan Bryan against all other huans Chris The nuber of losses by huan Chris against all other huans Derek The nuber of losses by huan Derek against all other huans Eddie The nuber of losses by huan Eddie against all other huans Frank The nuber of losses by huan Frank against all other huans phi Get the phi skew-syetry of a socioatrix. Get the phi skew-syetry of a socioatrix. phi() A atrix with individuals ordered identically in rows and coluns. The phi skew-syetry index of. References Leiva D et al, 2008, Testing reciprocity in social interactions: A coparison between the directional consistency and skew-syetry statistics, Behav Res Methods.
randotourney 15 Phi is the skew-syetry index (0 eans copletely syetric, 0.5 eans copletely not syetric) <- atrix(c(na,2,30,6,19,122,0,na,18, 0,19,85,0,1,NA,3,8,84,0,0,0,NA,267,50,0, 0,0,5,NA,10,1,0,4,4,1,NA), ncol=6) #table 2, Vervaecke et al. 2000 - fleeing in bonobos phi() randotourney Generates a randoized tournaent with rando outcoes Generates a randoized tournaent with rando outcoes randotourney(n, atchups = 2, pties = 0, ints = 100, type = "char") n atchups pties ints type Nuber of individuals in tournaent Nuber of ties individuals copete in tournaent. Can be a nueric input, or, if atchups="rando" interactions are rando Probability of each individual atchup ending in a tie. Default is 0, i.e. no ties. Needs to be a nuber between 0 and 1. The nuber of interactions in the tournaent if atchups are set to rando. Whether to return results as W/L characters or 1/2 nubers. type="char" is the default, type="nus" returns 1/2 nubers referring to winner as id1 or id2 A copetition results datafrae Specify nuber of individuals to copete in a tournaent and the nuber of ties they copete with each other. Winners and losers are deterined at rando. The resulting datafrae will have variables: id1, id2, result. Result refers to the outcoe fro id1 s perspective, i.e. a "W" refers to id1 beating id2, and a "L" refers to id2 beating id1. Individuals are referred to by a rando assignent of two conjoined letters.
16 sparseness randotourney(20,2) #20 individuals interact twice with each other randotourney(5,6) #5 individuals interact six ties with each other randotourney(8) #8 individuals interact twice with each other rshps Get Relaiontship Descriptives of Socioatrix Get Relaiontship Descriptives of Socioatrix rshps() A atrix with individuals ordered identically in rows and coluns. a list of total, unknown, tied, two-way and one-way relationships rshps(people) sparseness Calculate the sparseness of relationships in a socioatrix Calculate the sparseness of relationships in a socioatrix sparseness() A atrix with individuals ordered identically in rows and coluns. The sparseness of
ttri 17 The sparseness of a atrix is the proportion of null dyads sparseness(ouse) sparseness(caribou) ttri Get Triangle Transitivity of Socioatrix Get Triangle Transitivity of Socioatrix ttri() A frequency binary win-loss atrix Pt and t.tri Algorith described in D. Shizuka and D. B. McDonald, 2012, A social network perspective on transitivity and linearity in doinance hierarchies. Anial Behaviour. DOI:10.1016/j.anbehav.2012.01.011 Code adapted fro original code by Dai Shikua - see http://www.shizukalab.co/toolkits/sna/triangletransitivity ttri(ouse)
18 unknowns ttri_test Signficance testing of Triangle Transitivity of Socioatrix Signficance testing of Triangle Transitivity of Socioatrix ttri_test(, Npers = 1000) Npers A frequency or binary win-loss atrix Nuber of randoizations in signficance test Pt, triangle transitivity and pvalue Algorith described in D. Shizuka and D. B. McDonald, 2012, A social network perspective on transitivity and linearity in doinance hierarchies. Anial Behaviour. DOI:10.1016/j.anbehav.2012.01.011 Code adapted fro original code by Dai Shikua - see http://www.shizukalab.co/toolkits/sna/triangletransitivity ttri_test(ouse) unknowns Calculate the nuber of unknown relationships in a socioatrix Calculate the nuber of unknown relationships in a socioatrix unknowns() A atrix with individuals ordered identically in rows and coluns.
unknowns 19 The nuber of unknown relationships in An unknown relationship is defined as one whereby M(i,j)==M(j,i)==0. The zeros in each cell of dyads that have this property ay be referred to as structural zeros. unknowns(ouse)
Index Topic datasets bonobos, 2 caribou, 3 el, 7 ouse, 12 people, 14 bonobos, 2 caribou, 3 dc_test, 5 dci, 4 devries, 6 ds, 7 el, 7 get_di_atrix, 8 get_wl_df, 9, 10 get_wl_atrix, 10 isi13, 10, 12 isi98, 11, 11 ouse, 12 org_atrix, 13 people, 14 phi, 14 randotourney, 15 rshps, 16 sparseness, 16 ttri, 17 ttri_test, 18 unknowns, 18 20