Title: | Implements New and Existing Association Indices for Constructing Animal Social Networks |
---|---|
Description: | Implements several new association indices that can control for various types of errors. Also includes existing association indices and functions for simulating the effects of different rates of error on estimates of association strength between individuals using each method. |
Authors: | William Hoppitt and Damien Farine |
Maintainer: | Damien Farine <[email protected]> |
License: | GPL-2 |
Version: | 1.0.1 |
Built: | 2024-12-06 06:32:03 UTC |
Source: | CRAN |
Implements several new association indices that can control for various types of errors. Also includes existing association indices and functions for simulating the effects of different rates of error on estimates of association strength between individuals using each method.
Package: | assocInd |
Type: | Package |
Version: | 1.0.1 |
Date: | 2017-07-05 |
License: | GPL2 |
Authors: William Hoppitt <[email protected]> Damien Farine <[email protected]>
Maintainer: Damien Farine <[email protected]>
Hoppitt, W. & Farine, D.R. (in press) Association indices for quantifying social relationships: how to deal with missing observations of individuals or groups. Animal Behaviour
Calculates the combined error corrected index
CECI(x, Ya, Yb, Yab, Ynull, w, psi, E, plot = F)
CECI(x, Ya, Yb, Yab, Ynull, w, psi, E, plot = F)
x |
Number of times individuals a and b were observed together |
Ya |
Number of times individual a was observed without b |
Yb |
Number of times individual b was observed without a |
Yab |
Number of times individuals a and b were observed at the same time but not associating |
Ynull |
Number of times neither a or b were observed |
w |
The correction term w (see details) |
psi |
The correction term psi (see details) |
E |
The correction term Epsilon (see details) |
plot |
Flag whether to plot the results or not (default = FALSE) |
The CECI calculates the probability that two individuals are observed together given that one has been seen, correcting for group location error (missing entire groups during a sampling period) and individual identification error (missing individuals that are present in a group). This index can be used if prior information is available on the observation probability of finding groups, where the correction factor w is based on calibration data suggesting that failing to observe a group containing both a and b when they are together is w times more (w > 0) or less (w < 0) likely than failing to observe both the group containing a and the group containing b when a and b are apart. E (Epsilon) is probability of missing one individual given that it is not with the other, which also requires calibration data. psi represents the relative importance of the group location error to the individual identification error (see Hoppitt & Farine in prep for how to calculate this value based on observation errors).
Returns two elements: the estimated association strength and the standard error of the estimate. Also plots the function if required.
William Hoppitt <[email protected]> Damien Farine <[email protected]>
Hoppitt, W. & Farine, D.R. (in prep) Association indices for quantifying social relationships: how to deal with missing observations of individuals or groups.
# Simulated values x <- ya <- yb <- yab <- 10 ynull <- 0 # Set parameters to make equivalent to the SRI psi <- 1.0 w <- 0 E <- 0 # Calculate the group location error corrected index CECI(x,ya,yb,yab,ynull,w,psi,E)
# Simulated values x <- ya <- yb <- yab <- 10 ynull <- 0 # Set parameters to make equivalent to the SRI psi <- 1.0 w <- 0 E <- 0 # Calculate the group location error corrected index CECI(x,ya,yb,yab,ynull,w,psi,E)
Generate an estimated combined error corrected index under conditions where both group and individual location errors are present, but where individual location errors are equal for all individuals
ceSimErrorsEqualCECI(aAB, w, psi, E, n)
ceSimErrorsEqualCECI(aAB, w, psi, E, n)
aAB |
The real association rate between individuals A and B |
w |
The group location error term |
psi |
The relative importance of the group location error to the individual location error |
E |
The probability of missing one individual given that it is not with the other |
n |
The number of sampling periods |
A simple function that simulates data for a given probability of missing groups and real association strength. The w term represents the likelihood of failing to observe a group containing a and b compared to failing to observe both groups containing a and b if the two individuals are apart. E (Epsilon) is probability of missing one individual given that it is not with the other. psi represents the relative importance of the group location error to the individual identification error. The function returns the simulated combined error corrected index and whether the value lies within the 95 percent confidence intervals of the combined error corrected index given the number of samples and under the assumption of no error.
Returns two values: the simulated combined error corrected index and whether or not it falls within the 95 percent confidence intervals (1 = yes, 0 = no)
William Hoppitt <[email protected]> Damien Farine <[email protected]>
Hoppitt, W. & Farine, D.R. (in prep) Association indices for quantifying social relationships: how to deal with missing observations of individuals or groups.
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set errors parameters psi <- 0.5 E <- 0.5 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- ceSimErrorsEqualCECI(aAB,w[i],psi,E,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated CECI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set errors parameters psi <- 0.5 E <- 0.5 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- ceSimErrorsEqualCECI(aAB,w[i],psi,E,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated CECI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
Generate an estimated group location error corrected index under conditions where both group and individual location errors are present, but where individual location errors are equal for all individuals
ceSimErrorsEqualGLECI(aAB, w, psi, E, n)
ceSimErrorsEqualGLECI(aAB, w, psi, E, n)
aAB |
The real association rate between individuals A and B |
w |
The group location error term |
psi |
The relative importance of the group location error to the individual location error |
E |
The probability of missing one individual given that it is not with the other |
n |
The number of sampling periods |
A simple function that simulates data for a given probability of missing groups and real association strength. The w term represents the likelihood of failing to observe a group containing a and b compared to failing to observe both groups containing a and b if the two individuals are apart. E (Epsilon) is probability of missing one individual given that it is not with the other. psi represents the relative importance of the group location error to the individual identification error. The function returns the simulated group location error corrected index and whether the value lies within the 95 percent confidence intervals of the group location error corrected index given the number of samples and under the assumption of no error.
Returns two values: the simulated group location error corrected index and whether or not it falls within the 95 percent confidence intervals (1 = yes, 0 = no)
William Hoppitt <[email protected]> Damien Farine <[email protected]>
Hoppitt, W. & Farine, D.R. (in prep) Association indices for quantifying social relationships: how to deal with missing observations of individuals or groups.
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set errors parameters psi <- 0.5 E <- 0.5 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- ceSimErrorsEqualGLECI(aAB,w[i],psi,E,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated GLECI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set errors parameters psi <- 0.5 E <- 0.5 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- ceSimErrorsEqualGLECI(aAB,w[i],psi,E,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated GLECI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
Generate an estimated simple ratio index under conditions where both group and individual location errors are present, but where individual location errors are equal for all individuals
ceSimErrorsEqualHWI(aAB, w, psi, E, n)
ceSimErrorsEqualHWI(aAB, w, psi, E, n)
aAB |
The real association rate between individuals A and B |
w |
The group location error term |
psi |
The relative importance of the group location error to the individual location error |
E |
The probability of missing one individual given that it is not with the other |
n |
The number of sampling periods |
A simple function that simulates data for a given probability of missing groups and real association strength. The w term represents the likelihood of failing to observe a group containing a and b compared to failing to observe both groups containing a and b if the two individuals are apart. E (Epsilon) is probability of missing one individual given that it is not with the other. psi represents the relative importance of the group location error to the individual identification error. The function returns the simulated half weight index and whether the value lies within the 95 percent confidence intervals of the half weight index given the number of samples and under the assumption of no error.
Returns two values: the simulated half weight index and whether or not it falls within the 95 percent confidence intervals (1 = yes, 0 = no)
William Hoppitt <[email protected]> Damien Farine <[email protected]>
Hoppitt, W. & Farine, D.R. (in prep) Association indices for quantifying social relationships: how to deal with missing observations of individuals or groups.
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set errors parameters psi <- 0.5 E <- 0.5 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- ceSimErrorsEqualHWI(aAB,w[i],psi,E,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated HWI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set errors parameters psi <- 0.5 E <- 0.5 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- ceSimErrorsEqualHWI(aAB,w[i],psi,E,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated HWI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
Generate an estimated simple ratio index under conditions where both group and individual location errors are present, but where individual location errors are equal for all individuals
ceSimErrorsEqualSRI(aAB, w, psi, E, n)
ceSimErrorsEqualSRI(aAB, w, psi, E, n)
aAB |
The real association rate between individuals A and B |
w |
The group location error term |
psi |
The relative importance of the group location error to the individual location error |
E |
The probability of missing one individual given that it is not with the other |
n |
The number of sampling periods |
A simple function that simulates data for a given probability of missing groups and real association strength. The w term represents the likelihood of failing to observe a group containing a and b compared to failing to observe both groups containing a and b if the two individuals are apart. E (Epsilon) is probability of missing one individual given that it is not with the other. psi represents the relative importance of the group location error to the individual identification error. The function returns the simulated simple ratio index and whether the value lies within the 95 percent confidence intervals of the simple ratio index given the number of samples and under the assumption of no error.
Returns two values: the simulated simple ratio index and whether or not it falls within the 95 percent confidence intervals (1 = yes, 0 = no)
William Hoppitt <[email protected]> Damien Farine <[email protected]>
Hoppitt, W. & Farine, D.R. (in prep) Association indices for quantifying social relationships: how to deal with missing observations of individuals or groups.
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set errors parameters psi <- 0.5 E <- 0.5 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- ceSimErrorsEqualSRI(aAB,w[i],psi,E,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated SRI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set errors parameters psi <- 0.5 E <- 0.5 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- ceSimErrorsEqualSRI(aAB,w[i],psi,E,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated SRI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
Generate an estimated very simple ratio index under conditions where both group and individual location errors are present, but where individual location errors are equal for all individuals
ceSimErrorsEqualvSRI(aAB, w, psi, E, n)
ceSimErrorsEqualvSRI(aAB, w, psi, E, n)
aAB |
The real association rate between individuals A and B |
w |
The group location error term |
psi |
The relative importance of the group location error to the individual location error |
E |
The probability of missing one individual given that it is not with the other |
n |
The number of sampling periods |
A simple function that simulates data for a given probability of missing groups and real association strength. The w term represents the likelihood of failing to observe a group containing a and b compared to failing to observe both groups containing a and b if the two individuals are apart. E (Epsilon) is probability of missing one individual given that it is not with the other. psi represents the relative importance of the group location error to the individual identification error. The function returns the simulated very simple ratio index and whether the value lies within the 95 percent confidence intervals of the very simple ratio index given the number of samples and under the assumption of no error.
Returns two values: the simulated very simple ratio index and whether or not it falls within the 95 percent confidence intervals (1 = yes, 0 = no)
William Hoppitt <[email protected]> Damien Farine <[email protected]>
Hoppitt, W. & Farine, D.R. (in prep) Association indices for quantifying social relationships: how to deal with missing observations of individuals or groups.
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set errors parameters psi <- 0.5 E <- 0.5 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- ceSimErrorsEqualvSRI(aAB,w[i],psi,E,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated vSRI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set errors parameters psi <- 0.5 E <- 0.5 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- ceSimErrorsEqualvSRI(aAB,w[i],psi,E,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated vSRI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
Generate an estimated combined error correction index under conditions where both group and individual location errors are present, but where individual location errors are not equal for all individuals
ceSimErrorsUnequalCECI(aAB, w, psi, Emean, Esd, n)
ceSimErrorsUnequalCECI(aAB, w, psi, Emean, Esd, n)
aAB |
The real association rate between individuals A and B |
w |
The group location error term |
psi |
The relative importance of the group location error to the individual location error |
Emean |
The mean probability of missing one individual given that it is not with the other |
Esd |
The standard deviation of the individual location error distribution |
n |
The number of sampling periods |
A simple function that simulates data for a given probability of missing groups and real association strength. The w term represents the likelihood of failing to observe a group containing a and b compared to failing to observe both groups containing a and b if the two individuals are apart. E (Epsilon) is probability of missing one individual given that it is not with the other. psi represents the relative importance of the group location error to the individual identification error. The function allows a distribution of individual location error probabilities to be given using Emean and Esd. The function returns the simulated combined error correction index and whether the value lies within the 95 percent confidence intervals of the combined error correction index given the number of samples and under the assumption of no error.
Returns two values: the simulated combined error correction index and whether or not it falls within the 95 percent confidence intervals (1 = yes, 0 = no)
William Hoppitt <[email protected]> Damien Farine <[email protected]>
Hoppitt, W. & Farine, D.R. (in prep) Association indices for quantifying social relationships: how to deal with missing observations of individuals or groups.
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set errors parameters psi <- 0.5 Emean <- 0.5 Esd <- 0.05 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- ceSimErrorsUnequalCECI(aAB,w[i],psi,Emean,Esd,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated CECI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set errors parameters psi <- 0.5 Emean <- 0.5 Esd <- 0.05 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- ceSimErrorsUnequalCECI(aAB,w[i],psi,Emean,Esd,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated CECI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
Generate an estimated group location error corrected index under conditions where both group and individual location errors are present, but where individual location errors are not equal for all individuals
ceSimErrorsUnequalGLECI(aAB, w, psi, Emean, Esd, n)
ceSimErrorsUnequalGLECI(aAB, w, psi, Emean, Esd, n)
aAB |
The real association rate between individuals A and B |
w |
The group location error term |
psi |
The relative importance of the group location error to the individual location error |
Emean |
The mean probability of missing one individual given that it is not with the other |
Esd |
The standard deviation of the individual location error distribution |
n |
The number of sampling periods |
A simple function that simulates data for a given probability of missing groups and real association strength. The w term represents the likelihood of failing to observe a group containing a and b compared to failing to observe both groups containing a and b if the two individuals are apart. E (Epsilon) is probability of missing one individual given that it is not with the other. psi represents the relative importance of the group location error to the individual identification error. The function allows a distribution of individual location error probabilities to be given using Emean and Esd. The function returns the simulated group location error corrected index and whether the value lies within the 95 percent confidence intervals of the group location error corrected index given the number of samples and under the assumption of no error.
Returns two values: the simulated group location error corrected index and whether or not it falls within the 95 percent confidence intervals (1 = yes, 0 = no)
William Hoppitt <[email protected]> Damien Farine <[email protected]>
Hoppitt, W. & Farine, D.R. (in prep) Association indices for quantifying social relationships: how to deal with missing observations of individuals or groups.
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set errors parameters psi <- 0.5 Emean <- 0.5 Esd <- 0.05 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- ceSimErrorsUnequalGLECI(aAB,w[i],psi,Emean,Esd,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated GLECI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set errors parameters psi <- 0.5 Emean <- 0.5 Esd <- 0.05 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- ceSimErrorsUnequalGLECI(aAB,w[i],psi,Emean,Esd,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated GLECI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
Generate an estimated half weight index under conditions where both group and individual location errors are present, but where individual location errors are not equal for all individuals
ceSimErrorsUnequalHWI(aAB, w, psi, Emean, Esd, n)
ceSimErrorsUnequalHWI(aAB, w, psi, Emean, Esd, n)
aAB |
The real association rate between individuals A and B |
w |
The group location error term |
psi |
The relative importance of the group location error to the individual location error |
Emean |
The mean probability of missing one individual given that it is not with the other |
Esd |
The standard deviation of the individual location error distribution |
n |
The number of sampling periods |
A simple function that simulates data for a given probability of missing groups and real association strength. The w term represents the likelihood of failing to observe a group containing a and b compared to failing to observe both groups containing a and b if the two individuals are apart. E (Epsilon) is probability of missing one individual given that it is not with the other. psi represents the relative importance of the group location error to the individual identification error. The function allows a distribution of individual location error probabilities to be given using Emean and Esd. The function returns the simulated half weight index and whether the value lies within the 95 percent confidence intervals of the half weight index given the number of samples and under the assumption of no error.
Returns two values: the simulated half weight index and whether or not it falls within the 95 percent confidence intervals (1 = yes, 0 = no)
William Hoppitt <[email protected]> Damien Farine <[email protected]>
Hoppitt, W. & Farine, D.R. (in prep) Association indices for quantifying social relationships: how to deal with missing observations of individuals or groups.
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set errors parameters psi <- 0.5 Emean <- 0.5 Esd <- 0.05 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- ceSimErrorsUnequalHWI(aAB,w[i],psi,Emean,Esd,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated HWI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set errors parameters psi <- 0.5 Emean <- 0.5 Esd <- 0.05 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- ceSimErrorsUnequalHWI(aAB,w[i],psi,Emean,Esd,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated HWI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
Generate an estimated simple ratio index under conditions where both group and individual location errors are present, but where individual location errors are not equal for all individuals
ceSimErrorsUnequalSRI(aAB, w, psi, Emean, Esd, n)
ceSimErrorsUnequalSRI(aAB, w, psi, Emean, Esd, n)
aAB |
The real association rate between individuals A and B |
w |
The group location error term |
psi |
The relative importance of the group location error to the individual location error |
Emean |
The mean probability of missing one individual given that it is not with the other |
Esd |
The standard deviation of the individual location error distribution |
n |
The number of sampling periods |
A simple function that simulates data for a given probability of missing groups and real association strength. The w term represents the likelihood of failing to observe a group containing a and b compared to failing to observe both groups containing a and b if the two individuals are apart. E (Epsilon) is probability of missing one individual given that it is not with the other. psi represents the relative importance of the group location error to the individual identification error. The function allows a distribution of individual location error probabilities to be given using Emean and Esd. The function returns the simulated simple ratio index and whether the value lies within the 95 percent confidence intervals of the simple ratio index given the number of samples and under the assumption of no error.
Returns two values: the simulated simple ratio index and whether or not it falls within the 95 percent confidence intervals (1 = yes, 0 = no)
William Hoppitt <[email protected]> Damien Farine <[email protected]>
Hoppitt, W. & Farine, D.R. (in prep) Association indices for quantifying social relationships: how to deal with missing observations of individuals or groups.
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set errors parameters psi <- 0.5 Emean <- 0.5 Esd <- 0.05 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- ceSimErrorsUnequalSRI(aAB,w[i],psi,Emean,Esd,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated SRI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set errors parameters psi <- 0.5 Emean <- 0.5 Esd <- 0.05 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- ceSimErrorsUnequalSRI(aAB,w[i],psi,Emean,Esd,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated SRI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
Generate an estimated very simple ratio index under conditions where both group and individual location errors are present, but where individual location errors are not equal for all individuals
ceSimErrorsUnequalvSRI(aAB, w, psi, Emean, Esd, n)
ceSimErrorsUnequalvSRI(aAB, w, psi, Emean, Esd, n)
aAB |
The real association rate between individuals A and B |
w |
The group location error term |
psi |
The relative importance of the group location error to the individual location error |
Emean |
The mean probability of missing one individual given that it is not with the other |
Esd |
The standard deviation of the individual location error distribution |
n |
The number of sampling periods |
A simple function that simulates data for a given probability of missing groups and real association strength. The w term represents the likelihood of failing to observe a group containing a and b compared to failing to observe both groups containing a and b if the two individuals are apart. E (Epsilon) is probability of missing one individual given that it is not with the other. psi represents the relative importance of the group location error to the individual identification error. The function allows a distribution of individual location error probabilities to be given using Emean and Esd. The function returns the simulated very simple ratio index and whether the value lies within the 95 percent confidence intervals of the very simple ratio index given the number of samples and under the assumption of no error.
Returns two values: the simulated very simple ratio index and whether or not it falls within the 95 percent confidence intervals (1 = yes, 0 = no)
William Hoppitt <[email protected]> Damien Farine <[email protected]>
Hoppitt, W. & Farine, D.R. (in prep) Association indices for quantifying social relationships: how to deal with missing observations of individuals or groups.
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set errors parameters psi <- 0.5 Emean <- 0.5 Esd <- 0.05 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- ceSimErrorsUnequalvSRI(aAB,w[i],psi,Emean,Esd,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated vSRI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set errors parameters psi <- 0.5 Emean <- 0.5 Esd <- 0.05 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- ceSimErrorsUnequalvSRI(aAB,w[i],psi,Emean,Esd,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated vSRI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
Calculates the Group Location Error Corrected Index
GLECI(x, Ya, Yb, Yab, Ynull, w)
GLECI(x, Ya, Yb, Yab, Ynull, w)
x |
Number of times individuals a and b were observed together |
Ya |
Number of times individual a was observed without b |
Yb |
Number of times individual b was observed without a |
Yab |
Number of times individuals a and b were observed at the same time but not associating |
Ynull |
Number of times neither a or b were observed |
w |
The correction term w (see details) |
The GLECI calculates the probability that two individuals are observed together given that one has been seen, correcting for group location error (missing entire groups during a sampling period). This index can be used if prior information is available on the observation probability of finding groups, where the correction factor w is based on calibration data suggesting that failing to observe a group containing both a and b when they are together is w times more (w > 0) or less (w < 0) likely than failing to observe both the group containing a and the group containing b when a and b are apart.
Returns two elements: the estimated association strength and the standard error of the estimate.
William Hoppitt <[email protected]> Damien Farine <[email protected]>
Hoppitt, W. & Farine, D.R. (in prep) Association indices for quantifying social relationships: how to deal with missing observations of individuals or groups.
# Simulated values x <- ya <- yb <- yab <- 10 ynull <- 0 # Set w (here make the GLECI equal to the SRI) w <- 1.0 # Calculate the group location error corrected index GLECI(x,ya,yb,yab,ynull,w)
# Simulated values x <- ya <- yb <- yab <- 10 ynull <- 0 # Set w (here make the GLECI equal to the SRI) w <- 1.0 # Calculate the group location error corrected index GLECI(x,ya,yb,yab,ynull,w)
Generate an estimated group location error corrected index under a given rate of missing observations of groups that are present
gleSimGLECI(aAB, w, pMissA, pMissB, n)
gleSimGLECI(aAB, w, pMissA, pMissB, n)
aAB |
The real association rate between individuals A and B |
w |
The group location error term |
pMissA |
Probability of missing group A |
pMissB |
Probability of missing group A |
n |
The number of sampling periods (number of observations of the dyad) |
A simple function that simulates data for a given probability of missing groups and real association strength. The w term represents the likelihood of failing to observe a group containing a and b compared to failing to observe both groups containing a and b if the two individuals are apart. The function returns the simulated group location error corrected index and whether the value lies within the 95 percent confidence intervals of the group location error corrected index given the number of samples and under the assumption of no error.
Returns two values: the simulated group location error corrected index and whether or not it falls within the 95 percent confidence intervals (1 = yes, 0 = no)
William Hoppitt <[email protected]> Damien Farine <[email protected]>
Hoppitt, W. & Farine, D.R. (in prep) Association indices for quantifying social relationships: how to deal with missing observations of individuals or groups.
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set observation errors pMissA <- 0.7 pMissB <- 0.7 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- gleSimGLECI(aAB,w[i],pMissA,pMissB,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength,na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated GLECI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set observation errors pMissA <- 0.7 pMissB <- 0.7 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- gleSimGLECI(aAB,w[i],pMissA,pMissB,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength,na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated GLECI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
Generate an estimated simple ratio index under a given rate of missing observations of groups that are present
gleSimHWI(aAB, w, pMissA, pMissB, n)
gleSimHWI(aAB, w, pMissA, pMissB, n)
aAB |
The real association rate between individuals A and B |
w |
The group location error term |
pMissA |
Probability of missing group A |
pMissB |
Probability of missing group A |
n |
The number of sampling periods (number of observations of the dyad) |
A simple function that simulates data for a given probability of missing groups and real association strength. The w term represents the likelihood of failing to observe a group containing a and b compared to failing to observe both groups containing a and b if the two individuals are apart. The function returns the simulated half weight index and whether the value lies within the 95 percent confidence intervals of the half weight index given the number of samples and under the assumption of no error.
Returns two values: the simulated half weight index and whether or not it falls within the 95 percent confidence intervals (1 = yes, 0 = no)
William Hoppitt <[email protected]> Damien Farine <[email protected]>
Hoppitt, W. & Farine, D.R. (in prep) Association indices for quantifying social relationships: how to deal with missing observations of individuals or groups.
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set observation errors pMissA <- 0.7 pMissB <- 0.7 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- gleSimHWI(aAB,w[i],pMissA,pMissB,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated HWI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set observation errors pMissA <- 0.7 pMissB <- 0.7 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- gleSimHWI(aAB,w[i],pMissA,pMissB,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated HWI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
Generate an estimated simple ratio index under a given rate of missing observations of groups that are present
gleSimSRI(aAB, w, pMissA, pMissB, n)
gleSimSRI(aAB, w, pMissA, pMissB, n)
aAB |
The real association rate between individuals A and B |
w |
The group location error term |
pMissA |
Probability of missing group A |
pMissB |
Probability of missing group A |
n |
The number of sampling periods (number of observations of the dyad) |
A simple function that simulates data for a given probability of missing groups and real association strength. The w term represents the likelihood of failing to observe a group containing a and b compared to failing to observe both groups containing a and b if the two individuals are apart. The function returns the simulated simple ratio index and whether the value lies within the 95 percent confidence intervals of the simple ratio index given the number of samples and under the assumption of no error.
Returns two values: the simulated simple ratio index and whether or not it falls within the 95 percent confidence intervals (1 = yes, 0 = no)
William Hoppitt <[email protected]> Damien Farine <[email protected]>
Hoppitt, W. & Farine, D.R. (in prep) Association indices for quantifying social relationships: how to deal with missing observations of individuals or groups.
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set observation errors pMissA <- 0.7 pMissB <- 0.7 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- gleSimSRI(aAB,w[i],pMissA,pMissB,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated SRI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set observation errors pMissA <- 0.7 pMissB <- 0.7 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- gleSimSRI(aAB,w[i],pMissA,pMissB,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated SRI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
Generate an estimated very simple ratio index under a given rate of missing observations of groups that are present
gleSimvSRI(aAB, w, pMissA, pMissB, n)
gleSimvSRI(aAB, w, pMissA, pMissB, n)
aAB |
The real association rate between individuals A and B |
w |
The group location error term |
pMissA |
Probability of missing group A |
pMissB |
Probability of missing group A |
n |
The number of sampling periods (number of observations of the dyad) |
A simple function that simulates data for a given probability of missing groups and real association strength. The w term represents the likelihood of failing to observe a group containing a and b compared to failing to observe both groups containing a and b if the two individuals are apart. The function returns the simulated very simple ratio index and whether the value lies within the 95 percent confidence intervals of the very simple ratio index given the number of samples and under the assumption of no error.
Returns two values: the simulated very simple ratio index and whether or not it falls within the 95 percent confidence intervals (1 = yes, 0 = no)
William Hoppitt <[email protected]> Damien Farine <[email protected]>
Hoppitt, W. & Farine, D.R. (in prep) Association indices for quantifying social relationships: how to deal with missing observations of individuals or groups.
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set observation errors pMissA <- 0.7 pMissB <- 0.7 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- gleSimvSRI(aAB,w[i],pMissA,pMissB,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated vSRI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
# Set a real association index aAB <- 0.5 # Set w range w <- seq(-1,1,0.1) # Set observation errors pMissA <- 0.7 pMissB <- 0.7 # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(w)) inCIs <- matrix(NA,nrow=replicates,ncol=length(w)) # Loop through repeating N times for each error value for (i in 1:length(w)) { for (j in 1:replicates) { out <- gleSimvSRI(aAB,w[i],pMissA,pMissB,20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(w,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated vSRI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(w,CIs[1,],w,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(w,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
Calculates the half-weight index
HWI(x, Ya, Yb, Yab)
HWI(x, Ya, Yb, Yab)
x |
Number of times individuals a and b were observed together |
Ya |
Number of times individual a was observed without b |
Yb |
Number of times individual b was observed without a |
Yab |
Number of times individuals a and b were observed at the same time but not associating |
The half-weight index calculates the probability that two individuals are observed together given that one has been seen, but under the assumption that the probability of missing individuals a or b when they are together is equal to M times the probability of missing them when they are apart. This index is the most commonly used in animal social network analysis, but note that Hoppitt & Farine (in prep) and other authors argue that the weighting of the probabilities is arbitrary.
Returns two elements: the estimated association strength and the standard error of the estimate.
William Hoppitt <[email protected]> Damien Farine <[email protected]>
Hoppitt, W. & Farine, D.R. (in prep) Association indices for quantifying social relationships: how to deal with missing observations of individuals or groups.
# Simulated values (all = 10) x <- ya <- yb <- yab <- 10 # Calculate half-weight index HWI(x,ya,yb,yab)
# Simulated values (all = 10) x <- ya <- yb <- yab <- 10 # Calculate half-weight index HWI(x,ya,yb,yab)
Generate an estimated half-weight index under a given rate of missing observations of one individual given that it is present
iieSimHWI(aAB, e, n)
iieSimHWI(aAB, e, n)
aAB |
The real association rate between individuals A and B |
e |
The probability of failing to observe an individual given it is present in a group |
n |
The number of sampling periods (number of observations of the dyad) |
A simple function that simulates data for a given rate of identification error and real association strength. The function returns the simulated half-weight index and whether the value lies within the 95 percent confidence intervals of the half-weight index given the number of samples and under the assumption of no error.
Returns two values: the simulated half weight index and whether or not it falls within the 95 percent confidence intervals (1 = yes, 0 = no)
William Hoppitt <[email protected]> Damien Farine <[email protected]>
Hoppitt, W. & Farine, D.R. (in prep) Association indices for quantifying social relationships: how to deal with missing observations of individuals or groups.
# Set a real association index aAB <- 0.5 # Create a range of errors e <- seq(0,0.8,0.01) # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(e)) inCIs <- matrix(NA,nrow=replicates,ncol=length(e)) # Loop through repeating N times for each error value for (i in 1:length(e)) { for (j in 1:replicates) { out <- iieSimHWI(aAB,e[i],20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(e,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated HWI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(e,CIs[1,],e,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(e,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
# Set a real association index aAB <- 0.5 # Create a range of errors e <- seq(0,0.8,0.01) # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(e)) inCIs <- matrix(NA,nrow=replicates,ncol=length(e)) # Loop through repeating N times for each error value for (i in 1:length(e)) { for (j in 1:replicates) { out <- iieSimHWI(aAB,e[i],20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(e,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated HWI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(e,CIs[1,],e,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(e,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
Generate an estimated simple ratio index under a given rate of missing observations of one individual given that it is present
iieSimSRI(aAB, e, n)
iieSimSRI(aAB, e, n)
aAB |
The real association rate between individuals A and B |
e |
The probability of failing to observe an individual given it is present in a group |
n |
The number of sampling periods (number of observations of the dyad) |
A simple function that simulates data for a given rate of identification error and real association strength. The function returns the simulated simple ratio index and whether the value lies within the 95 percent confidence intervals of the simple ratio index given the number of samples and under the assumption of no error.
Returns two values: the simulated simple ratio index and whether or not it falls within the 95 percent confidence intervals (1 = yes, 0 = no)
William Hoppitt <[email protected]> Damien Farine <[email protected]>
Hoppitt, W. & Farine, D.R. (in prep) Association indices for quantifying social relationships: how to deal with missing observations of individuals or groups.
# Set a real association index aAB <- 0.5 # Create a range of errors e <- seq(0,0.8,0.01) # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(e)) inCIs <- matrix(NA,nrow=replicates,ncol=length(e)) # Loop through repeating N times for each error value for (i in 1:length(e)) { for (j in 1:replicates) { out <- iieSimSRI(aAB,e[i],20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(e,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated SRI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(e,CIs[1,],e,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(e,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
# Set a real association index aAB <- 0.5 # Create a range of errors e <- seq(0,0.8,0.01) # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(e)) inCIs <- matrix(NA,nrow=replicates,ncol=length(e)) # Loop through repeating N times for each error value for (i in 1:length(e)) { for (j in 1:replicates) { out <- iieSimSRI(aAB,e[i],20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(e,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated SRI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(e,CIs[1,],e,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(e,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
Generate an estimated very simple ratio index under a given rate of missing observations of one individual given that it is present
iieSimvSRI(aAB, e, n)
iieSimvSRI(aAB, e, n)
aAB |
The real association rate between individuals A and B |
e |
The probability of failing to observe an individual given it is present in a group |
n |
The number of sampling periods (number of observations of the dyad) |
A simple function that simulates data for a given rate of identification error and real association strength. The function returns the simulated very simple ratio index and whether the value lies within the 95 percent confidence intervals of the very simple ratio index given the number of samples and under the assumption of no error.
Returns two values: the simulated very simple ratio index and whether or not it falls within the 95 percent confidence intervals (1 = yes, 0 = no)
William Hoppitt <[email protected]> Damien Farine <[email protected]>
Hoppitt, W. & Farine, D.R. (in prep) Association indices for quantifying social relationships: how to deal with missing observations of individuals or groups.
# Set a real association index aAB <- 0.5 # Create a range of errors e <- seq(0,0.8,0.01) # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(e)) inCIs <- matrix(NA,nrow=replicates,ncol=length(e)) # Loop through repeating N times for each error value for (i in 1:length(e)) { for (j in 1:replicates) { out <- iieSimvSRI(aAB,e[i],20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(e,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated HWI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(e,CIs[1,],e,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(e,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
# Set a real association index aAB <- 0.5 # Create a range of errors e <- seq(0,0.8,0.01) # Replicate N times replicates <- 100 # small number used to save computation time # Create a blank storage matrices assocStrength <- matrix(NA,nrow=replicates,ncol=length(e)) inCIs <- matrix(NA,nrow=replicates,ncol=length(e)) # Loop through repeating N times for each error value for (i in 1:length(e)) { for (j in 1:replicates) { out <- iieSimvSRI(aAB,e[i],20) assocStrength[j,i] <- out[1] inCIs[j,i] <- out[2] } } # Plot the results par(mfrow=c(1,2)) plot(e,colMeans(assocStrength, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Simulated HWI") CIs <- apply(assocStrength,2,quantile,c(0.025,0.975),na.rm=TRUE) arrows(e,CIs[1,],e,CIs[2,],len=0.1,code=3,angle=90) abline(h=0.5,col="red") plot(e,colMeans(inCIs, na.rm=TRUE), pch=20, ylim=c(0,1), ylab="Percent of times in CIs") abline(h=0.95, col="red")
Calculates the m-weight index, a generalisation of the half-weight index correcting for individual identification error.
MWI(x, Ya, Yb, Yab, m)
MWI(x, Ya, Yb, Yab, m)
x |
Number of times individuals a and b were observed together |
Ya |
Number of times individual a was observed without b |
Yb |
Number of times individual b was observed without a |
Yab |
Number of times individuals a and b were observed at the same time but not associating |
m |
The correction term m (see details) |
The m-weight index calculates the probability that two individuals are observed together given that one has been seen, but under the assumption that the probability of missing individuals a or b when they are together is equal to m times the probability of missing them when they are apart. This index can be used if prior information is available on the observation probability of individuals when they are together versus when they are apart (defined by the ratio m).
Returns two elements: the estimated association strength and the standard error of the estimate.
William Hoppitt <[email protected]> Damien Farine <[email protected]>
Hoppitt, W. & Farine, D.R. (in prep) Association indices for quantifying social relationships: how to deal with missing observations of individuals or groups.
# Simulated values (all = 10) x <- ya <- yb <- yab <- 10 # Set m (here make the MWI equal to the SRI) m <- 1.0 # Calculate m-weight index MWI(x,ya,yb,yab,m)
# Simulated values (all = 10) x <- ya <- yb <- yab <- 10 # Set m (here make the MWI equal to the SRI) m <- 1.0 # Calculate m-weight index MWI(x,ya,yb,yab,m)
Calculates the simple ratio index
SRI(x, Ya, Yb, Yab)
SRI(x, Ya, Yb, Yab)
x |
Number of times individuals a and b were observed together |
Ya |
Number of times individual a was observed without b |
Yb |
Number of times individual b was observed without a |
Yab |
Number of times individuals a and b were observed at the same time but not associating |
The simple ratio index calculates the probability that two individuals are observed together given that one has been seen. This index is widely used in animal social network analysis.
Returns two elements: the estimated association strength and the standard error of the estimate.
William Hoppitt <[email protected]> Damien Farine <[email protected]>
Hoppitt, W. & Farine, D.R. (in prep) Association indices for quantifying social relationships: how to deal with missing observations of individuals or groups.
# Simulated values (all = 10) x <- ya <- yb <- yab <- 10 # Calculate simple ratio index SRI(x,ya,yb,yab)
# Simulated values (all = 10) x <- ya <- yb <- yab <- 10 # Calculate simple ratio index SRI(x,ya,yb,yab)
Calculates the very Simple Ratio Index
vSRI(x, Yab)
vSRI(x, Yab)
x |
Number of times individuals a and b were observed together |
Yab |
Number of times individuals a and b were observed at the same time but not associating |
The very simple ratio index calculates the probability that two individuals are observed together given that both have been seen. This index is useful if there is large individual identification error and is an unbiased estimate (however it requires the majority of groups in the study to be sampled in a given sampling period).
Returns two elements: the estimated association strength and the standard error of the estimate.
William Hoppitt <[email protected]> Damien Farine <[email protected]>
Hoppitt, W. & Farine, D.R. (in prep) Association indices for quantifying social relationships: how to deal with missing observations of individuals or groups.
# Simulated values (all = 10) x <- yab <- 10 # Calculate very simple ratio index vSRI(x,yab)
# Simulated values (all = 10) x <- yab <- 10 # Calculate very simple ratio index vSRI(x,yab)