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
)

Arguments

likelihoodProfile

Named vector containing grid likelihood data from Cyclops.

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
)
#> Detected data following grid distribution
#> Performing MCMC. This may take a while

# Report posterior expectation
mean(mcmcTraces$theta)
#> [1] 0.4205803

# (Estimates in this example will vary due to the random simulation)