View source: R/BayesianSynthesis.R
approximateSimplePosterior | R Documentation |
Approximate a Bayesian posterior from a Cyclops
likelihood profile and normal prior
using the Markov chain Monte Carlo engine BEAST.
approximateSimplePosterior(
likelihoodProfile,
chainLength = 1100000,
burnIn = 1e+05,
subSampleFrequency = 100,
priorMean = 0,
priorSd = 0.5,
startingValue = 0,
seed = 1
)
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. |
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.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.