Description Usage Arguments Details Value Author(s) References See Also Examples
The function overlapPriorPost
implements the diagnostic of
Garrett and Zeger (2000) to assess the overlap between the prior
and the posterior.
The function plotOverlap
displays the table summarizing the
overlap between the prior and the posterior distributions of the
parameters (result of the function overlapPriorPost
.
1 2 3 | overlapPriorPost(x, param, prior = "dnorm(z,0,sqrt(10))", from = -10, to = 10, n = 1000)
plotOverlap(x, df, cex = 1.5)
|
x |
An object of class |
param |
A character string containing the name of a parameter in |
prior |
a character string indicating the form of the prior for the
parameter. Note that the parameter should be named |
from,to,n |
the values of |
df |
A data.frame (see details). |
cex |
the size of the text in the table |
For the function plotOverlap
, tqhe object df
must
contain the following variables: (i) Parameter
: the name of the
parameter in the model i
, (ii) tau
: the value of the
overlap parameter tau between the prior and the posterior,(iii)
namo
: a character string containing a plotmath expression to be
used in the first column of the resulting table, (iv) prior
: a
character string indicating the form of the prior for the parameter;
note that the parameter should be named z
in this expression,
(v) three columns named from,to,n
passed to the function
density
, and used to calculate the values of the parameter over
which the prior and posterior should be compared.
The function overlapPriorPost
returns a numeric value
corresponding to the diagnostic.
Clement Calenge clement.calenge@ofb.gouv.fr
Calenge C., Menoni E., Milhau B., Foulche K, Chiffard J., Marchandeau S. (in prep.). The participatory monitoring of the capercaillie in the French Pyrenees.
Garrett, E. and Zeger, S. 2000. Latent class model diagnosis. Biometrics, 56, 1055-1067.
overlapPriorPost
to calculate the coefficient
tau
.
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 | ## Not run:
## Use the MCMC samples from the model coefModelCountDetectBinREY
rs <- do.call(rbind, coefModelCountDetectBinREY)
## Detects the name of the parameters for which tau should be calculated
library(stringr)
nam <- c("interceptpd","pente1pd","mukappa","sigmaREY",
"sigmaepsilon","sigmaeta","sigmakappa",
"sigmanu")
nam <- unlist(lapply(nam, function(z) colnames(rs)[str_detect(colnames(rs),z)]))
## Remove the parameters not part of the model (only three regions
## for KILs, and only one region for ULs)
nam <- nam[!nam
"mukappa[3,3]", "mukappa[4,3]","mukappa[5,3]")]
## For each parameter, calculates the value of tau:
lb <- sapply(nam, function(na) {
if (str_detect(na, "mukappa")|na
tau <- overlapPriorPost(coefModelCountDetectBinREY, na)
if (str_detect(na, "sigma"))
tau <- overlapPriorPost(coefModelCountDetectBinREY, na,
prior="dgamma(den$x[j],0.01, 0.01)", from=0, to=1000)
return(tau)
})
## Builds the data.frame required by plotOverlap
df <- data.frame(Parameter=nam, tau=lb)
namo <- paste0("expression(", c("alpha[d]","beta[d]", gsub("kappa","",gsub(",", "", nam[3:11])),
"sigma[e]", "sigma[epsilon]",
"sigma[eta]^(1)", "sigma[eta]^(2)",
"sigma[eta]^(3)",
"sigma[kappa]","sigma[nu]"),")")
df$namo <- namo
df$prior <- "dgamma(z,0.01,0.01)"
df$prior[1:11] <- "dnorm(z,0,sqrt(10))"
df$from <- 0.01
df$to <- 20
df$to[12] <- 100
df$to[13] <- 600
df$to[17] <- 600
df$from[1:11] <- -4
df$to[1:11] <- 4
plotOverlap(coefModelCountDetectBinREY, df, cex=1)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.