-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAge_Growth_Masonetal.R
92 lines (64 loc) · 2.48 KB
/
Age_Growth_Masonetal.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
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
# Mason et al.
# Age and Growth Model Fits (Traditional Von Bertalanffy and Francis parameterization)
# 2022
# load libraries
library(FSA)
library(nlstools)
library(readr)
# load data (Barred Sand Bass age at length data from Walker et al. 2020)
bsb <- read.csv("bsbage.csv")
str(bsb)
# create column of age in months (for CMR modeling of 2010s tagging data)
bsb.mo <- bsb %>%
mutate(age.mo = age*12)
View(bsb.mo)
hist(bsb$age)
hist(bsb.mo$age.mo)
# Annual Growth -----------------------------------------------------------
# Traditional Von Bert parameterization=====
svTypical <- vbStarts(tl~age,data=bsb)
unlist(svTypical)
vbTypical <- tl~Linf*(1-exp(-K*(age-t0)))
fitTypical <- nls(vbTypical,data=bsb,start=svTypical)
fitPlot(fitTypical,xlab="Age",ylab="Total Length (mm)",main="")
overview(fitTypical)
# note high correlation among traditional Von Vertalanffy growth parameters
bootTypical <- nlsBoot(fitTypical,niter=1000)
confint(bootTypical,plot=TRUE)
plot(bootTypical)
# Francis parameterization of the Von Bertalanffy Growth Function=====
svFrancis <- vbStarts(tl~age,data=bsb,type="Francis",tFrancis=c(2,9))
unlist(svFrancis)
table(bsb$age)
ages <- c(3,16)
vbFrancis <- vbFuns("Francis")
fitFrancis <- nls(tl~vbFrancis(age,L1,L2,L3,t1=ages[1],t3=ages[2]),
data=bsb,start=svFrancis)
overview(fitFrancis)
# solves correlation problem
bootFrancis <- nlsBoot(fitFrancis,niter=1000)
confint(bootFrancis,plot=TRUE)
plot(bootFrancis)
# Monthly Growth -----------------------------------------------------------
# Traditional Von Bert parameterization=====
svTypical <- vbStarts(tl~age.mo,data=bsb.mo)
unlist(svTypical)
vbTypical <- tl~Linf*(1-exp(-K*(age.mo-t0)))
fitTypical <- nls(vbTypical,data=bsb.mo,start=svTypical)
fitPlot(fitTypical,xlab="Age (months)",ylab="Total Length (mm)",main="")
overview(fitTypical)
bootTypical <- nlsBoot(fitTypical,niter=1000)
confint(bootTypical,plot=TRUE)
plot(bootTypical)
# Francis parameterization of the Von Bertalanffy Growth Function=====
svFrancis <- vbStarts(tl~age.mo,data=bsb.mo,type="Francis",tFrancis=c(24,192))
unlist(svFrancis)
table(bsb.mo$age.mo)
ages.mos <- c(24,192)
vbFrancis <- vbFuns("Francis")
fitFrancis <- nls(tl~vbFrancis(age.mo,L1,L2,L3,t1=ages.mos[1],t3=ages.mos[2]),
data=bsb.mo,start=svFrancis)
overview(fitFrancis)
bootFrancis <- nlsBoot(fitFrancis,niter=1000)
confint(bootFrancis,plot=TRUE)
plot(bootFrancis)