-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathKW_WMW_pulse_separations.R
67 lines (49 loc) · 1.96 KB
/
KW_WMW_pulse_separations.R
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# This script looks for differences in pulse separations between behaviors.
# 03-13-2020
# Kathryn Busby
# Load libraries.
library(tidyverse)
# Bring in data file.
mydata <- read.csv(file = "[Insert your path to Vent_times.csv here]",
header = TRUE,
sep = ",")
# Eliminate those NAs that occurred where there wasn't an event separation, at the beginning of each behavior.
shortdata <- mydata %>%
select(Behavior, EvSepby3)
shortdata <- na.omit(shortdata)
# I want to compare between groups of event separations.
# This should be looking within bouts. So first index to <1000.
pulses <- shortdata %>%
filter(EvSepby3 < 1000)
# Kruskal-Wallis tests for pulse separations between behaviors.
# These data are all right skewed, so not normally distributed.
kruskal.test(EvSepby3 ~ Behavior, data=pulses)
# Next we need to test for differences between specific pairs of behaviors.
# Create variables to index to them individually.
dv.pulse <- pulses %>%
filter(Behavior == "abdomen dv") %>%
filter(EvSepby3 < 1000)
cleaner.pulse <- shortdata %>%
filter(Behavior == "cleaner") %>%
filter(EvSepby3 < 1000)
feeder.pulse <- shortdata %>%
filter(Behavior == "feeder") %>%
filter(EvSepby3 < 1000)
heater.pulse <- shortdata %>%
filter(Behavior == "heater") %>%
filter(EvSepby3 < 1000)
# Now we need to do the non-parametric pairwise comparisons that correspond to the KW test, which would
# be Wilcoxon-Mann-Whitney tests of all the following pairs:
# cleaner-abdomen dv
wilcox.test(dv.pulse$EvSepby3, cleaner.pulse$EvSepby3)
# feeder-abdomen dv
wilcox.test(dv.pulse$EvSepby3, feeder.pulse$EvSepby3)
# heater-abdomen dv
wilcox.test(dv.pulse$EvSepby3, heater.pulse$EvSepby3)
# feeder-cleaner
wilcox.test(feeder.pulse$EvSepby3, cleaner.pulse$EvSepby3)
# heater-cleaner
wilcox.test(heater.pulse$EvSepby3, cleaner.pulse$EvSepby3)
# heater-feeder
wilcox.test(heater.pulse$EvSepby3, feeder.pulse$EvSepby3)