Learn R Programming

⚠️There's a newer version (0.1.5) of this package.Take me there.

MQMF

An R package for the book Using R for Modelling and Quantitative Methods in Fisheries (2020). ISBN: 9780367469894 due to be published in June 2020.

To install this development version from GitHub you can use:

if (!require(devtools)){install.packages("devtools")} 

devtools::install_github("https://github.com/haddonm/MQMF")

There are currently no vignettes, although the example code-chunks from the book are all available as the help pages of functions chapter2, chapter3, …, and chapter7.

This new book is an evolution and adaptation of my book Modelling and Quantitative Methods in Fisheries (Haddon, 2011). It is designed to introduce materials needed to understand the use of R in fisheries and ecology. The book is not really for total beginners to R, and only a brief introduciton to a few less commonly used aspects of R is provided. In terms of fisheries and population ecology, because it covers a wide array of subjects, and hence is limited in the depth in which each can be treated, it should probably be considered an introductory text. Even so, sufficient detail and worked examples are given that anyone should be able to make a good start with simple model fitting, characterizing uncertainty, and other basic fisheries model fitting. Subjects such as maximum likelihood, simple and dynamic model fitting, and the estimation of uncertainty do receive relatively detailed attention. For example, there is a sufficient development around the use of MCMC that anyone should be able to develop a better understanding of its strengths and weaknesses. More advanced subjects such as age- and size-structured models are not included here as they are not really suited to brief treatments.

The primary objective of thios book is that it be useful to workers in the field. Hopefully, this R package will assist with that objective.

Malcolm Haddon

Hobart, March 10, 2020

Haddon, M. (2011) Modelling and Quantitative Methods in Fisheries. 2nd Ed. CRC/Chapman & Hall. 449p.

Haddon, M. (2020) Using R for Modelling and Quantitative Methods in Fisheries. CRC/Chapman & Hall. In Press

Copy Link

Version

Install

install.packages('MQMF')

Monthly Downloads

274

Version

0.1.0

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Malcolm Haddon

Last Published

March 19th, 2020

Functions in MQMF (0.1.0)

addnorm

addnorm adds a normal distribution to a histogram of a data set.
aicbic

aicbic returns the AIC and BIC for a given model
altnegLL

altnegLL calculate the Normal negative log-likelihood
bce

bce Baranov catch equation
LatA

LatA Simulated length-at-age for 358 female fish
Gz

Gz calculates predicted Gompertz length-at-age growth curve
abdat

abdat A list of fishery data for blacklip abalone
MQMF

MQMF R functions for the New Book
addcontours

addcontours eases adding contours to an xy plot of points
addlnorm

addlnorm estimates a log-normal distribution from output of hist
chapter2

chapter2 The 14 R-code chunks from A Non-Introduction to R
bracket

bracket bounds a value on the x-axis and y-axis
chapter3

chapter3 The 27 R-code chunks from Simple Population Models
calcprior

calcprior return sum of a vector of constant values as priors
chapter5

chapter5 The 23 R-code chunks from Static Models
chapter4

chapter4 The 49 R-code chunks from Model Parameter Estimation
bh

bh represents one version of Beverton-Holt recruitment
blackisland

blackisland tagging data from a blacklip abalone population
dataspm

dataspm A data.frame of fisheries catch and cpue data
countzeros

countzeros used in apply to count the number of zeros in a vector
countNAs

countNAs used in apply to count the number of NAs in a vector
getseed

getseed generates a random number seed
countgtone

countgtone used in apply to count the number > 1 in a vector
getrmse

getrmse calculates the rmse of the input 'invar' series
getmin

getmin generates the lower bound for a plot
getname

getname returns the name of a variable as character
getvector

getvector extracts a vector of numbers from a line of characters
chapter6

chapter6 The 53 R-code chunks from On Uncertainty
countgtzero

countgtzero used in apply to count how many numbers are greater than zero in a vector
countones

countones used in apply to count the number of ones in a vector
likeratio

likeratio conducts a likelihood ratio test
negLL

negLL calculate log-normal log-likelihoods
mnnegLL

mnnegLL generic multinomial negative log-likelihoods
invl

invl calculates growth increments for the inverse logistic
fitSPM

fitSPM fits a surplus production model
iscol

incol is a utility to determine is a column is present in a matrix
parasympt

parasympt generates N vectors from a multi-variate normal
facttonum

facttonum converts a vector of numeric factors into numbers
%ni%

