approximateSimplePosterior {EvidenceSynthesis} | R Documentation |
Approximate simple Bayesian posterior
Description
Approximate a Bayesian posterior from a Cyclops
likelihood profile and normal prior
using the Markov chain Monte Carlo engine BEAST.
Usage
approximateSimplePosterior(
likelihoodProfile,
chainLength = 1100000,
burnIn = 1e+05,
subSampleFrequency = 100,
priorMean = 0,
priorSd = 0.5,
startingValue = 0,
seed = 1
)
Arguments
likelihoodProfile |
Named vector containing grid likelihood data from |
chainLength |
Number of MCMC iterations. |
burnIn |
Number of MCMC iterations to consider as burn in. |
subSampleFrequency |
Subsample frequency for the MCMC. |
priorMean |
Prior mean for the regression parameter |
priorSd |
Prior standard deviation for the regression parameter |
startingValue |
Initial state for regression parameter |
seed |
Seed for the random number generator. |
Value
A data frame with the point estimates and 95% credible intervals for the regression parameter. Attributes of the data frame contain the MCMC trace for diagnostics.
Examples
# Simulate some data for this example:
population <- simulatePopulations(createSimulationSettings(nSites = 1))[[1]]
# Fit a Cox regression at each data site, and approximate likelihood function:
cyclopsData <- Cyclops::createCyclopsData(Surv(time, y) ~ x + strata(stratumId),
data = population,
modelType = "cox"
)
cyclopsFit <- Cyclops::fitCyclopsModel(cyclopsData)
likelihoodProfile <- approximateLikelihood(cyclopsFit, parameter = "x", approximation = "grid")
# Run MCMC
mcmcTraces <- approximateSimplePosterior(
likelihoodProfile = likelihoodProfile,
priorMean = 0, priorSd = 100
)
# Report posterior expectation
mean(mcmcTraces$theta)
# (Estimates in this example will vary due to the random simulation)
[Package EvidenceSynthesis version 0.5.0 Index]