library(ndl)
# create sequence of learning events
n = 1000
dat = data.frame(
backgroundCue = rep("bird", n),
colorCue = c(rep("red", n/2), rep("blue", n/2))
)
set.seed(314)
dat = dat[sample(1:nrow(dat)),]
rownames(dat)=1:n
dat$category = ifelse(dat$colorCue=="red", "wug", "niz")
#put in the right format
dat$Frequency=1
dat$Cues = paste(dat$backgroundCue, dat$colorCue, sep="_")
dat$Outcomes = dat$category
#rescorla wagner function -> association between "red" and "wug"
dat.rw = RescorlaWagner(dat, traceCue="red", traceOutcome="wug", random=F)
plot(dat.rw)
#rescorla wagner function -> association between "bird" and "wug"
dat.bw = RescorlaWagner(dat, traceCue="bird", traceOutcome="wug", random=F)
plot(dat.bw)
#rescorla wagner function -> association between "bird" and "niz"
dat.bn = RescorlaWagner(dat, traceCue="bird", traceOutcome = "niz", random = F)
plot(dat.bn)
#rescorla wagner function -> association between "red" and "niz"
dat.rn = RescorlaWagner(dat, traceCue="red", traceOutcome = "niz", random = F)
plot(dat.rn)
###############################
redniz = RescorlaWagner(dat, traceCue="red", traceOutcome="niz", random=F)
birdniz = RescorlaWagner(dat, traceCue="bird", traceOutcome="niz", random=F)
plot(1:n, redniz$weightvector+birdniz$weightvector, type="l")
abline(h=0)
redwug = RescorlaWagner(dat, traceCue="red", traceOutcome="wug", random=F)
birdwug = RescorlaWagner(dat, traceCue="bird", traceOutcome="wug", random=F)
plot(1:n, redwug$weightvector+birdwug$weightvector, type="l")
abline(h=1)