Description Usage Arguments Details Value Author(s) References Examples
Estimates the Strategy Switch model (Speekenbrink et al., 2009).
1 2 3 |
y |
A list with each element being a vector with binary responses of a subject. |
X |
A list with each element a matrix of binary indicators for presence X[i,j] = 1 or absence X[i,j] = 0 of cue j at trial i of a subject. |
Z |
A matrix with coefficients for |
prior |
A vector with (starting values) for the prior probabilties of the strategies. |
A |
A list with starting values for the transition matrices. |
b |
A vector with (starting) values for the response consistency parameters of each subject. |
tol |
tolerance for the EM algorithm; estimation stops when the change in logLikelihood is smaller than tol. |
maxiter |
maximum number of iterations of the EM algorithm. |
A.est |
A list with each element a matrix with integers to fix (value 0) that parameter in A or freely estimate (value > 1) it. Giving different elements the same integer > 0 will contrain these elements to have the same value. |
prior.est |
A vector with integers to fix or estimate the prior strategy probabilities. Numbering is similar to that for A.est. |
b.est |
A vector with integers to fix or estimate the response consistency parameter. Numbering is similar to that for A.est |
A.group |
a vector indicating for each subject which transition matrix (element in list A) applies. |
verbose |
(logical) to indicate whether details of the EM iterations should be printed to screen. |
b.min |
lower bound for the consistency parameter. |
This function estimates the Strategy Switch model (Speekenbrink et al., in press). The Strategy Switch model is formulated as a hidden Markov model in which the states are specific strategies of responding to cue patterns. Design matrices for the cue patterns are given in the list X. Each strategy specifies a predicted probability of responses for each cue pattern. These predictions are on a logit scale. The strategies are given as rows in the matrix Z, which contain coefficients such that X[i]][j,]
An list with estimated A, b, prior, etc.
Maarten Speekenbrink
Speekenbrink, M., Lagnado, D. A, Wilkinson, L., Jahanshahi, M. & Shanks, D. R. (in press). Models of probabilistic category learning in Parkinson's disease: Strategy use and the effects of L-dopa. Journal of Mathematical Psychology.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ## open weather prediction data
data(WPT)
## specify the Z matrix for the Constant Error version
Z <- rbind(rep(0,15),
c(0,1,1,-1,-1,-2,0,0,0,0,2,1,1,-1,-1),
c(-1,2,rep(0,13)),
c(-1,0,2,rep(0,12)),
c(1,0,0,-2,rep(0,11)),
c(1,0,0,0,-2,rep(0,10)),
c(0,1,1,-1,-1,-1,1,0,0,-1,1,0,2,-2,0))
## construct y and X lists
y <- X <- list()
for(i in 1:length(levels(WPT$id))) {
dat <- subset(WPT,id==levels(WPT$id)[i])
y[[i]] <- as.numeric(dat$r==0)
X[[i]] <- model.matrix(r~x1*x2*x3*x4 - x1:x2:x3:x4,data=dat)
}
## set initial values for A and prior
A <- matrix(1/7,ncol=7,nrow=7)
prior <- c(1,rep(0,6))
##
## Not run: mod <- StrategySwitch(y=y,X=X,Z=Z,prior=prior,A=A,b=2.8,prior.est=rep(0,7),A.est=TRUE,b.est=TRUE,tol=1e-5,maxiter=2000,A.group=c(1,2),verbose=T,b.min=0.4054651)
## compute BIC
-2*mod$LL + 2*mod$df
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.