uvsdSample {hbmem}R Documentation

Function uvsdSample

Description

Runs MCMC for the hierarchical UVSD model

Usage

uvsdSample(dat, M = 10000, keep = (M/10):M, getDIC = TRUE,
freeCrit=TRUE, equalVar=FALSE, freeSig2=FALSE, jump=.01)

Arguments

dat Data frame that must include variables cond,sub,item,lag,resp. Indexes for cond, sub, item, and respone must start at zero and have no gapes (i.e., no skipped subject numbers). Lags must be zero-centered.
M Number of MCMC iterations.
keep Which MCMC iterations should be included in estimates and returned. Use keep to both get ride of burn-in, and thin chains if necessary
getDIC Logical. should the function compute DIC value? This takes a while if M is large.
freeCrit Logical. If TRUE (default) individual criteria vary across people. If false, all participants have the same criteria (but note that overall response biases are still modeled in the means)
equalVar Logical. If FALSE (default), unequal-variance model is fit. If TRUE, equal-variance model is fit.
freeSig2 Logical. If FALSE (default), one sigma is fit for all participants and items (as in Pratte, et al., 2009). If TRUE, then an additive model is placed on the log of sigma2.
jump The criteria and decorrelating steps utilize Matropolis-Hastings sampling routines, which require tuning. All MCMC functions should self tune during the burnin perior (iterations before keep), and they will alert you to the success of tuning. If acceptance rates are too low, "jump" should be decreased, if they are too hight, "jump" should be increased. Alternatively, or in addition to adjusting "jump", simply increase the burnin period which will allow the function more time to self-tune.

Value

The function returns an internally defined "uvsd" structure that includes the following components

mu Indexes which element of blocks contain mu
alpha Indexes which element of blocks contain participant effects, alpha
beta Indexes which element of blocks contain item effects, beta
s2alpha Indexes which element of blocks contain variance of participant effects (alpha).
s2beta Indexes which element of blocks contain variance of item effects (beta).
theta Indexes which element of blocks contain theta, the slope of the lag effect
estN Posterior means of block parameters for new-item means
estS Posterior means of block parameters for studied-item means
estS2 Posterior means of block for studied-item variances.
estCrit Posterior means of criteria
blockN Each iteration for each parameter in the new-item mean block. Rows index iteration, columns index parameter.
blockS Same as blockN, but for the studied-item means
blockS2 Same as blockN, but for variances of studied-item distribution. If equalVar=TRUE, then these values are all zero. If UVSD is fit but freeSig2=FALSE, then only the first element is non-zero (mu).
s.crit Samples of each criteria.
pD Number of effective parameters used in DIC. Note that this should be smaller than the actual number of parameters, as constraint from the hierarchical structure decreases the number of effective parameters.
DIC DIC value. Smaller values indicate better fits. Note that DIC is notably biased toward complexity.
M Number of MCMC iterations run
keep MCMC iterations that were used for estimation and returned
b0 Metropolis-Hastings acceptance rates for decorrelating steps. These should be between .2 and .6. If they are not, the M, keep, or jump need to be adjusted.
b0S2 If additive model is placed on Sigma2 (i.e., freeSigma2=TRUE), then all parameters on S2 must be tuned. b0S2 are the acceptance probabilities for these parameters.

Author(s)

Michael S. Pratte

References

See Pratte, Rouder, & Morey (2009)

See Also

hbmem

Examples

#In this example we generate data from EVSD, then fit it with both
#hierarchical UVSD and UVSD assuming no participant or item effects.
#Note that there is variance in the studied-item distribution, but not
#the new-item distribution.

library(hbmem)
sim=uvsdSim(I=70,J=400,s2aN = 0, s2bN = 0,s2aS=.25,s2bS=.25)
dat=as.data.frame(cbind(sim@subj,sim@item,sim@cond,sim@lag,sim@resp))
colnames(dat)=c("sub","item","cond","lag","resp")

M=100
UVSD=uvsdSample(dat,M=M)
#Now make data frame for data-averaged analysis
adat=dat
adat$sub=0
adat$item=0
aUVSD=uvsdSample(adat,M=M,freeCrit=FALSE)

par(mfrow=c(1,2))
plot(sqrt(exp(UVSD@blockS2[,UVSD@mu])),t='l',main="Hierarchical")
plot(sqrt(exp(aUVSD@blockS2[,aUVSD@mu])),t='l',main="Data-Averaged")

[Package hbmem version 0.1 Index]