-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.Rhistory
512 lines (512 loc) · 23.8 KB
/
.Rhistory
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
ages= 0:(final.year-birth.year)
growth= vb.growth.f(age.vector=ages,Linf=Linf,k=k,t0=t0,cv=cv)
old.pars=par()
par(mfcol=c(2,1),mar=c(3,3,1,3),omi=c(.01,1.5,.01,1.5))
plot(growth$Age,growth$Length,xlab="Age", ylab="Length (cm)",type="n",ylim=c(0,max(growth$Length.CI.high)+1.01),cex.axis=.85)
mtext("Age (years)",side=1,line=2)
mtext("Length (cm)",side=2,line=2.5)
legend("bottomright",legend=c(paste("Linf=",Linf),paste("k=",k),paste("t0=",t0),paste("cv=",cv)),bty="n",cex=0.6)
polygon(x=c(growth$Age, rev(growth$Age)), y=c(growth$Length.CI.low,rev(growth$Length.CI.high)), col = "grey", border = NA)
lines(growth$Age,growth$Length,lwd=2)
props$vbcurve= growth
plotcdfa.f(props,lengths.of.interest=lengths.of.interest,birth.year=birth.year,final.year=final.year,
k=k, Linf=Linf, t0=t0, cv=cv)
mtext("Year",side=1,line=2)
mtext("Prop abundance > size",side=2,line=2.5)
par=old.pars
props$years= birth.year:final.year
props$lengths= 1:nrow(props$abundance.props)
props
}
#' Proportion of a cohort recruiting each year
#'
#' Using a Von Bertalanffy growth function and parameters you supply, this determines the proportion
#' of a cohort's numbers and biomass that are at or above different size classes each year
#' @param birth.year four digit year of birth
#' @param final.year four digit final year of the growth projection (birth year + average max age is good)
#' @param Linf VB maximum length (cm)
#' @param k VB k
#' @param t0 VB t-zero
#' @param cv coefficient of variation on length for an age
#' @keywords VonBertalanffy growth recruit age
#' @export
#' @examples
#' cohort.props.f(birth.year=2011, final.year = 2030, Linf = 42, k = 0.086, t0 = -1.57, cv = 0.089)
#' vb.growth.f(age.vector=1:40,Linf=42,k=0.086,t0=-1.57,cv=0.1)
cohort.props.f= function(birth.year, final.year, Linf, k, t0, cv){
years= 1:(final.year-birth.year)
lengths=ceiling(Linf+Linf*cv*3):1 #need to reverse length vector to make diff work properly.
props.gte.len= matrix(nrow=length(lengths),ncol=length(years))
for (i in years){
len= Linf*(1-exp(-k*(i-t0)))
props.gte.len[,i]= 1-pnorm(lengths,len,len*cv)
}
# this part does the same calculation but for biomass. I have disabled it though because it involves
# extra assumptions that I think are against the simplicity of such a method for abundance. If you want
# to enable it, think about it first.
# props.gte.len= as.data.frame(props.gte.len)
# names(props.gte.len)=c(paste("Y",(birth.year+1):final.year,sep=""))
# row.names(props.gte.len)=paste(lengths,"cm",sep="")
# #computes the proportion of individuals in each size class noting that they are from largest to smallest size
# props.eq.len= apply(props.gte.len,2,diff)
# weight= (exp(lw.a)*lengths^lw.b)[-1]
# # multiply the proportion in each length class by the nominal weight of individuals in that length class.
# bmass.len= props.eq.len*weight
#
#
# bmass.sum= apply(bmass.len,2,sum) # compute the total biomass for a year
# props.bmass.len= t(t(bmass.len)/bmass.sum)
# props.bms.gte.len= apply(props.bmass.len,2,cumsum)
#
# # The output is reversed again so it goes from smallest to largest size
#outp= list(abundance.props= props.gte.len[lengths,][-length(lengths),], biomass.props= props.bms.gte.len[lengths[-1],])
outp= list(abundance.props= props.gte.len[lengths,][-length(lengths),])
outp
}
#' Von Bertalanffy growth
#'
#' Using a Von Bertalanffy growth function and parameters you supply, show the trajectory for the supplied age vector
#' @param age.vector ages
#' @param Linf VB maximum length (cm)
#' @param k VB k
#' @param t0 VB t-zero
#' @param cv coefficient of variation on length for an age
#' @keywords VonBertalanffy growth recruit age
#' @export
#' @examples
#' vb.growth.f(age.vector=1:40,Linf=42,k=0.086,t0=-1.57,cv=0.1)
#' cohort.props.f(birth.year=2011, final.year = 2030, Linf = 42, k = 0.086, t0 = -1.57, cv = 0.089)
vb.growth.f= function(age.vector,Linf,k,t0,cv){
Amax= max(age.vector) #maximum age
A=age.vector
L= Linf*(1-exp(-k*(age.vector-t0)))
stdev= cv*L
CI.low= L-1.96*stdev
CI.high= L+1.96*stdev
vb.growth= data.frame(Age=A,Length=L,Length.CI.low= CI.low, Length.CI.high=CI.high)
vb.growth
}
#' Von Bertalanffy growth solved for mean age given a length
#'
#' Using a Von Bertalanffy growth function and parameters you supply, show the mean age given a specified length
#' @param length.vector ages
#' @param Linf VB maximum length (cm)
#' @param k VB k
#' @param t0 VB t-zero
#' @keywords VonBertalanffy growth recruit age
#' @export
VB.growth.for.age.f= function(length.vector,k,Linf,t0){
age.vector= (1/-k) * log(1-length.vector/Linf)+t0
VB.age= data.frame(length=length.vector, age=age.vector)
VB.age
}
#' gam interpolation of sigmoidal curve
#'
#' Just for plotting. Gives the year where probability = 50%
#' @param birth.year four digit year of birth
#' @param final.year four digit final year of the growth projection (birth year + average max age is a good)
#' @param len length class of interest
#' @param proportion the proportion of interest
#' @export
#' @examples
propinterp.f= function(recruiting.matrix, birth.year, final.year, len){
tmp= data.frame(year=(birth.year+1):final.year, props= as.numeric(recruiting.matrix[len,]))
interpgam= gam(year~ s(props),data=tmp,k=ncol(tmp))
pred.year= predict(interpgam,newdata=data.frame(props= 0.5))
pred.year
}
#' The proportion of a cohort of at or above difference sizes cumulative distribution
#'
#' Using a Von Bertalanffy growth function and parameters you supply, this determines the proportion
#' of a cohort's numbers and biomass that are at or above different size classes each year and plots them. A helper
#' function not usually called directly. It is called by the overall vbrecruit function.
#' @param proj.object a projection object produced by vbgrowth.f
#' @param birth.year four digit year of birth
#' @param final.year four digit final year of the growth projection (birth year + average max age is a good)
#' @param lengths.of.interest (often the length at recruitment to the fishery or a valuable size
#' @param Linf VB maximum length (cm)
#' @param k VB k
#' @param t0 VB t-zero
#' @param cv coefficient of variation on length for an age
#' @keywords VonBertalanffy growth recruit age
#' @export
#' @examples
#' vbrecruit.f(birth.year=2011, final.year = 2050, Linf = 42, k = 0.086, t0 = -1.57, cv = 0.089,
#' lengths.of.interest=c(22,25,27,30))
#' cohort.props.f(birth.year=2011, final.year = 2030, Linf = 42, k = 0.086, t0 = -1.57, cv = 0.089)
#' vb.growth.f(age.vector=1:40,Linf=42,k=0.086,t0=-1.57,cv=0.089)
plotcdfa.f= function(proj.object,lengths.of.interest,birth.year,final.year,k,Linf,t0, cv){
abund= proj.object$abundance.props
years= (birth.year+1):final.year
plot(years,abund[lengths.of.interest[1],],lwd=2,type="n",xlab="",ylab="",las=1,cex.axis=.85,ylim=c(0,1))
for (i in lengths.of.interest){
lines(years,abund[i,],lwd=2)
y50= VB.growth.for.age.f(i,k=k,Linf=Linf,t0=t0)[2]+birth.year
#y50= propinterp.f(recruiting.matrix=abund, birth.year=birth.year, final.year=final.year,len=i)
# text(y50,0.65,paste(i,"cm"),cex=0.6)
points(y50,0.5,pch=21,cex=1.7,bg="white")
text(y50,.5,i,cex=0.5)
lines(c(y50,y50),c(-.5,0.5),col="grey",lty=1)
}
legend("topleft",legend=paste("birth year=",birth.year,sep=""),bty="n",cex=0.6,xjust=0)
}
#' Proportion of a cohort recruiting each year, plots, wrapper function
#'
#' Using a Von Bertalanffy growth function and parameters you supply, this determines the proportion
#' of a cohort's numbers and biomass that are at or above different size classes each year
#' @param birth.year four digit year of birth
#' @param final.year four digit final year of the growth projection (birth year + average max age is a good)
#' @param Linf VB maximum length (cm)
#' @param k VB k
#' @param t0 VB t-zero
#' @param cv coefficient of variation on length for an age
#' @param lengths.of.interest (often the length at recruitment to the fishery or a valuable size
#' @keywords VonBertalanffy growth recruit age
#' @export
#' @examples
#' cohort.props.f(birth.year=2011, final.year = 2030, Linf = 42, k = 0.086, t0 = -1.57, cv = 0.089)
#' vb.growth.f(age.vector=1:40,Linf=42,k=0.086,t0=-1.57,cv=0.089)
#' recruit=vbrecruit.f(birth.year=2011, final.year = 2035, Linf = 42, k = 0.086, t0 = -1.57, cv = 0.089,
#' lengths.of.interest=c(25,22,27,30,35))
vbrecruit.f= function(birth.year, final.year, Linf, k, t0, cv, lengths.of.interest){
props= cohort.props.f(birth.year=birth.year, final.year=final.year, Linf=Linf, k=k, t0=t0, cv=cv)
ages= 0:(final.year-birth.year)
growth= vb.growth.f(age.vector=ages,Linf=Linf,k=k,t0=t0,cv=cv)
old.pars=par()
par(mfcol=c(2,1),mar=c(3,3,1,3),omi=c(.01,1.5,.01,1.5))
plot(growth$Age,growth$Length,xlab="Age", ylab="Length (cm)",type="n",ylim=c(0,max(growth$Length.CI.high)+1.01),cex.axis=.85)
mtext("Age (years)",side=1,line=2)
mtext("Length (cm)",side=2,line=2.5)
legend("bottomright",legend=c(paste("Linf=",Linf),paste("k=",k),paste("t0=",t0),paste("cv=",cv)),bty="n",cex=0.6)
polygon(x=c(growth$Age, rev(growth$Age)), y=c(growth$Length.CI.low,rev(growth$Length.CI.high)), col = "grey", border = NA)
lines(growth$Age,growth$Length,lwd=2)
props$vbcurve= growth
plotcdfa.f(props,lengths.of.interest=lengths.of.interest,birth.year=birth.year,final.year=final.year,
k=k, Linf=Linf, t0=t0, cv=cv)
mtext("Year",side=1,line=2)
mtext("Prop abundance > size",side=2,line=2.5)
par=old.pars
props$years= birth.year:final.year
props$lengths= 1:nrow(props$abundance.props)
props
}
knit_with_parameters('~/github/vbrecruit/README.rmd')
unlink('README_cache', recursive = TRUE)
library(vbrecruit)
vbrecruit.f= function(birth.year, final.year, Linf, k, t0, cv, lengths.of.interest){
props= cohort.props.f(birth.year=birth.year, final.year=final.year, Linf=Linf, k=k, t0=t0, cv=cv)
ages= 0:(final.year-birth.year)
growth= vb.growth.f(age.vector=ages,Linf=Linf,k=k,t0=t0,cv=cv)
old.pars=par()
par(mfcol=c(2, 1),mar=c(3, 3, 1, 3),omi=c(.01, 1.5, .01, 1.5))
plot(growth$Age,growth$Length,xlab="Age", ylab="Length (cm)",type="n",ylim=c(0,max(growth$Length.CI.high)+1.01),cex.axis=.85)
mtext("Age (years)",side=1,line=2)
mtext("Length (cm)",side=2,line=2.5)
legend("bottomright",legend=c(paste("Linf=",Linf),paste("k=",k),paste("t0=",t0),paste("cv=",cv)),bty="n",cex=0.6)
polygon(x=c(growth$Age, rev(growth$Age)), y=c(growth$Length.CI.low,rev(growth$Length.CI.high)), col = "grey", border = NA)
lines(growth$Age,growth$Length,lwd=2)
props$vbcurve= growth
plotcdfa.f(props,lengths.of.interest=lengths.of.interest,birth.year=birth.year,final.year=final.year,
k=k, Linf=Linf, t0=t0, cv=cv)
mtext("Year",side=1,line=2)
mtext("Prop abundance > size",side=2,line=2.5)
par=old.pars
props$years= birth.year:final.year
props$lengths= 1:nrow(props$abundance.props)
props
}
vbrecruit.f
library(vbrecruit)
library(vbrecruit)
knitr::opts_chunk$set(echo = TRUE, error=TRUE)
recruit=vbrecruit.f(birth.year=2011, final.year = 2035, Linf = 42, k = 0.086, t0 = -1.57, cv = 0.089, lengths.of.interest=c(22,25,27,30,35))
knitr::opts_chunk$set(echo = TRUE)
recruit= vbrecruit.f(birth.year=2011, final.year = 2035, Linf = 42, k = 0.086, t0 = -1.57,
cv = 0.089, lengths.of.interest=c(22,25,27,30,35))
library("knitr")
getwd()
knit2html("README.rmd")
render("README.rmd")
render_html("README.rmd")
render_html()
?render
render("README.rmd")
library(rmarkdown)
render("README.rmd")
render("README.rmd")
render("README.rmd")
render("README.rmd")
install_github("ropensci/rfishbase")
devtools::install_github("ropensci/rfishbase")
library(rfishbase)
popgrowth("Oreochromis niloticus")
library(rfishbase)
popgrowth("Oreochromis niloticus")
la
ls()
??rfishbase
species(gadus morhua)
species("gadus morhua")
species("greenland halibut")
list_fields("Growth")
list_fields("growth")
crap=species("greenland halibut")
crap
crap=species("greenland halibut",fields=c("Growth"))
crap=species("greenland halibut",fields=c("growth"))
crap=species("greenland halibut",fields="growth")
crap=species("greenland halibut",fields=c("Species", "PriceCateg", "Vulnerability"))
crap
crap=species("greenland halibut")
crap
crap=species("greenland halibut",fields=c("DepthRangeDeep", "Landings", "LongevityWild"))
crap
crap=species("Atlatnic cod",fields=c("DepthRangeDeep", "Landings", "LongevityWild"))
crap
crap=species("Atlantic cod",fields=c("DepthRangeDeep", "Landings", "LongevityWild"))
crap
crap=stocks("greenland halibut",fields=c("DepthRangeDeep", "Landings", "LongevityWild"))
crap
species("Atlantic cod")
stocks("Atlantic cod",fields="BodyShapeI")
stocks("Atlantic cod",fields="BodyShape1")
species(trout$Species)
fish= c("Gadus morhua")
validate_names(fish)
cods <- common_to_sci("cod")
cods
species(cods$Species)
species(fish)
list_fields("Growth")
list_fields("growth")
list_fields("Linf")
list_fields("k")
list_fields("K")
list_fields("popgrowth")
list_fields("popqb")
list_fields("popgrowth")
stocks(fish, fields=c("Species", "Resilience", "StockDefs"))
stocks(fish, fields=c("Species", "Resilience", "StockDefs","popgrowth"))
stocks(fish, fields=c("Species", "Resilience", "StockDefs","growth"))
stocks(fish, fields=c("Species", "Resilience", "StockDefs","Growth"))
stocks(fish, fields=c("StockDefs","Growth"))
list_fields("Bertalanffy")
list_fields("Lm")
stocks(fish, fields=c("StockDefs","popgrowth"))
stocks(fish, fields=c("StockDefs"))
?list_fields
list_fields("Lm")
stocks(fish, fields=c("StockDefs","Lm"))
popgrowth(fish, fields=c("StockDefs","Lm"))
?popgrowth
crap= popgrowth(fish)
crap
crap= popgrowth(fish,fields=c("TLinfinity","K","t0"))
crap= popgrowth(fish,fields=c("TLinfinity","K","to"))
crap
vb.cod= popgrowth(fish,fields=c("TLinfinity","K","to"))
vb.cod
length(vb.cod)
dim(vb.cod)
apply(vb.cod,2,mean,na.rm=T)
knitr::opts_chunk$set(echo = TRUE)
vb.params= popgrowth(fish,fields=c("TLinfinity","K","to"))
vb.mean= apply(vb.params,2,mean,na.rm=T)
Linf= vb.mean$TLinfinity
vb.mean$TLinfinity
vb.mean
names(vb.mean)
vb.mean$TLinfinity
class(vb.mean)
dim(vb.mean)
Linf= vb.mean[1]
k= vb.mean$K[2]
t0= vb.mean$to[3]
Linf= vb.mean[1]
k= vb.mean$K[2]
t0= vb.mean$to[3]Linf= vb.mean[1]
k= vb.mean[2]
t0= vb.mean[3]
Linf= vb.mean[1]
k= vb.mean[2]
t0= vb.mean[3]
Linf
fish= "Gadus morhua"
vb.params= popgrowth(fish,fields=c("TLinfinity","K","to"))
vb.mean= apply(vb.params,2,mean,na.rm=T)
cod= vbrecruit.f(birth.year= 2017, final.year= 2030, Linf= vb.mean[1], k= vb.mean[2], t0= vb.mean[3],
cv = 0.1, lengths.of.interest=c(25,45,60,80))
cod= vbrecruit.f(birth.year= 2017, final.year= 2030, Linf= vb.mean[1], k= vb.mean[2], t0= vb.mean[3],
cv= 0.1, lengths.of.interest=c(25,45,60,80))
render("README.rmd")
library(rmarkdown)
render("README.rmd")
library(vbrecruit)
library(rmarkdown)
render("README.rmd")
cod= vbrecruit.f(birth.year= 2017, final.year= 2030, Linf= vb.mean[1], k= vb.mean[2], t0= vb.mean[3],
cv= 0.1, lengths.of.interest=c(25,45,60,80))
cod= vbrecruit.f(birth.year= 2017, final.year= 2030, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(25,45,60,80))
render("README.rmd")
261*9
(261-30)*9
(261-50)*9
(261-40)+(261-25)*9
((261-40)+(261-25))*9
((261-40)+(261-25))*9+7*300
fish= "greenland halibut"
vb.params= popgrowth(fish,fields=c("TLinfinity","K","to"))
vb.params
fish= "Reinhardtius hippoglossoides"
vb.params= popgrowth(fish,fields=c("TLinfinity","K","to"))
fish= "Reinhardtius hippoglossoides"
vb.params
vb.mean= apply(vb.params,2,mean,na.rm=T)
vbout= vbrecruit.f(birth.year= 2017, final.year= 2030, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(25,45,60,80))
vbout= vbrecruit.f(birth.year= 2017, final.year= 2040, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(25,45,60,80))
vbout= vbrecruit.f(birth.year= 2014, final.year= 2040, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(25,45,60,80))
fish= "Hippoglossus hippoglossus"
vb.params= popgrowth(fish,fields=c("TLinfinity","K","to"))
vb.mean= apply(vb.params,2,mean,na.rm=T)
vbout= vbrecruit.f(birth.year= 2014, final.year= 2040, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(60,85,120,150))
vbout= vbrecruit.f(birth.year= 2014, final.year= 2040, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(60,85,120,150,200))
vbout= vbrecruit.f(birth.year= 2014, final.year= 2050, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(60,85,120,150,200))
vb.params
fish= "Sebastes mentella"
vb.params= popgrowth(fish,fields=c("TLinfinity","K","to"))
vb.mean= apply(vb.params,2,mean,na.rm=T)
vbout= vbrecruit.f(birth.year= 2014, final.year= 2050, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(60,85,120,150,200))
vbout= vbrecruit.f(birth.year= 2014, final.year= 2050, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(15,22,25,30,35))
vbout= vbrecruit.f(birth.year= 2014, final.year= 2040, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(15,22,25,30,35))
vbout= vbrecruit.f(birth.year= 2011, final.year= 2030, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(15,22,25,30,35))
fish= "Gadus morhua"
vb.params= popgrowth(fish,fields=c("TLinfinity","K","to"))
vb.mean= apply(vb.params,2,mean,na.rm=T)cod= vbrecruit.f(birth.year= 2017, final.year= 2030, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(25,45,60,80))
fish= "Reinhardtius hippoglossoides"
fish= "Gadus morhua"
vb.params= popgrowth(fish,fields=c("TLinfinity","K","to"))
vb.mean= apply(vb.params,2,mean,na.rm=T)cod= vbrecruit.f(birth.year= 2017, final.year= 2030, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(25,45,60,80))
vb.mean= apply(vb.params,2,mean,na.rm=T)
vbout= vbrecruit.f(birth.year= 2017, final.year= 2030, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(25,45,60,80))
fish= "Melanogrammus aeglefinus"
vb.params= popgrowth(fish,fields=c("TLinfinity","K","to"))
vb.mean= apply(vb.params,2,mean,na.rm=T)
vbout= vbrecruit.f(birth.year= 2017, final.year= 2030, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(25,45,60,80))
vb.mean
vbout= vbrecruit.f(birth.year= 2017, final.year= 2030, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(35,45,60))
title(fish)
fish= "Gadus morhua"
vb.params= popgrowth(fish,fields=c("TLinfinity","K","to"))
vb.mean= apply(vb.params,2,mean,na.rm=T)
vbout= vbrecruit.f(birth.year= 2017, final.year= 2030, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(25,45,60,80))
title(fish)
fish= "Reinhardtius hippoglossoides"
vb.params= popgrowth(fish,fields=c("TLinfinity","K","to"))
vb.mean= apply(vb.params,2,mean,na.rm=T)
vbout= vbrecruit.f(birth.year= 2014, final.year= 2040, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(25,45,60,80))
title(fish)
fish= "Hippoglossus hippoglossus"
vb.params= popgrowth(fish,fields=c("TLinfinity","K","to"))
vb.mean= apply(vb.params,2,mean,na.rm=T)
vbout= vbrecruit.f(birth.year= 2014, final.year= 2050, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(60,85,120,150,200))
title(fish)
fish= "Sebastes mentella"
vb.params= popgrowth(fish,fields=c("TLinfinity","K","to"))
vb.mean= apply(vb.params,2,mean,na.rm=T)
vbout= vbrecruit.f(birth.year= 2011, final.year= 2030, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(15,22,25,30,35))
title(fish)
fish= "Melanogrammus aeglefinus"
vb.params= popgrowth(fish,fields=c("TLinfinity","K","to"))
vb.mean= apply(vb.params,2,mean,na.rm=T)
vbout= vbrecruit.f(birth.year= 2017, final.year= 2030, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(35,45,60))
title(fish)
1.5^2
knitr::opts_chunk$set(echo = TRUE)
library(vbrecruit)
library("rfishbase")
fish= "Trachurus murphyi"
vb.params= popgrowth(fish,fields=c("TLinfinity","K","to"))
vb.mean= apply(vb.params,2,mean,na.rm=T)
cod= vbrecruit.f(birth.year= 2017, final.year= 2030, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(20,30,50))
cod= vbrecruit.f(birth.year= 2017, final.year= 2030, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(30, 40, 50, 60))
library(vbrecruit)
knitr::opts_chunk$set(echo = TRUE)
recruit= vbrecruit.f(birth.year=2011, final.year = 2035, Linf = 42, k = 0.086, t0 = -1.57,
cv = 0.089, lengths.of.interest=c(22,25,27,30,35))
devtools::install_github("ropensci/rfishbase")
library("rfishbase")
fish= "Gadus morhua"
vb.params= popgrowth(fish,fields=c("TLinfinity","K","to"))
vb.mean= apply(vb.params,2,mean,na.rm=T)
cod= vbrecruit.f(birth.year= 2017, final.year= 2030, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(25,45,60,80))
fish= "Trachurus murphyi"
vb.params= popgrowth(fish,fields=c("TLinfinity","K","to"))
vb.mean= apply(vb.params,2,mean,na.rm=T)
cod= vbrecruit.f(birth.year= 2017, final.year= 2030, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(30, 40, 50, 60))
cod= vbrecruit.f(birth.year= 2017, final.year= 2030, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(30, 40, 50, 60))
title("Chilean mackerel, Trachurus murphyi",outer=T)
cod= vbrecruit.f(birth.year= 2017, final.year= 2030, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(30, 40, 50, 60))
title("Chilean mackerel, Trachurus murphyi",outer=T,line=0.5)
cod= vbrecruit.f(birth.year= 2017, final.year= 2030, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(30, 40, 50, 60))
title("Chilean mackerel, Trachurus murphyi",outer=T,line=0)
cod= vbrecruit.f(birth.year= 2017, final.year= 2030, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(30, 40, 50, 60))
title("Chilean mackerel, Trachurus murphyi",outer=T,line=-1)
cod= vbrecruit.f(birth.year= 2017, final.year= 2030, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(30, 40, 50, 60))
title("Chilean mackerel, Trachurus murphyi",outer=T,line=-0.75)
cod= vbrecruit.f(birth.year= 2017, final.year= 2030, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(25,45,60,80))
title("Atlantic cod, Gadus morhua",outer=T,line=-0.75)
fish= "Gadus morhua"
vb.params= popgrowth(fish,fields=c("TLinfinity","K","to"))
vb.mean= apply(vb.params,2,mean,na.rm=T)
cod= vbrecruit.f(birth.year= 2017, final.year= 2030, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(25,45,60,80))
title("Atlantic cod, Gadus morhua",outer=T,line=-0.75)
recruit= vbrecruit.f(birth.year=2011, final.year = 2035, Linf = 42, k = 0.086, t0 = -1.57,
cv = 0.089, lengths.of.interest=c(22,25,27,30,35))
cod= vbrecruit.f(birth.year= 2017, final.year= 2030, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(25,45,60,80))
title(fish,outer=T,line=-0.75)
cod= vbrecruit.f(birth.year= 2017, final.year= 2030, Linf= round(vb.mean[1],0), k= round(vb.mean[2],2), t0= round(vb.mean[3],2),
cv= 0.1, lengths.of.interest=c(30, 40, 50, 60))
title(fish,outer=T,line=-0.75)
library(vbrecruit)
library(rfishbase)
library(vbrecruit)
library(rfishbase)
recruit= vbrecruit.f(birth.year=2011, final.year = 2035, Linf = 42, k = 0.086, t0 = -1.57,
cv = 0.089, lengths.of.interest=c(22,25,27,30,35))
ls()
vb.params
library(vbrecruit)
library(vbrecruit)