Description Usage Arguments Details Author(s) See Also Examples

Fits a density function to a multivariate sample

1 2 | ```
createPriorDensity(sampler, method = "multivariate", eps = 1e-10,
lower = NULL, upper = NULL, best = NULL, ...)
``` |

`sampler` |
an object of class BayesianOutput or a matrix |

`method` |
method to generate prior - default and currently only option is multivariate |

`eps` |
numerical precision to avoid singularity |

`lower` |
vector with lower bounds of parameter for the new prior, independent of the input sample |

`upper` |
vector with upper bounds of parameter for the new prior, independent of the input sample |

`best` |
vector with "best" values of parameter for the new prior, independent of the input sample |

`...` |
parameters to pass on to the getSample function |

This function fits a density estimator to a multivariate (typically a posterior) sample. The main purpose is to summarize a posterior sample as a pdf, in order to include it as a prior in a new analysis, for example when new data becomes available, or to calculate a fractional Bayes factor (see `marginalLikelihood`

).

The limitation of this function is that we currently only implement a multivariate normal density estimator, so you will have a loss of information if your posterior is not approximately multivariate normal, which is likely the case if you have weak data. Extending the function to include more flexible density estimators (e.g. gaussian processes) is on our todo list, but it's quite tricky to get this stable, so I'm not sure when we will have this working. In general, creating reliable empirical density estimates in high-dimensional parameter spaces is extremely tricky, regardless of the software you are using.

For that reason, it is usually recommended to not update the posterior with this option, but rather:

1. If the full dataset is available, to make a single, or infrequent updates, recompute the entire model with the full / updated data

2. For frequent updates, consider using SMC instead of MCMC sampling. SMC sampling doesn't require an analytical summary of the posterior.

Florian Hartig

`createPrior`

`createBetaPrior`

`createTruncatedNormalPrior`

`createUniformPrior`

`createBayesianSetup`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | ```
# Create a BayesianSetup
ll <- generateTestDensityMultiNormal(sigma = "no correlation")
bayesianSetup = createBayesianSetup(likelihood = ll,
lower = rep(-10, 3),
upper = rep(10, 3))
settings = list(iterations = 1000)
out <- runMCMC(bayesianSetup = bayesianSetup, settings = settings)
newPrior = createPriorDensity(out, method = "multivariate",
eps = 1e-10, lower = rep(-10, 3),
upper = rep(10, 3), best = NULL)
bayesianSetup <- createBayesianSetup(likelihood = ll, prior = newPrior)
## Not run:
settings = list(iterations = 1000)
out <- runMCMC(bayesianSetup = bayesianSetup, settings = settings)
## End(Not run)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.