'%ni%' identifies which element in x is NOT in y
linter

linter finds a value in a series using its location in another
makelabel

makelabel generates a label from text and values
chapter7

chapter7 The 67 R-code chunks from Surplus Production Models
fabens

fabens calculates predicted growth increment for tagging data
magnitude

magnitude returns the magnitude of numbers
domed

domed calculates domed selectivity curves
outfit

outfit tidy print of output from optim, nlminb, or nlm
logist

logist Logistic selectivity function
getMSY

getMSY calculates the MSY for the Polacheck et al 1993 equation
getsingle

getsingle extracts one number from an input line of characters
freqMean

freqMean calculates the mean and stdev of count data
gettime

gettime calculates time in seconds passed each day
discretelogistic

discretelogistic example and figure 3.2 Discrete logistic model
minnow

minnow contains weekly growth data for use with seasonal growth curves
do_MCMC

do_MCMC conducts an MCMC using Gibbs within Metropolis
penalty1

penalty1 enables the adding of a large penalty as one approaches 1.0
panel.cor

panel.cor is a version of function given in the pairs help
mm

mm calculates the predicted Michaelis-Menton length-at-age
npf

npf fishery catch data from Northern Prawn Fishery 1970-1992
plotspmdat

plotspmdat plots the fish data containing catches and cpue
negnormL

negnormL an alternative -log-likelihood for normal errors
plotspmmod

plotspmmod plots an spm model fit given parameters and data
mature

mature alternative logistic function commonly used for maturity
parsyn

parsyn types the standard par command syntax to the console
plot.dynpop

plot.dynpop an S3 method for plotting dynpop objects
ricker

ricker one version of the Ricker stock recruitment
getlag

getlag used to look for the response of cpue to previous catches
parset

parset alters the current base graphics par settings
halftable

halftable halves the height of a tall narrow data.frame
negLL1

negLL1 calculate log-normal log-likelihoods with a penalty
getmax

getmax generates the upper bound for a plot
inthist

inthist a replacement for the hist function for use with integers
negLLM

negLLM -ve log-normal likelihoods for multiple index time-series
negLLP

negLLP -ve log-likelihood for normally distributed variables
spm

spm - calculates the dynamics of a Schaefer or Fox model
quants

quants used in apply to estimate quantiles across a vector
removeEmpty

removeEmpty removes empty strings from a vector of strings
plotlag

plotlag plots the effect of a lag between two variables
spmCE

spmCE - calculates the dynamics for nultiple cpue time-series
schaef

schaef is yellowfin tuna fishery data from Schaefer 1957
plot1

plot1 a quick way to plot an xy line or point plot
plotfishM

plotfishM plots the catch and optionally the cpue
negNLL

negNLL -ve log-likelihood for normally distributed variables
setpalette

setpalette is a shortcut for altering the palette to R4
summspm

summspm extracts critical statistics from output of plotspmmod
tasab

tasab is a matrix of abalone maturity-at-length data
plotprofile

plotprofile simplifies plotting single likelihood profiles
penalty0

penalty0 enables the adding of a large penalty as one approaches 0.0
srug

srug is the Schnute and Richards Unified Growth Curve
pttuna

pttuna is yellowfin tuna fishery data from Pella-Tomlinson 1969
spmboot

spmboot conducts a bootstrap analysis on a spm model
plotproj

plotproj generate a plot of a matrix of biomass projections
properties

properties - used to check a data.frame before standardization
robustSPM

robustSPM does a robustness test on quality of fit of an SPM
spmproj

spmproj calculates biomass trajectories for replicate parameters
predfreq

predfreq is used for modal analysis of count data
plotprep

plotprep: sets up a window and the par values for plotting
printV

printV returns a vector cbinded to 1:length(invect)
ssq

ssq a generalized function for summing squared residuals
simpspm

simpspm calculates only the predicted log(CE) for an SPM
uphist

uphist a histogram with an upper limit on the x-axis
twoindex

twoindex has orange roughy catches with hypothetical cpue
spmprojDet

spmprojDet conducts forward projections from known conditions
which.closest

which.closest find the number closest to a given value
tigers

tigers is tiger prawn recruitment data from Penn & Caputi 1986
simpspmM

simpspmM calculates predicted CE when multiple indices are present
spmphaseplot

spmphaseplot - plots the phase plot of harvest rate vs biomass
vB

vB calculates the predicted von Bertalanffy length at age