# NOT RUN {
# load example data:
data(dat)
# add obligatory columns Cues, Outcomes, and Frequency:
dat$Cues <- paste("BG", dat$Shape, dat$Color, sep="_")
dat$Outcomes <- dat$Category
dat$Frequency <- dat$Frequency1
head(dat)
dim(dat)
# now use createTrainingData to sample from the specified frequencies:
train <- createTrainingData(dat)
head(train)
dim(train)
# the rows should be equal to the sum of frequencies in dat:
sum(dat$Frequency)
# this training data can actually be used train network:
wm <- RWlearning(train)
# inspect weight matrix:
wm[[1]]
# retrieve cues and outcomes from data:
c <- getCues(wm)
o <- getOutcomes(wm)
# add missing cues to initial weight matrix:
checkWM(c, o, wm=wm[[1]])
# -------------------
# additional possibility for
# simulating experimental designs:
# -------------------
dat$Frequency <- dat$Frequency2
train2 <- createTrainingData(dat, nruns=5)
head(train2)
# items are completely randomized,
# and not equally distributed over the experiment:
train2$Run <- rep(1:5, each=(nrow(train2)/5))
table(train2$Run, train2$Item)
# in this way the items are randomized within each run:
train3 <- createTrainingData(dat, nruns=5, within.runs=TRUE)
head(train3)
table(train3$Run, train3$Item)
# difference in learning (may take some time):
# }
# NOT RUN {
wm2 <- RWlearning(train2)
plotCueWeights(wm2, cue="brown")
wm3 <- RWlearning(train3)
plotCueWeights(wm3, cue="brown")
plotOutcomeWeights(wm3, outcome="animal")
# }
Run the code above in your browser using DataLab