Description Usage Arguments Value Author(s) Examples
View source: R/createTrainingData.R
Create event training data from a frequency data frame.
1 2 3 4 5 6 7 8 |
data |
Data frame with columns |
nruns |
Numeric: number of times to run through the data. |
random |
Logical: randomize the data or not (defaults to TRUE). |
within.runs |
Logical: apply setting of |
add.id |
Logical: whether or not to add columns that identify events
(default is TRUE). The column |
check |
Logical: check for empty strings ("") or not (defaults to TRUE). If empty strings are found, they will be removed. |
data frame
Jacolien van Rij
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | # 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")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.