Created
December 9, 2013 19:18
-
-
Save vasishth/7879095 to your computer and use it in GitHub Desktop.
Hierarchical linear model (varying intercepts model) with t distribution instead of normal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model | |
{ | |
# The model for each observational unit | |
# (each row is a subject's data point) | |
for( j in 1:N ) | |
{ | |
mu[j] <- beta[1] + beta[2] * ( so[j] ) + u[subj[j]] + w[item[j]] | |
rt[j] ~ dnorm( mu[j], tau.e ) | |
##change the above line to: | |
#rt[j] ~ dt(mu[j],tau.e, 2) | |
##generate predicted values: | |
rt.pred[j] ~ dnorm(mu[j],tau.e) | |
##change the above line to: | |
#rt.pred[j] ~ dt(mu[j],tau.e, 2) | |
} | |
# Random effects for each subject | |
for( i in 1:I ) | |
{ | |
u[i] ~ dnorm(0,tau.u) | |
} | |
# Random effects for each item | |
for( k in 1:K ) | |
{ | |
w[k] ~ dnorm(0,tau.w) | |
} | |
# Uninformative priors: | |
# Fixed effect intercept and slope | |
beta[1] ~ dnorm(0.0,1.0E-5) | |
beta[2] ~ dnorm(0.0,1.0E-5) | |
# Residual (within-person) variance | |
tau.e <- pow(sigma.e,-2) | |
sigma.e ~ dunif(0,2000) | |
# Between-person variation | |
tau.u <- pow(sigma.u,-2) | |
sigma.u ~ dunif(0,500) | |
# Between-item variation | |
tau.w <- pow(sigma.w,-2) | |
sigma.w ~ dunif(0,500) | |
## track predicted values: | |
smallest <- min(rt.pred) | |
mn <- mean(rt.pred) | |
largest <- max(rt.pred) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment