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 made available/published in September 2020.

Hardback and softback versions are available from www.routledge.com, but is also available for pre-order from Amazon (best to use one’s local Amazon site). A gitbook version is under development and once completed will at least be available on gitpages. I will annouce here when it is ready.

The release version of the MQMF package (commit 88bc002499), is available on CRAN, but to install this development version from GitHub you can use:

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

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

The development version differs from having more details put into the help pages, plus various typos and obscure text fixed. No changes have been made to the code base yet, though various developments are now in mind to increase robustness and generality of a number of the functions.

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 this 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.1

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Malcolm Haddon

Last Published

August 31st, 2020

Functions in MQMF (0.1.1)

altnegLL

altnegLL calculate the Normal negative log-likelihood
bce

bce Baranov catch equation
abdat

abdat A list of fishery data for blacklip abalone
MQMF

MQMF R functions for the New Book
addnorm

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

aicbic returns the AIC and BIC for a given model
chapter2

chapter2 The 15 R-code chunks from A Non-Introduction to R
chapter3

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

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

chapter6 The 53 R-code chunks from On Uncertainty
do_MCMC

do_MCMC conducts an MCMC using Gibbs within Metropolis
discretelogistic

discretelogistic example and figure 3.2 Discrete logistic model
LatA

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

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

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

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

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

calcprior return the sum of a vector of constant values as priors
getlag

getlag is used to look for the response of cpue to previous catches
domed

domed calculates domed selectivity curves
addcontours

addcontours simplifies adding contours to an xy plot of points
getmax

getmax can be used to define the upper bound for a plot
negLL

negLL calculate log-normal log-likelihoods
mnnegLL

mnnegLL generic multinomial negative log-likelihoods
getsingle

getsingle extracts one number from an input line of characters
facttonum

facttonum converts a vector of numeric factors into numbers
fitSPM

fitSPM fits a surplus production model
gettime

gettime calculates time in seconds passed each day
fabens

fabens calculates predicted growth increment for tagging data
bh

bh represents one version of Beverton-Holt recruitment
outfit

outfit tidy print of output from optim, nlminb, or nlm
panel.cor

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

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

logist Logistic selectivity function
magnitude

magnitude returns the magnitude of numbers in base 10
chapter4

chapter4 The 47 R-code chunks from Model Parameter Estimation
blackisland

blackisland tagging data from a blacklip abalone population
getmin

getmin can be used to define the lower bound for a plot
getname

getname returns the name of a variable as character
plot1

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

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

chapter5 The 23 R-code chunks from Static Models
countgtone

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

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

predfreq is used for modal analysis of count data
plotfishM

plotfishM plots the catch and optionally the cpue
getrmse

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

countgtzero used in apply to count numbers > zero in a vector
ssq

ssq a generalized function for summing squared residuals
srug

srug is the Schnute and Richards Unified Growth Curve
likeratio

likeratio conducts a likelihood ratio test
minnow

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

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

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

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

halftable halves the height of a tall narrow data.frame for printing
getseed

getseed generates a random number seed
spmproj

spmproj calculates biomass trajectories for replicate parameters
spmprojDet

spmprojDet conducts forward projections from known conditions
which.closest

which.closest find a number in a vector closest to a given value
negnormL

negnormL an alternative -log-likelihood for normal errors
negLL1

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

schaef is yellowfin tuna fishery data from Schaefer 1957
plotlag

plotlag plots the effect of a lag between two variables
inthist

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

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

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

plotprep sets up a window and the par values for plotting
setpalette

setpalette is a shortcut for altering the palette to R4
freqMean

freqMean calculates the mean and stdev of count data
parasympt

parasympt generates N vectors from a multi-variate normal
getvector

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

makelabel generates a label from text and values
%ni%

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

parset alters the current base graphics par settings
spm

spm calculates the dynamics of a Schaefer or Fox model
twoindex

twoindex has orange roughy catches with hypothetical cpue
spmCE

spmCE - calculates the dynamics for multiple cpue time-series
tigers

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

mature alternative logistic function commonly used for maturity
getMSY

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

penalty1 adds an increasingly large penalty as a value approaches 1.0
quants

quants used in apply to estimate quantiles across a vector
plot.dynpop

plot.dynpop an S3 method for plotting dynpop objects
invl

invl calculates growth increments for the inverse logistic
iscol

incol is a utility to determine if a column is present in a matrix
spmboot

spmboot conducts a bootstrap analysis on a spm model
uphist

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

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

removeEmpty removes empty strings from a vector of strings
penalty0

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

plotprofile simplifies plotting single likelihood profiles
parsyn

parsyn types the standard par command syntax to the console
plotproj

plotproj generate a plot of a matrix of biomass projections
vB

vB calculates the predicted von Bertalanffy length at age
properties

properties - used to examine the properties of a data.frame
pttuna

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

negLLP -ve log-likelihood for normally distributed variables
negNLL

negNLL -ve log-likelihood for normally distributed variables
simpspm

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

plotspmdat plots the fish data containing catches and cpue
plotspmmod

plotspmmod plots an spm model fit given parameters and data
ricker

ricker one version of the Ricker stock recruitment
robustSPM

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

simpspmM calculates predicted CE when multiple indices are present
summspm

summspm extracts critical statistics from output of plotspmmod
tasab

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