kobe5

Upload: johnusapu5

Post on 02-Apr-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/27/2019 kobe5

    1/17

    Package kobe

    March 20, 2013

    Type Package

    Title Tools for providing advice for the Tuna Regional Fisheries Management Organisations

    Version 1.2.2

    Date 2012-06-22

    Author Laurence Kell

    Maintainer Laurence Kell

    Description The package reads in results from a variety of fish stock

    assessment packages and summarise them in the Kobe Scientific

    advice format used within the tuna Regional Fisheries

    Management Organisations (tRFMOs).. Advice summarises the

    probabilities of biomass being greater than and fishing

    mortality less than the levels that can support maximumsustainable yield (MSY) for a range of management options.

    License GPL-2

    Depends

    R(>= 2.15.1), methods, ggplot2, reshape, plyr, grid, MASS,coda, emdbook, tables, RCurl, ellipse

    Collate ggplotFL-multiplot.R ggplotFL-theme.R kobe-generics.R

    kobePhase.R kobeSmry.R kobe-aspic.R kobe-MFCL.R kobeP.R

    kobe-ss.R kobe-2box.R kobe-funcs.R kobePhaseMar.R kobeTrks.R

    kobe-read-methods.R kobe-SAM.R kobeShade.R

    BuildResaveData xz

    NeedsCompilation no

    Repository CRAN

    Date/Publication 2013-03-20 14:32:44

    1

  • 7/27/2019 kobe5

    2/17

    2 kobe-package

    R topics documented:

    kobe-package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

    data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

    k o b e - m e t h o d s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4kobe2box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

    kobeAspic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

    k o b e I n t e r p - m e t h o d s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

    kobeMFCL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

    kobeP-methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    k o b e P h a s e - m e t h o d s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    kobePhaseMar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    kobeProb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    kobeShade-methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

    kobeSmry-methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

    kobeSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

    kobeTrks-methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

    multiplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14theme_ms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

    Index 16

    kobe-package Tools for Tuna RFMOs in the Kobe

    Description

    Scientific Advice within the tuna Regional Fisheries Management Organisations (tRFMOs) is based

    on a common framework. This requires estimating the probability that fishing mortality is less than

    FMSY and SSB greater than BMSY for a range of management options; e.g. a range of total

    allowable catchess (TAC).

    This package provides methods for summarising stock assessment results (i.e. estimates of stock

    status, reference points and projections) in the Kobe advice format.

    Details

    Package: kobe

    Type: Package

    Version: 1.0

    Date: 2012-06-22

    License: GPL-2

    Depends: methods, ggplot2, reshape, plyr, grid, MASS, coda, emdbook, tablesCollate: kobe-generics.R kobe-funcs.R kobe-methods.R kobe-aspic.R kobe-2box.R kobe-ss.R kobe-MFCL.R mu

    Built: R 2.15.1; ; 2012-10-11 17:37:36 UTC; unix

    Index:

  • 7/27/2019 kobe5

    3/17

    data 3

    kobe-package Provides tools for plotting advice in the tRFMO format

    kobe2box Reads pro2box projection results and returns

    stock and harvest rate relative to BMSY and

    FMSY

    kobe2sm Calculates confidence intervals for differentprobabiity levels for pairs of data points.

    kobeAspic Reads ASPIC bootstrap and projections outputs

    and returns stock and harvest rate relative to

    BMSY and FMSY

    kobeMFCL Reads Multifan-CL assessment results and

    returns stock and harvest rate relative to BMSY

    and FMSY

    kobeP Calculates the probability of being over-fished

    or subject to over-fishing and being in one of

    the kobe phase plots quadrants.

    kobePhase Calculates confidence intervals for different

    Phaseabiity levels for pairs of data points.

    kobePhaseMar Calculates confidence intervals for different

    Phaseabiity levels for pairs of data points.

    kobeProb Calculates confidence intervals for different

    probabiity levels for pairs of data points.

    kobeSS Reads SS assessment results and returns stock

    and harvest rate relative to BMSY and FMSY

    kobeShade Calculates confidence intervals for different

    probabiity levels for pairs of data points.

    kobeTrks Calculates confidence intervals for different

    Trksabiity levels for pairs of data points.

    multiplot Calculates confidence intervals for different

    probabiity levels for pairs of data points.

    sims kobe datasets

    The package can be used to read in stock assessment results as text files from a variety of packages.

    These can then be summarised and plotted.

    Author(s)

    Laurence Kell \ Maintainer: Laurence Kell

    References

    Use http://www.tuna-org.org/Documents/TRFMO3/K3-REC_ENG.pdf

    data Example Datasets

    http://www.tuna-org.org/Documents/TRFMO3/K3-REC_ENG.pdfhttp://www.tuna-org.org/Documents/TRFMO3/K3-REC_ENG.pdf
  • 7/27/2019 kobe5

    4/17

    4 kobe2box

    Description

    sims A data.frame with histrorical and projected stock biomass and harvest rate by bootstrap

    iteration year and assessment run, derived from ASPIC

    assmtA data.frame with histrorical stock biomass and harvest rate by bootstrap iteration yearderived from ASPIC

    prj1 A data.frame with histrorical and projected stock biomass and harvest rate by bootstrap

    iteration year derived from ASPIC

    prj A list of data.frames with example summaries of assessment and projection

    Datasets can be loaded by issuing the data command, e.g. data(sims).

    References

    tRFMO.

    kobe-methods ~~ Methods for Function kobe in Package kobe ~~

    Description

    ~~ Methods for function kobe in package kobe ~~

    Generic function

    kobe(object,method)

    Methods

    signature(object = "character", method = "character")

    signature(object = "data.frame", method = "missing")

    kobe2box Reads pro2box projection results and returns stock and harvest rate

    relative to MSY reference points or proxies.

    Description

    Reads in text files generated by pro2box, a stock assessment projection program returns time series

    or summaries of B:BMSY and F:FMSY. what specifies how data are returned, i.e. sims bootstraps

    for all years; trks percentiles given by prob; year selected year(s) given by pts; smRY probabilities

    of being in the kobe quadrants and; wrms bootstraps selected at random. If of length 1 then a

    data.frame is returned, if >1 then a list of data.frames

  • 7/27/2019 kobe5

    5/17

    kobeAspic 5

    Usage

    kobe2box(object,proxy=c("fmsy","fmax","f.1","f2","f3","f4","f9max","f75max")[3],

    what =c("sims","trks","pts","smry","wrms")[1], prob=c(.75,.5,.25),year=

    Arguments

    object character; directory in which pro2box projection files are found.

    proxy character; specifies the form of data returned.

    what character; specifies the form of data returned.

    prob numeric; probabilities with values in [0,1] for percentiles returned ifwhat["trks"]

    selected.

    year numeric; year(s) for points ifwhat["pts"] selected.

    nwrms numeric; number of trajectories sampled at random to return if what["wrms"]

    selected.

    See Also

    kobeAspic,kobeMFCL,kobeSS

    Examples

    ## Not run:

    kobe2box("bft")

    ## End(Not run)

    kobeAspic Reads ASPIC bootstraps and projections and returns stock and harvest

    rate relative to MSY reference points

    Description

    Reads ASPIC output files with bootstrapped assesssment and projections and returns time series or

    summaries of B:BMSY and F:FMSY. what specifies how data are returned , i.e. sims bootstraps for

    all years; trks percentiles given by prob; year selected year(s) given by pts; smRY probabilities of

    being in the kobe quadrants and; wrms bootstraps selected at random. If of length 1 then a data.frame

    is returned, if >1 then a list of data.frames.

    Usage

    kobeAspic(object,prb,dir="",

    what=c("sims","trks","pts","smry","wrms")[1], prob=c(.75,.5,.25),year=NULL,nw

  • 7/27/2019 kobe5

    6/17

    6 kobeInterp-methods

    Arguments

    object character: ".bio" file with estimates of stock biomass and harvest rate trajectories

    for each ASPIC bootstrap trial.

    prb character; ".prb" file(s) with projection results, i.e. extension of data in bio forTACs, 1 file per TAC.

    dir character; optional argument identifying directory where files are.

    what character; specifies the form of data returned.

    prob numeric; probabilities with values in [0,1] for percentiles returned ifwhat["trks"]

    selected.

    year numeric; year(s) for points ifwhat["pts"] selected.

    nwrms numeric; number of trajectories sampled at random to return if what["wrms"]

    selected.

    See Also

    kobe2box,kobeMFCL,kobeSS

    Examples

    ## Not run:

    #aBio="http://gbyp-sam.googlecode.com/svn/trunk/data/ASPIC/whm/212/noBrazil/aspic.bio"

    res=kobeAspic(aBio,what=c("pts","trks"))

    kobePhase(res$pts)+

    geom_point(aes(stock,harvest))+

    geom_path( aes(stock,harvest),data=subset(res$trks,Percentile=="5%"))+

    scale_y_continuous(limits=c(,3))

    ## End(Not run)

    kobeInterp-methods Methods to generate the Kobe II Strategy Matrix.

    Description

    Plot of the Kobe II Strategy Matrix, probabilities of being in the green zone of the Kobe phase plot

    by year and management options.

    Methods

    signature(object = "data.frame")

  • 7/27/2019 kobe5

    7/17

    kobeMFCL 7

    kobeMFCL Reads Multifan-CL assessment results and returns stock and harvest

    rate relative to MSY reference points

    Description

    Reads in text file generated by MFCL and returns time series or summaries of B:BMSY and

    F:FMSY. what specifies how data are returned, i.e. sims bootstraps for all years; trks percentiles

    given by prob; year selected year(s) given by pts; smRY probabilities of being in the kobe quad-

    rants and; wrms bootstraps selected at random. If of length 1 then a data.frame is returned, if >1

    then a list of data.frames.

    Usage

    kobeMFCL(object,dir="",

    what=c("sims","trks","pts","smry","wrms")[1], prob=c(.75,.5,.25),year=NULL,nw

    Arguments

    object character: rep file with results.

    dir character; optional argument identifying directory where file is.

    what character; specifies the form of data returned.

    prob numeric; probabilities with values in [0,1] for percentiles returned ifwhat["trks"]

    selected.

    year numeric; year(s) for points ifwhat["pts"] selected.

    nwrms numeric; number of trajectories sampled at random to return if what["wrms"]

    selected.

    See Also

    kobeAspic,kobe2box,kobeMFCL,kobeSS

    Examples

    ## Not run:

    kobeMFCL("bft")

    ## End(Not run)

  • 7/27/2019 kobe5

    8/17

    8 kobePhase-methods

    kobeP-methods Calculates whether each point corresponds to being over-fished or

    subject to over-fishing and being in the red, green or yellow regions

    of the kobe phase plots quadrants.

    Description

    kobeP

    Usage

    kobeP(stock, harvest,...)

    Arguments

    stock numeric vector representing stock or a data.frame with columns for stock and

    harvest

    harvest numeric vector resprenting harvest

    ... other

    See Also

    kobePhase,kobeInterp,kobeP

    Examples

    ## Not run:

    data(sims)

    ## where is point

    res=head(kobeP(sims$stock,sims$harvest))

    ## End(Not run)

    kobePhase-methods Kobe phase plot

    Description

    A plot of assessment results of F verses biomass which summarises stock status by plotting points

    by coloured quadrant, I.e. green quadrant (not overfished, no overfishing), the yellow quadrant

    (overfished or overfishing), and the red quadrant (overfished and overfishing).

  • 7/27/2019 kobe5

    9/17

    kobePhaseMar 9

    Methods

    signature(object = "data.frame")

    signature(object = "FLlst")

    signature(object = "missing")

    kobePhaseMar Plots Kobe phase plot with marginal densities.

    Description

    kobePhaseMar Uses kde2d to calculate a bivariate density, then normalizes the results and calculates

    the contour corresponding to a contained volume of Phase of the total volume under the surface (i.e.

    a two-dimensional Bayesian credible region).

    Usage

    kobePhaseMar(pts,trks=NULL,mns=FALSE,size=1,

    xlab=expression(B:B[MSY]),

    ylab=expression(F:F[MSY]),

    maxX=2,maxY=maxX,

    col =colorRampPalette(c("orange","blue"),space="Lab"),

    shade=.5,col2=grey(shade),col3=grey(shade*1.1))

    Arguments

    pts numeric vector

    trks numeric vector

    mns logical:

    size numeric:

    xlab numeric:

    ylab numeric:

    maxX numeric:

    maxY numeric:

    col function:

    shade character:

    col2 character:

    col3 character:

    See Also

    kobePhase,kobeInterp,kobeP

  • 7/27/2019 kobe5

    10/17

    10 kobeProb

    Examples

    ####

    #data(sims)

    #pts=subset(sims,year=21)

    #kobePhaseMar(x=pts$stock, y=pst$harvest)

    kobeProb Calculates 2 dimenisonal confidence intervals for data pairs.

    Description

    kobeProb Uses kde2d to calculate a bivariate density, then normalises the results and calculatesthe contour corresponding to a contained volume of the total volume under the surface (i.e. a two-

    dimensional Bayesian credible region).

    Usage

    kobeProb(x, y, prob=c(.5, .75, .95), na.rm=FALSE)

    Arguments

    x numeric vector

    y numeric vector

    prob numeric vector of probabilities with values in [0,1].

    na.rm logical; if true, any NA and NaNs are removed from x before the quantiles are

    computed.

    See Also

    kobePhase,kobeInterp,kobeP

    Examples

    ## Not run:

    data(prj)geom_path(aes(x,y,group=level),colour="blue",

    data=kobeProb(prj$pts$stock,prj$pts$harvest,prob=c(.7,.5,.25)))

    ## End(Not run)

  • 7/27/2019 kobe5

    11/17

    kobeShade-methods 11

    kobeShade-methods Shades matrix depending on value of elements

    Description

    Kobe II strategy matrices to be prepared by the SCRS should highlight in a similar format as shown

    in Annex Table 2 a progression of probabilities over 50 % and in the range of 50-59 %, 60-69 %,

    70-79 %, 80-89 % and ??? 90 %.

    Methods

    signature(object = "data.frame")

    signature(object = "matrix")

    signature(object = "numeric")

    kobeSmry-methods Calculates the probability of being over-fished or subject to over-

    fishing and being in the red, green or yellow regions of the kobe phase

    plots quadrants.

    Description

    kobeSmry

    Usage

    kobeSmry(stock,harvest,...)

    Arguments

    stock numeric vector representing stock or a data.frame with columns for stock and

    harvest

    harvest numeric vector respresenting harvest

    ... other

    Methods

    signature(stock="numeric,"harvest="numeric") takes as input numeric vectors of stock and

    harvest

    signature(stock="data.frame",harvest="missing") takes as input a data.frame with columns

    names as stock and harvest

    See Also

    kobePhase,kobeInterp,kobeP

  • 7/27/2019 kobe5

    12/17

    12 kobeSS

    Examples

    ## Not run:

    data(sims)

    ## calculate probabilities

    res=ddply(subset(sims, year > 21 & year BMSY

    1-cast(res,TAC~year,value="overFished")

    ## K2SM for F1 then a list of data.frames.

    Usage

    kobeSS(object,nrows=-1,thin=1,

    what=c("sims","trks","pts","smry","wrms")[1], prob=c(.75,.5,.25),year=NULL,nwrm

    Arguments

    object character: derived posteriors file with MCMC runs.

    nrows numeric; if -ve reads all rowss, otherwise takes the 1st nrows from the file.

    thin numeric; thinning rate for chain.

    what character; specifies the form of data returned.

    prob numeric; probabilities with values in [0,1] for percentiles returned ifwhat["trks"]selected.

    year numeric; year(s) for points if what["pts"] selected and years for historical

    estimates.

    nwrms numeric; number of trajectories sampled at random to return if what["wrms"]

    selected.

  • 7/27/2019 kobe5

    13/17

    kobeTrks-methods 13

    See Also

    kobeAspic,kobe2box,kobeSS

    Examples

    ## Not run:

    kobeSS(...)

    ## End(Not run)

    kobeTrks-methods Calculates confidence intervals for different probabiity levels for pairs

    of data points.

    Description

    kobeTrks Uses kde2d to calculate a bivariate density, normalizes the results and then calculates the

    contour(S) corresponding to a contained volume of points of the total volume under the surface (i.e.

    a two-dimensional Bayesian credible region).

    Usage

    kobeTrks(stock,harvest,...)

    Arguments

    stock numeric vector representing stock or a data.frame with columns for stock andharvest

    harvest character

    ... character

    Methods

    signature(stock="data.frame")

    signature(stock="numeric",harvest="numeric")

    Examples

    #data(sims)

    #pts=subset(sims,year==21)

    #kobeTrks(x=pts$stock, y=pts$harvest)

  • 7/27/2019 kobe5

    14/17

    14 multiplot

    multiplot Calculates confidence intervals for different probabiity levels for pairs

    of data points.

    Description

    A multiple plot function, allowing ggplot2 objects to be plotted together. If the layout is something

    like matrix(c(1,2,3,3), nrow=2, by.row=TRUE), then plot 1 will go in the upper left, 2 will go in the

    upper right, and 3 will go all the way across the bottom.

    Borrowed with thanks from http://wiki.stdout.org/rcookbook/Graphs/Multiple

    Usage

    multiplot(..., plotlist=NULL, file, cols=1, layout=NULL)

    Arguments

    ... ggplot2 objects

    plotlist list ofggplot2 objects

    file character

    cols numeric; number of columns in layout

    layout numeric; A matrix specifying the layout. If present, cols is ignored

    See Also

    kobePhase,kobeInterp,kobeP

    Examples

    ## Not run:

    a=ggplot(data.frame(x=1:1,y=1:1))+geom_point(aes(x,y))

    multiplot(a,a)

    ## End(Not run)

  • 7/27/2019 kobe5

    15/17

    theme_ms 15

    theme_ms ggplot2 theme

    Description

    A ggplot2 theme for presentation of plots

    Usage

    theme_ms(base_size=12, base_family="", ...)

    Arguments

    base_size numeric: default font size.

    base_family character; default font.

    ... any other arguments.

    Details

    The ggplot2 "grammar of graphics" package includes "Themes" for ggplot2 charts, making it pos-

    sible to define and re-use your own preferences for title fonts and sizes, tick marks, grid color,

    etc.

    Source

    see https://github.com/hadley/ggplot2/wiki/Themes

    Examplesdata(prj)

    ggplot(subset(prj$trks, Percentile=="5%")) +

    geom_line(aes(year,stock,group=TAC,col=TAC)) +

    theme_ms()

  • 7/27/2019 kobe5

    16/17

    Index

    Topic \textasciitilde\textasciitildeother possible keyword(s)

    \textasciitilde\textasciitildekobeInterp-methods, 6

    kobePhase-methods, 8

    kobeShade-methods, 11

    Topic datasetsdata, 3

    Topic ggplot2theme_ms, 15

    Topic kobePhasekobe-methods, 4

    Topic methodskobe-methods, 4

    kobeInterp-methods, 6

    kobePhase-methods, 8

    kobeShade-methods, 11

    Topic packagekobe-package, 2

    Topic plottheme_ms, 15

    Topic themetheme_ms, 15

    assmt (data), 3

    data, 3

    kobe (kobe-methods), 4

    kobe,character,character-method

    (kobe-methods), 4

    kobe,data.frame,missing-method

    (kobe-methods), 4

    kobe-method (kobe-methods), 4

    kobe-methods, 4

    kobe-package, 2

    kobe2box, 4, 6, 7, 13

    kobeAspic, 5, 5, 7, 13

    kobeInterp, 811, 14

    kobeInterp (kobeInterp-methods), 6

    kobeInterp,data.frame-method

    (kobeInterp-methods), 6

    kobeInterp-methods, 6

    kobeMFCL, 57, 7

    kobeP, 811, 14

    kobeP (kobeP-methods), 8

    kobeP,data.frame,missing-method

    (kobeP-methods), 8

    kobeP,numeric,numeric-method

    (kobeP-methods), 8

    kobeP-methods, 8

    kobePhase, 811, 14

    kobePhase (kobePhase-methods), 8

    kobePhase,data.frame-method

    (kobePhase-methods), 8

    kobePhase,list-method

    (kobePhase-methods), 8

    kobePhase,missing-method

    (kobePhase-methods), 8

    kobePhase-methods, 8

    kobePhaseMar, 9kobeProb, 10

    kobeShade (kobeShade-methods), 11

    kobeShade,cast_df-method

    (kobeShade-methods), 11

    kobeShade,data.frame-method

    (kobeShade-methods), 11

    kobeShade,matrix-method

    (kobeShade-methods), 11

    kobeShade,numeric-method

    (kobeShade-methods), 11

    kobeShade-methods, 11

    kobeSmry (kobeSmry-methods), 11

    kobeSmry,data.frame,missing-method

    (kobeSmry-methods), 11

    kobeSmry,numeric,numeric-method

    (kobeSmry-methods), 11

    kobeSmry-methods, 11

    kobeSS, 57, 12, 13

    16

  • 7/27/2019 kobe5

    17/17

    INDEX 17

    kobeTrks (kobeTrks-methods), 13

    kobeTrks,data.frame,missing-method

    (kobeTrks-methods), 13

    kobeTrks,numeric,numeric-method

    (kobeTrks-methods), 13kobeTrks-methods, 13

    multiplot, 14

    prj (data), 3

    prj1 (data), 3

    sims (data), 3

    theme_ms, 15