createTrainingData {edl}R Documentation

Create event training data from a frequency data frame.

Description

Create event training data from a frequency data frame.

Usage

createTrainingData(
  data,
  nruns = 1,
  random = TRUE,
  within.runs = FALSE,
  add.id = TRUE,
  check = TRUE
)

Arguments

data

Data frame with columns Cues and Outcomes, and optionally Frequency.

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 random to the data _within_ each run (if set to TRUE) or over all data (if set to FALSE). Default setting is FALSE. Note that to randomize the data within seprate runs, both random and within.runs should be set to TRUE.

add.id

Logical: whether or not to add columns that identify events (default is TRUE). The column Item is added to describe each type of event (unless this column already exists in data), the column Run is added when within.runs=TRUE, and the column Trial indicates the order of events within the data frame or within the run (when within.runs=TRUE).

check

Logical: check for empty strings ("") or not (defaults to TRUE). If empty strings are found, they will be removed.

Value

data frame

Author(s)

Jacolien van Rij

Examples

# 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)

[Package edl version 1.1 Index]