get_prior_factor {EMC2} | R Documentation |
Prior specification and prior sampling for factor estimation
Description
To get the default priors for a given design: get_prior_factor(design = design, sample = FALSE)
Usage
get_prior_factor(
prior = NULL,
n_pars = NULL,
sample = TRUE,
N = 1e+05,
selection = "mu",
design = NULL,
Lambda_mat = NULL,
n_factors = NULL
)
Arguments
prior |
A named list that can contain the prior mean ( |
n_pars |
Often inferred from the design, but if |
sample |
Whether to sample from the prior or to simply return the prior. Default is TRUE, |
N |
How many samples to draw from the prior, the default is 1e5 |
selection |
Character. If |
design |
The design obtained from |
Lambda_mat |
The loadings constraint matrix. |
n_factors |
Integer. The number of factors. |
Details
For details see Ghosh, J., & Dunson, D. B. (2009). Default prior distributions and efficient posterior computation in Bayesian factor analysis. Journal of Computational and Graphical Statistics, 18, 306-320. or Stevenson, N., Innes, R. J., Gronau, Q. F., Miletic, S., Heathcote, A., PhD, Forstmann, B., & Brown, S. (2024). Using group level factor models to resolve high dimensionality in model-based sampling. https://doi.org/10.31234/osf.io/pn3wv.
Note that if sample = FALSE
, prior$theta_mu_invar (the inverse of the prior covariance matrix on the group-level mean) is returned,
which is only used for computational efficiency
Value
A list with a single entry of type of samples from the prior (if sample = TRUE
) or else a prior object
Examples
# First define a design for the model
design_DDMaE <- design(data = forstmann,model=DDM,
formula =list(v~0+S,a~E, t0~1, s~1, Z~1, sv~1, SZ~1),
constants=c(s=log(1)))
# Now get the default prior
prior <- get_prior_factor(design = design_DDMaE, sample = FALSE, n_factors = 3)
# We can change values in the default prior or use `prior`
# Then we can get samples from this prior e.g.
samples <- get_prior_factor(prior = prior, design = design_DDMaE,
sample = TRUE, selection = "mu", n_factors = 3)