Description Usage Arguments Value Warning See Also Examples
View source: R/fcs2JointAndSingleEQR.R
Produces Monte Carlo samples of the joint and single EQRs that can
be calculated individually using fcs2JointEQR and
fcs2SingleEQR respectively.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
fit1 |
an |
... |
further |
newData |
a data frame with surveys as rows and variables as columns. It should contain all variables required by each of the model fits. Covariates which are related to human disturbance (pressure variables) should have their values set to the value expected at the site if it were undisturbed (reference conditions) rather than the observed value for each of these variables. |
joinByVar |
the name of a column in |
subset |
an optional vector specifying a subset of surveys to calculate EQR samples for. |
na.action |
a function which indicates what should happen when the data
contain missing values ( |
n.samples |
the number of Monte Carlo EQR samples to produce for each survey (or joining variable). |
n.sims |
the number of Monte Carlo simulations to make for each EQR sample. These internal samples are used for approximating the probability that defines the joint EQR. |
both |
if |
showProgress |
whether to display the current progress while generating EQR samples. |
seed |
set random seed to allow repeatable results. |
If both = FALSE (the default), a single "fcs2EQR"
object containing Monte Carlo EQR samples for multiple fits is
returned. The "fcs2EQR" object is essentially an array with Monte
Carlo samples as rows and columns corresponding to either surveys, if
joinByVar is missing, or to different levels of the joining variable,
e.g. different water bodies. The third dimension of each object corresponds
to a individual model fit/species, with the first element corresponding to
all species (as produced by fcs2JointEQR).
If both = TRUE and joinByVar is provided, a list containing
both of these "fcs2EQR" objects is returned.
Although this function has been written in C for speed, it
can still take a long time to produce a large number n.samples of
EQR samples when the number n.sims of simulations is also
high.
print.fcs2EQR, summary.fcs2EQR and
fcs2EQRSummaryMatrix for summarising "fcs2EQR"
objects;
plot.fcs2EQR for plotting EQR
variables;
mean.fcs2EQR and quantile.fcs2EQR
for calculating means and quantiles of EQR variables
respectively;
fcs2FitModel for producing the required FCS2 model
fits;
fcs2Classify for using EQR samples to
produce probabilistic WFD classifications.
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 | ## Not run:
### Simple example with two model fits and no covariates
###
# simulate random dataset
Data <- data.frame(SurveyArea=rlnorm(100, 4.6, 0.5)) # random survey area
# a single salmon catch per survey
Data$Salmon <- rzinbinom(100, size=1.1,
zeroprob=0.3, nbmean=0.3 * Data$SurveyArea)
# a single trout catch per survey
Data$Trout <- rzinbinom(100, size=0.87,
zeroprob=0.19, nbmean=0.42 * Data$SurveyArea)
# randomly assign water body A, B or C to each survey
Data$WaterBody <- sample(c("A", "B", "C"), 100, replace=TRUE)
# fit full model for salmon with OpenBUGS
salmonFit <- fcs2FitModel("Salmon", dataFrame=Data, surveyAreaVar="SurveyArea",
runBUGS=TRUE, n.iter=1000, bugsProgram="OpenBUGS")
# fit full model for trout with OpenBUGS
troutFit <- fcs2FitModel("Trout", dataFrame=Data, surveyAreaVar="SurveyArea",
runBUGS=TRUE, n.iter=1000, bugsProgram="OpenBUGS")
# calculate samples of single and joint EQRs for salmon and trout
# per survey and per water body, using same dataset as no pressure variables
eqrs <- fcs2JointAndSingleEQR(salmonFit, troutFit, newData=Data,
n.samples=100, n.sims=100,
joinByVar="WaterBody", both=TRUE)
# calculate mean values of EQRs per survey
mean(eqrs[[1]])
# calculate mean values of EQRs per water body
mean(eqrs[[2]])
# plot salmon, trout and combined EQR variables for water body A
plot(eqrs[[2]], data.frame("A", 1:3), boundaries=NULL)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.