Install packages necessary to analyze data
##
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✔ ggplot2 3.4.1 ✔ purrr 0.3.4
## ✔ tibble 3.1.6 ✔ dplyr 1.0.8
## ✔ tidyr 1.2.0 ✔ stringr 1.4.0
## ✔ readr 2.1.2 ✔ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ lubridate::as.difftime() masks base::as.difftime()
## ✖ lubridate::date() masks base::date()
## ✖ dplyr::filter() masks stats::filter()
## ✖ lubridate::intersect() masks base::intersect()
## ✖ dplyr::lag() masks stats::lag()
## ✖ lubridate::setdiff() masks base::setdiff()
## ✖ lubridate::union() masks base::union()
## corrplot 0.92 loaded
##
## Attaching package: 'igraph'
## The following objects are masked from 'package:dplyr':
##
## as_data_frame, groups, union
## The following objects are masked from 'package:purrr':
##
## compose, simplify
## The following object is masked from 'package:tidyr':
##
## crossing
## The following object is masked from 'package:tibble':
##
## as_data_frame
## The following objects are masked from 'package:lubridate':
##
## %--%, union
## The following objects are masked from 'package:stats':
##
## decompose, spectrum
## The following object is masked from 'package:base':
##
## union
Read in data (Ignore warnings)
knitr::opts_chunk$set(warning = FALSE)
group1h <- read_excel("~/Downloads/CAT.xlsx", sheet= "code sheet")
Change the group column from character form to numeric
## [1] 65
Rename data fields and create association data frame
Create a sampling period from our association data frame
Sampling_Periods_ray <-get_sampling_periods(
Association_rays[,
c(1,2)],Association_rays[,3],1,
data_format="individuals")
Calculate Half Weight Index
## Generating 65 x 65 matrix
## num [1:65, 1:65] 0 0.75 0.2143 0.0769 0.2143 ...
## - attr(*, "dimnames")=List of 2
## ..$ : chr [1:65] "7659647" "1510634" "3995345" "3995428" ...
## ..$ : chr [1:65] "7659647" "1510634" "3995345" "3995428" ...
Correlation plot for HWI
Simple Ratio Index
## Generating 65 x 65 matrix
## num [1:65, 1:65] 0 0.6 0.12 0.04 0.12 0.56 0.24 0.08 0.92 0.76 ...
## - attr(*, "dimnames")=List of 2
## ..$ : chr [1:65] "7659647" "1510634" "3995345" "3995428" ...
## ..$ : chr [1:65] "7659647" "1510634" "3995345" "3995428" ...
Correlation plot for SRI
Sociogram of 66 stingrays
Since there are 66 nodes, perhaps we can add a different attribute to discern males and females instead of ID numbers
Useful Links: Correlation plot: http://www.sthda.com/english/wiki/visualize-correlation-matrix-using-correlogram.
t test: # https://stats.stackexchange.com/questions/57684/test-for-significance-of-correlation-matrix
One link: two lines below: https://stats.libretexts.org/Bookshelves/Introductory_Statistics/Book%3A_Introductory_Statistics_ (OpenStax)/12%3A_Linear_Regression_and_Correlation/12.05%3A_Testing_the_Significance_of_the_Correlation_Coefficient
igraph doc https://kelseyandersen.github.io/DataVizR/Networks.html
///SocProg/// http://whitelab.biology.dal.ca/SOCPROG/social
What to do next? SOCPROG for Lagged Association Rate (LAR)? (Search Damien Farine for LAR) Let’s read what others have done and see how we can support our data, this may include: permutations, calculating lagged rate of associations, t test, calculating weighted degree of each ray. Or let’s think about how we can come up with an average value of a stingray to represent it within the population (since you can’t average correlation coefficients). Maybe ask your stats professor or consult the internet.