-
Notifications
You must be signed in to change notification settings - Fork 0
/
Autocorrelation testing
33 lines (25 loc) · 1.39 KB
/
Autocorrelation testing
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
##Autocorrelation testing with Starry Stonewort Data 2021
library(ggplot2)
library(dplyr)
library(tidyr)
library(pspearman)
library(sp)
library(tseries)
# We have two different sets of data that might be autocorrelated so we're gonna test both
SSWnomod <- read.csv("SSW_Data.csv")
SSWphmod <- read.csv("SSW_Data_Final_pH_Modified.csv")
# First let's get the data sheet cut up into the variables we want
## We're going to remove the organizational measure (first 5 columns)
# Data needs to have all values if a value is missing then put an NA
newnomod <- SSWnomod[,6:14]
newmod <- SSWphmod[,6:14]
Autonomod <- acf(newnomod, type= c("correlation"))
Automod <- acf(newmod, type = c("correlation"))
## Tons of plots are going to pop up so go through them piece by piece and save them as images if you want
## we essentially want to be sure that our data has a degree of randomness to it
## Lag at 0 will always be 1 since that will be the data tested against itself
# the dotted lines will be a 95% confidence band on the data so if your lag at the other values is above that
#then we would see that the data has some autocorrelation present
# For the SSW data we can see that the tissues are autocorrelated with one another for the most part but
# between the tissues and the environmental variables there isn't too much autocorrelation
# and between the environmental variables they are decently autocorrelated as well