getActivations {edl}R Documentation

Function to calculate the activations.


Calculate the activations for all or specific outcomes on the basis of a set of cues. This function combines the various functions to calculate the activations.


  data = NULL,
  cueset = NULL,
  split = "_",
  select.outcomes = NULL,
  init.value = 0,
  normalize = FALSE



A list with weightmatrices, generated by RWlearning or updateWeights. Or, alternatively, wmlist can be a single weightmatrix.


Data frame with columns Cues and Outcomes, specifying one learning event per row (i.e., assuming Frequency=1, as data generated with createTrainingData). Optional argument: when data is provided, the activations will be calculated for each learning event in data (i.e., for the combination of cues and outcomes). When data is set to NULL (no data frame provided), this function will use the cue sets specified in cueset. Use the argument select.outcomes to specify a set of outcomes for which to calculate the activations instead of for the observed outcome(s) only. See examples.


String, specifying the cue set for which to calculate change in activation. Only will be used when data is set to NULL.


String, separator between cues and/or outcomes.


Optional selection of outcomes to limit (or expand) the number of activations that are returned. See examples for how to use this argument in combination with data and cueset. When data is provided, the value of NULL (default) will only return the activations for each learning event (i.e., only for the observed cues and outcomes). When data is provided, the value TRUE will return the activations for all outcomes in data given the cues observed in the learning events. When cueset is specified, the values of NULL (default) or TRUE will return the activations for all outcomes in wmlist. Note that specified values that are not in the weightmatrix will return the initial value without error or warning. Please use getValues for returning all outcomes in the data.


Value of activations for non-existing connections. Typically set to 0.


Logical: whether or not the activation is normalized by dividing the total activation by the number of cues. Default is FALSE. If set to TRUE, the activation reflects the average activation per cue.


List: when data is provided, a list is returned with the outcome activations for each learning event; when cueset is provided, a list is returned with data frames of outcome activations. See examples.


Jacolien van Rij

See Also

getWeightsByCue, getWeightsByOutcome

Other functions for calculating activations: activationsCueSet(), activationsEvents(), activationsMatrix(), activationsOutcomes()


# load example data:

# add obligatory columns Cues, Outcomes, and Frequency:
dat <- droplevels(dat[1:3,])
dat$Cues <- paste("BG", dat$Shape, dat$Color, sep="_")
dat$Outcomes <- dat$Category
dat$Frequency <- dat$Frequency1

# now use createTrainingData to sample from the specified frequencies: 
train <- createTrainingData(dat)

# this training data can actually be used train network:
wm <- RWlearning(train)

# With this data we illustrate four different 
# ways to retrieve activation changes.

# Situation I: return activations for each event 
act1 <- getActivations(wm, data=train)
# plotting activations for each event doesn't provide very 
# useful info:
plot(act1$Activation, type='l', ylim=c(0,1), col=alpha(1),
# these lines may be more interpretable:
n <- which(act1$Outcomes=="animal")
lines(n, act1$Activation[n], col=alpha(2), lwd=2)
n <- which(act1$Outcomes=="plant")
lines(n, act1$Activation[n], col=alpha(3), lwd=2)

# Situation II: return activations for each events
# for all outcomes
act2 <- getActivations(wm, data=train, select.outcomes=TRUE)

plot(act2$plant, type='l', ylim=c(0,1), col=alpha(1),
n <- which(act2$Outcomes=="plant")
rug(n, side=1)
lines(n, act2$plant[n], lwd=2, col=alpha(3))
n <- which(act2$Outcomes!="plant")
lines(n, act2$plant[n], lwd=2, col=alpha(2))
    legend=c("all events", "outcome present", "outcome absent"),
	   col=c(1,alpha(3),alpha(2)), lwd=c(1,2,2),

# Situation III: return activations for specific cuesets
# for all outcomes
act3 <- getActivations(wm, cueset=c("BG_cat_brown", "BG_flower_brown"))

a31 <- act3[["BG_flower_brown"]] # or act3[[1]]
plot(a31$plant, type='l', ylim=c(0,1), col=alpha(1),
    main="BG_flower_brown", ylab='Activation')
rug(which(train$Cues == "BG_flower_brown"), side=1)
    legend=c("plant", "animal"),
	   col=c(1,2), lwd=1, bty='n')

# Situation IV: return activations for a static weight matrix
# Note: only with cueset
(final <- getWM(wm))
act4 <- getActivations(final, cueset=unique(train$Cues))

[Package edl version 1.1 Index]