Extract quantile distribution from mcmcComposite object
as.quantiles(
x,
chain = 1,
fun = function(...) return(as.numeric(list(...))),
probs = c(0.025, 0.975),
xlim = NULL,
nameparxlim = NULL,
namepar = NULL
)
A mcmcComposite obtained as a result of MHalgoGen()
function
The number of the chain in which to get parameters
The function to apply the parameters
The probability to get quantiles
The values to apply in fun
The name of the parameter for xlim
The name of parameters from mcmc object to be used in fun
A data.frame with quantiles
Other mcmcComposite functions:
MHalgoGen()
,
as.mcmc.mcmcComposite()
,
as.parameters()
,
merge.mcmcComposite()
,
plot.mcmcComposite()
,
summary.mcmcComposite()
# NOT RUN {
library(HelpersMG)
require(coda)
x <- rnorm(30, 10, 2)
dnormx <- function(data, x) {
data <- unlist(data)
return(-sum(dnorm(data, mean=x['mean'], sd=x['sd'], log=TRUE)))
}
parameters_mcmc <- data.frame(Density=c('dnorm', 'dlnorm'),
Prior1=c(10, 0.5), Prior2=c(2, 0.5), SDProp=c(1, 1),
Min=c(-3, 0), Max=c(100, 10), Init=c(10, 2), stringsAsFactors = FALSE,
row.names=c('mean', 'sd'))
mcmc_run <- MHalgoGen(n.iter=10000, parameters=parameters_mcmc, data=x,
likelihood=dnormx, n.chains=1, n.adapt=100, thin=1, trace=1)
k <- as.quantiles(x=mcmc_run, namepar="mean")
k <- as.quantiles(x=mcmc_run, namepar="mean",
xlim=c(1:5), nameparxlim="sd",
fun=function(...) return(sum(as.numeric(list(...)))))
# }
Run the code above in your browser using DataLab