State-trace analysis is an alternative to dissociation logic that allows experimenters to deter-mine whether multiple systems are required to explain an experimental result. This is accom-plished by drawing a state-trace plot. To do this, two dependent variables, in this case performance on the rule-based and information-integration category structures, are plotted on the x and y axes. Then, a trace is plotted for each training type condition, with each point being the accuracy from each test block. The state-trace plot is then inspected to determine whether the traces are con-sistent with a single- or multiple-system account (Edmunds et al. 2015)
This page shows how state-trace plot is done in R. In this demo, the treatment variable is 'tem', short for 'temperament',this has 2 levels: HL and LH. The two category structures are CR and II. Performance shown are block-wise average and standard error.
Keep in mind the dataset is merely a demo, the resulted output should not make sense to be interpreted.
library(plotrix)
library(dplyr)
library(data.table)
library(ggplot2)
library(knitr)
set.seed(2288)
subj<-rep(1:60)
Block<-as.factor(rep(1:6, each = 60))
cat_type<-rep(c('CR','II'))
accuracy<-runif(360, min=55, max=96)
a<-data.frame(subj,Block,cat_type, accuracy)
a$tem<-ifelse(a$subj %%3 == 0, 'HL', 'LH')
d5<-a%>%
group_by(tem, cat_type, Block)%>%
summarize(mean=mean(accuracy),sd=sd(accuracy), se=std.error(accuracy))
b<-d5[d5$cat_type=='CR',]
c<-d5[d5$cat_type=='II',]
d<-cbind(b,c)
d<-setnames(d,old=c('tem...1','cat_type...2','Block...3','mean...4','sd...5','se...6','tem...7','cat_type...8','Block...9','mean...10','sd...11','se...12'), new=c('Temp_profile1','cat_type1','Block1','mean1','sd1','se1','Temp_profile2','cat_type2','Block2','mean2','sd2','se2'))
kable(head(d[,1:6]))
| Temp_profile1 | cat_type1 | Block1 | mean1 | sd1 | se1 |
|---|---|---|---|---|---|
| HL | CR | 1 | 70.18797 | 11.941570 | 3.776256 |
| HL | CR | 2 | 80.23538 | 11.245853 | 3.556251 |
| HL | CR | 3 | 77.55925 | 14.926921 | 4.720307 |
| HL | CR | 4 | 74.90772 | 13.221011 | 4.180851 |
| HL | CR | 5 | 77.72639 | 9.366703 | 2.962012 |
| HL | CR | 6 | 78.41915 | 14.293737 | 4.520077 |
d<-d[,c(1:6, 8:12)]
f <- ggplot(d, aes(x = mean1, y = mean2))+
geom_point(aes(color=factor(Temp_profile1)), size = 2)+
geom_errorbar(aes(ymin = mean2-se2,ymax = mean2+se2)) +
geom_errorbar(aes(xmin = mean1-se1,xmax = mean1+se1))+
xlim(60,90)+ylim(60,90) +labs(x='Proportion Correct on CR Task', y='Proportion Correct on II Task', colour='Temperament Profile' ) + theme_bw()
f