Description Usage Arguments Details Value See Also Examples
View source: R/elicit_priors.R
Here we fix the hyperparameters for priors on theta_i and W_i, i.e., B, U, mu and n_w.
1 2 3 4 5 6 7 8 | make_priors_and_init(
df.background,
col.variables,
col.item,
use.priors = c("ML", "vague"),
use.init = c("random", "vague"),
...
)
|
df.background |
the background dataset |
col.variables |
columns with variables: names or positions |
col.item |
column with the id of the item (i): names or positions |
use.priors |
see details |
use.init |
see details |
... |
additional variables for priors and init (see the description) |
An appropriate initialization value for W^{-1}_i, i=1,2 ($h_p$ and $h_d$ chains respectively) is also generated.
Notice that we have three chains in the LR computations, the same initialization is used thrice.
use.priors
:
'ML'
: maximum likelihood estimation as in \insertCiteBozza2008Probabilisticbayessource
'vague'
: low-information priors
U
is alpha*diag(p)
, B is beta*diag(p)
, mu
is mu0
.
By default alpha = 1, beta = 1, mu0 = 0
The Wishart dofs nw
are set as small as possible without losing full rank:
n_w = 2*(p + 1) + 1
Generate values for W^{-1}_1, W^{-1}_2 that will be used as starting values for the Gibbs chains. Two methods:
use.init
:
'random'
: initialize according to the model
generate one W_i ~ IW_p(n_w, U)
then invert: W^{-1}_i = (W_i)^{-1}
'vague'
: low-information initialization
W_i = alpha_init + beta_init * diag(p)
Some constants can be changed by passing the new values to ...
:
use.priors = 'vague'
: accepts parameters
alpha
(default: 1
)
beta
(default: 1
)
mu0
(default: 0
)
use.init = 'vague'
: accepts parameters
alpha_init
(default: 1
)
beta_init
(default: 100
)
A list of variables:
mu
: the global mean
B.inv
: the between-source prior covariance matrix, as the inverse
U
: the Inverted Wishart scale matrix
nw
: the Inverted Wishart dof n_w
W.inv.1
, W.inv.2
: the initializations for the within-source covariance matrices, as their inverses
a list of variables
Other core functions:
bayessource-package
,
get_minimum_nw_IW()
,
marginalLikelihood_internal()
,
marginalLikelihood()
,
mcmc_postproc()
,
samesource_C()
,
two.level.multivariate.calculate.UC()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # Use the iris data
head(iris, 3)
col_variables <- c(1,3)
col_item <- 5
# Elicitation using MLE
priors_init <- make_priors_and_init(
df.background = iris,
col.variables = col_variables,
col.item = col_item
)
priors_init
priors_init_2 <- make_priors_and_init(
df.background = iris,
col.variables = col_variables,
col.item = col_item,
use.priors = "vague",
alpha_init = 100
)
priors_init_2
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.