-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathi_France_data_exploration
159 lines (151 loc) · 7.38 KB
/
i_France_data_exploration
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
##################################
# Data exploration france data #
##################################
# I'm going to look at FRAc baka and the regular baka together and see can one model
# do both gears with reasonable results
# subest data to look at it easier
summary(as.factor(hauls$Country))
par(mfrow=c(1,1))
france<-subset(hauls, Country=="FRA",)
png(file = "QQ_doorspread_france_29-09-2016.png", bg = "transparent")
qqnorm(france$DoorSpread, main="Normal QQ plot for DoorSpread", ylab="DoorSpread (m)")
qqline(france$DoorSpread, col="red")
dev.off()
#
png(file = "QQ_wingspread_france_29-09-2016.png", bg = "transparent")
qqnorm(france$WingSpread, main="Normal QQ plot for WingSpread", ylab="WingSpread (m)")
qqline(france$WingSpread, col="red")
dev.off()
png(file = "QQ_netopening_france_29-09-2016.png", bg = "transparent")
qqnorm(france$Netopening, main="Normal QQ plot for Netopening", ylab="Netopening (m)")
qqline(france$Netopening, col="red")
dev.off()
# couple of outliers needing a closer look in netopeing
png(file = "netopening_france_29-09-2016.png", bg = "transparent")
plot(france$DepthNew, france$Netopening, pch=19, col='grey', xlab="Depth (m)",
ylab="Net Opening (m)")
dev.off()
# plot shows doorspread is normally distributed as the points fall close to the line
png(file = "doorspread_france_29-09-2016.png", bg = "transparent")
plot(france$DepthNew, france$DoorSpread, pch=19, col='grey', xlab="Depth (m)",
ylab="Door Spread (m)")
dev.off()
png(file = "wingspread_france_29-09-2016.png", bg = "transparent")
plot(france$Depth, france$WingSpread, pch=19, col='grey', xlab="Depth (m)",
ylab="Wing Spread (m)")
dev.off()
# use a box plot to look at the effect of one variable against another,
png(file = "doorspread_france_box_29-09-2016.png", bg = "transparent")
boxplot(france$DoorSpread~france$Ship,
col="lightgray", xlab="Ship", ylab="DoorSpread (m)",
ylim=c(30, 150))
dev.off()
png(file = "wingspread_france_box_29-09-2016.png", bg = "transparent")
boxplot(france$WingSpread~france$Ship,
col="lightgray", xlab="Ship", ylab="WingSpread (m)",
ylim=c(10, 32))
dev.off()
# boxplot reveals that some ships have a lower average doorspread than others,
# wingspreads of some ships, like are more variable than others.
# a clear ship effect exists - decision to include ship as factor in model
png(file = "doorVsweep_france_box_29-09-2016.png", bg = "transparent")
boxplot(france$DoorSpread~france$SweepLngt,
col="lightgray", xlab="Sweep Length (m)", ylab="DoorSpread (m)",
ylim=c(30, 200))
dev.off()
png(file = "wingVsweep_france_box_29-09-2016.png", bg = "transparent")
boxplot(france$WingSpread~france$SweepLngt, col="lightgray",
xlab="Sweep Length (m)", ylab="WingSpread (m)",
ylim=c(10, 32))
dev.off()
# Variation is similar to that seen in ship effect - which probably explains this better
# Sweep Lnght has a stronger effect on DoorSpread than Wing Spread, look at 2 cats,
# Short and Long Sweep to see if this may give sufficent explaniation of the variation
# in the model
# boxplot reveals that sweep impacts on doorspread,
# as the sweep increases so too does the doorspread this is related to depth too!
# this is captured by the long/ short catagories too.
summary(as.factor(france$Gear))
# no Gear Exceptions in france
# but two different gears
png(file = "wingVgear_france_box_29-09-2016.png", bg = "transparent")
boxplot(france$WingSpread~france$Gear, col="lightgrey", pch=19,
xlab="Gear", ylab="WingSpread (m)")
dev.off()
png(file = "doorVgear_france_box_29-09-2016.png", bg = "transparent")
boxplot(france$DoorSpread~france$Gear, col="lightgrey", pch=19,
xlab="Gear", ylab="Door Spread (m)")
dev.off()
cols<-c(rainbow(3))
png(file="doorspreadVDepth_france_col_29-09-2016.png", bg="transparent")
plot(france$Depth, france$DoorSpread, col=cols[as.factor(france$Gear)], pch=20)
legend(680, 90, levels(as.factor(france$Gear)), col=cols,
pch=15, ncol=1, cex=1, bty="n")
dev.off()
png(file="wingspreadVDepth_france_col_29-09-2016.png", bg="transparent")
plot(france$Depth, france$WingSpread, col=cols[as.factor(france$Gear)], pch=20)
legend(680, 30, levels(as.factor(france$Gear)), col=cols,
pch=15, ncol=1, cex=1, bty="n")
dev.off()
# stations look good - france may have fished with the Irish DWS in some years?
plot3d( france$Depth, france$ShootLong, france$ShootLat, main= "Station Locations",
col=cols[as.factor(france$Gear)] , pch=20)
# Deeper depths look like they are in the correct places
png(file="other_franceish_graphs_29-09-2016.png", bg="transparent")
par(mfrow=c(2,3))
plot(france$WingSpread, france$DoorSpread, col=cols[as.factor(france$Gear)], pch=20)
legend(1900, 160, levels(as.factor(france$Gear)), col=cols,
pch=15, ncol=1, cex=.9, bty="n")
#Look at relationship between Warp and Door
plot(france$Warplngt, france$DoorSpread, col=cols[as.factor(france$Gear)], pch=20)
legend(1900, 160, levels(as.factor(france$Gear)), col=cols,
pch=15, ncol=1, cex=.9, bty="n")
# Very Similar to Depth, DoorSpread relationship
plot(france$Warplngt, france$WingSpread, col=cols[as.factor(france$Gear)], pch=20)
legend(1900, 160, levels(as.factor(france$Gear)), col=cols,
pch=15, ncol=1, cex=.9, bty="n")
# Very Similar to Depth, WingSpread relationship
plot(france$Depth,france$Warplngt, col=cols[as.factor(france$Gear)], pch=20)
legend(650, 1800, levels(as.factor(france$Gear)), col=cols,
pch=15, ncol=1, cex=.9, bty="n")
plot(france$Netopening,france$DoorSpread, col=cols[as.factor(france$Gear)], pch=20, xlim=c(0,5))
plot(france$Netopening,france$WingSpread, col=cols[as.factor(france$Gear)], pch=20, xlim=c(0,5))
legend(4, 25, levels(as.factor(france$Gear)), col=cols,
pch=15, ncol=1, cex=.9, bty="n")
dev.off()
# Pearson's product-moment correlation
cor.test(france$Warplngt,france$Depth) # 0.9862778
cor.test(france$DoorSpread,france$Depth) # 0.7596876
cor.test(france$WingSpread,france$Depth) # 0.5695914
# Subset data to check correlations
corhaul<-subset(france,
select=c(SweepLngt, Year, Depth,
Netopening, Warplngt,
DoorSpread, WingSpread))
rcorr(as.matrix(corhaul), type="pearson")
corrgram(corhaul, order=TRUE, lower.panel=panel.shade,
upper.panel=panel.pie, text.panel=panel.txt,
main="IBTS Haul Parameters")
corrgram(corhaul, order=TRUE, lower.panel=panel.ellipse,
upper.panel=panel.pts, text.panel=panel.txt,
diag.panel=panel.minmax,
main="IBTS Haul Parameters",
pch=19)
# depth and warp are showing a positive linear relationship.
# Corrgram shows relationsships and correlations
# run a generalised linear model
# Response Variable: DoorSpread
# Fixed Effects: Depth, Warp Length, Wing Spread, Sweep Length, Net Opening,
# Ship, Ground Gear, Survey, Quarter, Year, StatRec
# does quater account for some differences in weather patterns at each stage of the
# year???
summary(as.factor(france$Quarter))
boxplot(france$DoorSpread~as.factor(france$Quarter),
col="lightgray", xlab="Quarter", ylab="DoorSpread (m)")
boxplot(france$WingSpread~as.factor(france$Quarter),
col="lightgray", xlab="Quarter", ylab="DoorSpread (m)")
# Again the quaters look different - but is this to do with the ships that are
# fishing or the weather?
plot(france$Quarter, france$DoorSpread, col=cols[as.factor(france$Gear)],
pch=19, xlim=c(1,5))
# more likely related to gear than quarter