Adjusts the posterior distribution of correlations for the sampling error of a population correlation according to the sample size (i.e., the number of participants; Ly, Marsman, & Wagenmakers, 2018).
correlationPosterior(
fittedModel,
r,
N,
kappa = 1,
ci = 0.95,
M = 1000,
precision = 0.005,
maxiter = 10000,
plot = TRUE,
nCPU = 4
)
a fitted betaMPT or traitMPT model with
covariates (added during fitting by the argument covData
)
optional: a vector of posterior correlations (instead of
fittedModel
)
only if r
is used: the number of participants the correlation
is based on
parameter for the prior of the correlation, that is, a scaled
beta distribution: Beta(1/kappa, 1/kappa). The default kappa=1
defines a uniform distribution on [-1,1], whereas kappa<1
defines a
unimodal prior centered around zero.
credibility interval
number of subsamples from the fitted model
precision on the interval [-1,1] to approximate the posterior density
maximum number of iterations in
genhypergeo
. Higher values might be necessary to
increase numerical stability for large correlations (r>.95).
whether to plot (a) the unadjusted posterior correlations (gray histogram) and (b) the corrected posterior (black line with red credibility intervals)
number of CPUs used for parallel computation of posterior distribution
Daniel W. Heck, Alexander Ly
This function (1) uses all posterior samples of a correlation to (2) derive the posterior of the correlation corrected for sampling error and (3) averages these densities across the posterior samples. Thereby, the method accounts for estimation uncertainty of the MPT model (due to the use of the posterior samples) and also for sampling error of the population correlation due to sample size (cf. Ly, Boehm, Heathcote, Turner, Forstmann, Marsman, & Matzke, 2016).
Ly, A., Marsman, M., & Wagenmakers, E.-J. (2018). Analytic posteriors for Pearson’s correlation coefficient. Statistica Neerlandica, 72, 4–13. tools:::Rd_expr_doi("10.1111/stan.12111")
Ly, A., Boehm, U., Heathcote, A., Turner, B. M. , Forstmann, B., Marsman, M., and Matzke, D. (2017). A flexible and efficient hierarchical Bayesian approach to the exploration of individual differences in cognitive-model-based neuroscience. https://osf.io/evsyv/. tools:::Rd_expr_doi("10.1002/9781119159193")
# test effect of number of participants:
set.seed(123)
cors <- rbeta(50, 100, 70)
correlationPosterior(r = cors, N = 10, nCPU = 1)
correlationPosterior(r = cors, N = 100, nCPU = 1)
Run the code above in your browser using DataLab