writeIATfull: Builds a fully functional IAT with counterbalanced...

View source: R/writeIATfull.R

writeIATfullR Documentation

Builds a fully functional IAT with counterbalanced permutations

Description

This is the primary function for building IATs. It has two modes. In automatic mode (set qsf=TRUE), the function creates a fully functional *.qsf file (Qualtrics survey file) in the user’s working directory, ready to import into Qualtrics. In manual mode (the default option, qsf=FALSE), it creates four numbered folders which contain HTML and JavaScript code which can be pasted into a template (see tutorial for manual mode at www.iatgen.wordpress.com). In both modes, the user specifies features of the IAT. The user must specify a name for the IAT (IATname) and the four labels for the targets and categories (posname, negname, Aname, and Bname). The user must also always specify the type of stimuli for both targets (tgtType="words" or tgtType="images") and categories (catType="words" or catType="images"). The user must also specify the stimuli sets for each of the four terms (when images: Aimgs, Bimgs, posimgs, and negimgs; when words: Awords, Bwords, poswords, and negwords). Word stimuli are specified by vectors of words (e.g., poswords=c("Gentle", "Enjoy", "Heaven", "Cheer", "Happy", "Love", "Friend"), whereas images are specified by vectors of image URLs: (e.g., posimgs=c("www.website.com/gentle.jpg", "www.website.com/enjoy.jpg", "www.website.com/Heaven.jpg"). We recommend users host their own images to avoid issues for participants (see tutorial on www.iatgen.wordpress.com). Beyond the above, there are a number of additional settings. By default, the IAT creates a 250-ms pause between trials (Greenwald et al., 1998), but this can be changed using the pause argument (e.g., pause=500). By default, the function also produces the original Greenwald et al. (1998) variant in which an error message (a red X) flashes for a pause before automatically starting the next trial (default = 300 ms, can be changed by setting errorpause to a number other than 300 [e.g., errorpause = 400]). We recommend using a popular variant of the IAT in which the user must correct errors before proceeding to the next trial, which is accomplished by setting correct.error=TRUE. Users can also edit the color of the targets using the optional tgtCol argument (e.g., tgtCol="black") which is set to black by default. Users can change the color of attributes using the catCol argument (e.g., catCol="green"), and can be set to any CSS color (see www.w3schools.com/colors/colors_names.asp for a list of all compatible colors). The user can set the number of trials by specifying the n argument. Users can enable a note reminding participants about the keypress directions during the IAT by setting note=TRUE, which is used on some popular IAT websites (e.g., www.projectimplicit.org) and may be useful in online settings where participants cannot directly approach an experimenter with questions.

Usage

writeIATfull(
  IATname = "IAT",
  posname,
  negname,
  Aname,
  Bname,
  n = c(20, 20, 20, 40, 40, 20, 40),
  catType,
  catCol = "green",
  poswords,
  negwords,
  posimgs,
  negimgs,
  tgtType,
  tgtCol = "black",
  Awords,
  Bwords,
  Aimgs,
  Bimgs,
  swap = "target",
  qsf = FALSE,
  pause = 250,
  errorpause = 300,
  correct.error = TRUE,
  note = FALSE,
  norepeat = FALSE,
  startqid = 1
)

Arguments

IATname

(Required, set by default). A short string of text that serves to name the IAT. By default, set as 'IAT'. Do not add spaces or special characters.

posname

(Required). The name of the positive category as appears to participants.

negname

(Required). The name of the negative category as appears to participants.

Aname

(Required). The name of Target A as appears to participants.

Bname

(Required). The name of Target B as appears to participants.

n

(Required, set by default). A numeric vector of length seven, indicating the number of trials in each block. By default, c(20, 20, 20, 40, 40, 20, 40). Block 5 is set, by default, to 40 trials following Nosek et al. (2005). Trials should be even numbers, and for combined blocks, divisible by 4.

catType

(Required). Can be catType="words" or catType="images". Determines whether the code adds text or images for category stimuli. If catType="words", user must specify two additional arguments: poswords and negwords. If catType="images", the user must specify two additional arguments: posimgs and negimgs.

catCol

(Required, set by default). Sets the color of the category stimuli and on-screen labels. By default, set to catCol="green" but can be set to any CSS color name.

poswords

(Required if catType="words"). Should be a vector of stimuli, e.g. poswords=c("Gentle", "Enjoy", "Heaven", "Cheer", "Happy", "Love", "Friend"). Ignored if catType="images".

negwords

(Required if catType="words"). Should be a vector of stimuli, e.g. negwords=c("Poison", "Evil", "Gloom", "Damage", "Vomit", "Ugly", "Hurt"). Ignored if catType="images".

posimgs

(Required if catType="images"). Should be a vector of image URLs, e.g. posimgs=c("www.website.com/gentle.jpg", "www.website.com/enjoy.jpg"). Users should have legal rights to use images and should host them personally (or via Qualtrics). For more on image sizing and how to host images, see tutorial at www.iatgen.wordpress.com. Ignored if catType="words".

negimgs

(Required if catType="images"). Should be a vector of image URLs, e.g. negimgs=c("www.website.com/poison.jpg", "www.website.com/evil.jpg"). Users should have legal rights to use images and should host them personally (or via Qualtrics). For more on image sizing and how to host images, see tutorial at www.iatgen.wordpress.com. Ignored if catType="words".

tgtType

(Required). Can be tgtType="words" or tgtType="images". Determines whether text or images are used for tgt stimuli. If tgtType="words", user must specify two additional arguments: Awords and Bwords. If tgtType="images", the user must specify two additional arguments: Aimgs and Bimgs.

tgtCol

(Required, set by default). Sets the color of the target stimuli and on-screen labels. By default, set to tgtCol="black" but can be set to any CSS color name.

Awords

(Required if tgtType="words"). Should be a vector of stimuli, e.g. Awords=c("Orchid", "Tulip", "Rose", "Daffodil", "Daisy", "Lilac", "Lily"). Ignored if tgtType="images".

Bwords

(Required if tgtType="words"). Should be a vector of stimuli, e.g. Bwords=c("Wasp", "Flea", "Roach", "Centipede", "Moth", "Bedbug", "Gnat"). Ignored if tgtType="images".

Aimgs

(Required if tgtType="images"). Should be a vector of image URLs, e.g. Aimgs=c("www.website.com/Orchid.jpg", "www.website.com/Tulip.jpg"). Users should have legal rights to use images and should host them personally (or via Qualtrics). For more on image sizing and how to host images, see tutorial at www.iatgen.wordpress.com. Ignored if tgtType="words".

Bimgs

(Required if tgtType="images"). Should be a vector of image URLs, e.g. Bimgs=c("www.website.com/Wasp.jpg", "www.website.com/flea.jpg"). Users should have legal rights to use images and should host them personally (or via Qualtrics). For more on image sizing and how to host images, see tutorial at www.iatgen.wordpress.com. Ignored if tgtType="words".

swap

(Required, set by default). Should be a scalar of either "category" or "target." Determines what swaps sides at Block 5. If swap="target", then the target (e.g., insects/flowers) swap sides. If sawp="category" then the category (e.g., pleasant/unpleasant) swapws sides. Both see use in the literature, although target swapping may be more common. Category swapping is more common in consumer IATs.

qsf

(Required, set by default). Logical value, set to FALSE by default. If qsf=TRUE, creates a functional Qualtrics Survey File (*.qsf) for the user to import directly into Qualtrics. If set to qsf=FALSE, the user must copy paste JavaScript and HTML files into a template. The QSF feature is not compatible with multi-IAT designs. See tutorial on www.iatgen.wordpress.com for multi-IAT designs and usage of manual mode.

pause

(Required, set by default). Numeric value sets the delay between trials (displaying the fixation cross) in milliseconds. By default, set to 250 (Greenwald et al., 1998) but can be set to any value.

errorpause

(Required if correct.error=TRUE). This sets the amount of time in milliseconds to display the red X in case of an error. By default, set to 300 ms (Greenwald et al., 1998) but can be set to any value. Ignored if correct.error=T.

correct.error

(Required, set by default). Logical value, set to TRUE by default. When correct.error=TRUE, creates a variant where participants must correct errors in order to proceed from one trial to the next (see Greenwald et al., 2003). When correct.error=FALSE, the IAT follows the original Greenwald et al. (1998) procedure in which an error message flashes on the screen between trials. Note that forced error correction is the default in most modern IAT software.

note

(Required, set by default). Logical value, set to FALSE by default. When note=TRUE, displays a persistent note at the bottom of the window reminding participants which keys to press and how to handle errors (if correct.error=TRUE). This is recommended for non-laboratory use, where participants are unable to ask for assistance.

norepeat

(Required, set by default). Logical value, set to FALSE by default. This controls the order in which stimuli are displayed. In the IAT, we always sample stimuli randomly without replacement from pools, replenishing the pools after they are depleted. In other words, any given stimulus will not appear twice in the IAT until all other stimuli from that pool are depleted. This keeps the distribution of stimuli even from participant to participant. However, iatgen then randomizes (within each block) the order in which those stimuli are displayed (e.g., Gawronski, 2002). Setting this to TRUE displays stimuli in the order sampled, meaning that there are no repeats seen *by the participant* until all stimuli from that stimuli set have been seen. This only changes the display order within a block.

startqid

(Required, set by default). Numeric value that impacts how files are named, which is only visible to users in manual mode. Although this does not substantively impact the IAT, it can make building multi-IAT studies easier in manual mode (see tutorial at www.iatgen.wordpress.com). By default, startqid=1, which means that iatgen creates files named Q1 through Q28, which are intended to be pasted into Q1 through Q28 of a Qualtrics survey. If a user is starting an IAT on a different question number (e.g., adding a second IAT, which starts on Q29 and ends on adding an additional IAT (e.g., as in the multi-IAT templates on www.iatgen.wordpress.com), then (for convenience) the user should set startqid to the lowest question number for the new IAT. For example, if a user wished to add an a second IAT to Q29 through Q56, the user would set startqid=29. The software will then clearly label the files Q29 through Q56 so it is clear where to add the code to the survey. This is intended only for advanced users and users building multi-IAT studies (see www.iatgen.wordpress.com for more information).

Value

Nothing is returned. However, a QSF file (if qsf=T) or folders (if qsf=F) are made in the working directory containing both HTML and JavaScript files that are to be pasted into Qualtrics.

References

Greenwald, A. G., McGhee, D. E., & Schwartz, J. L. K. (1998). Measuring individual differences in implicit cognition: The Implicit Association Test. Journal of Personality and Social Psychology, 74, 1464–1480. https://doi.org/10.1037/0022-3514.74.6.1464

Greenwald, A. G., Nosek, B. A., & Banaji, M. R. (2003). Understanding and using the Implicit Association Test: I. An improved scoring algorithm. Journal of Personality and Social Psychology, 85, 197–216. https://doi.org/10.1037/0022-3514.85.2.197

Nosek, B. A., Greenwald, A. G., & Banaji, M. R. (2005). Understanding and using the implicit association test: II. Method variables and construct validity. Personality and Social Psychology Bulletin, 31, 166–180. https://doi.org/10.1177/0146167204271418

See Also

See www.iatgen.wordpress.com for tutorials and files.

Examples

## Not run: 

### A words-only IAT with recommended settings. IAT examines insects vs. flowers
#   and is named "flowins". Recommended settings builds a QSF file automatically
#   with forced error correction and a note reminding participants of the instructions.
### Note: the following are specified below for example purposes but are specified
#   by default automatically and can be omitted: coloring of stimuli,
#   number of trials per block, pause between trials.

writeIATfull(
  IATname = "flowins",
  posname = "Pleasant",
  negname = "Unpleasant",
  Aname = "Flowers",
  Bname = "Insects",
  catType = "words",
  poswords = c("Gentle", "Enjoy", "Heaven", "Cheer", "Happy", "Love", "Friend"),
  negwords = c("Poison", "Evil", "Gloom", "Damage", "Vomit", "Ugly", "Hurt"),
  tgtType = "words",
  Awords = c("Orchid", "Tulip", "Rose", "Daffodil", "Daisy", "Lilac", "Lily"),
  Bwords = c("Wasp", "Flea", "Roach", "Centipede", "Moth", "Bedbug", "Gnat"),

  # advanced options with recommended IAT settings
  n = c(20, 20, 20, 40, 40, 20, 40),
  qsf = T,
  note = T,
  correct.error = T,
  pause = 250,
  tgtCol = "black",
  catCol = "green"
)

### Same IAT but with the persistent task directions disabled (\code{note=FALSE}),
#   forced error correction disabled (\code{correct.error=FALSE}) and a 300 ms pause
#   for the error message (\code{errorpause=300}).

writeIATfull(
  IATname = "flowins",
  posname = "Pleasant",
  negname = "Unpleasant",
  Aname = "Flowers",
  Bname = "Insects",
  catType = "words",
  poswords = c("Gentle", "Enjoy", "Heaven", "Cheer", "Happy", "Love", "Friend"),
  negwords = c("Poison", "Evil", "Gloom", "Damage", "Vomit", "Ugly", "Hurt"),
  tgtType = "words",
  Awords = c("Orchid", "Tulip", "Rose", "Daffodil", "Daisy", "Lilac", "Lily"),
  Bwords = c("Wasp", "Flea", "Roach", "Centipede", "Moth", "Bedbug", "Gnat"),

  # advanced options
  n = c(20, 20, 20, 40, 40, 20, 40),
  qsf = T,
  note = F,
  correct.error = F,
  pause = 250,
  errorpause = 300,
  tgtCol = "black",
  catCol = "green"
)

### Same IAT as prior example but with 10 trials for all non-critical blocks
#   and 12 trials for all critical blocks.

writeIATfull(
  IATname = "flowins",
  posname = "Pleasant",
  negname = "Unpleasant",
  Aname = "Flowers",
  Bname = "Insects",
  catType = "words",
  poswords = c("Gentle", "Enjoy", "Heaven", "Cheer", "Happy", "Love", "Friend"),
  negwords = c("Poison", "Evil", "Gloom", "Damage", "Vomit", "Ugly", "Hurt"),
  tgtType = "words",
  Awords = c("Orchid", "Tulip", "Rose", "Daffodil", "Daisy", "Lilac", "Lily"),
  Bwords = c("Wasp", "Flea", "Roach", "Centipede", "Moth", "Bedbug", "Gnat"),

  # advanced options
  n = c(10, 10, 10, 12, 10, 10, 12),
  qsf = T,
  note = F,
  correct.error = F,
  pause = 250,
  errorpause = 300,
  tgtCol = "black",
  catCol = "green"
)

### An images-only IAT with recommended settings. Note that image URL vectors
#   are specified first to simplify the code.
goodjpg <- c(
  "www.website.com/gentle.jpg",
  "www.website.com/enjoy.jpg",
  "www.website.com/Heaven.jpg",
  "www.website.com/Cheer.jpg"
)

badjpg <- c(
  "www.website.com/Poison.jpg",
  "www.website.com/Evil.jpg.",
  "www.website.com/Vomit.jpg",
  "www.website.com/Ugly.jpg"
)

Ajpg <- c(
  "www.website.com/Orchid.jpg",
  "www.website.com/Tulip.jpg",
  "www.website.com/Rose.jpg",
  "www.website.com/Daisy.jpg"
)

Bjpg <- c(
  "www.website.com/Wasp.jpg",
  "www.website.com/Flea.jpg",
  "www.website.com/Moth.jpg",
  "www.website.com/Bedbug.jpg"
)

writeIATfull(
  IATname = "flowins",
  posname = "Pleasant",
  negname = "Unpleasant",
  Aname = "Flowers",
  Bname = "Insects",
  catType = "images",
  posimgs = goodjpg,
  negimgs = badjpg,
  tgtType = "images",
  Aimgs = Ajpg,
  Bimgs = Bjpg,

  # advanced options with recommended IAT settings
  n = c(20, 20, 20, 40, 40, 20, 40),
  qsf = T,
  note = T,
  correct.error = T,
  pause = 250,
  tgtCol = "black",
  catCol = "green"
)

### Example IAT with images for categories and words for targets, with recommended settings.
goodjpg <- c(
  "www.website.com/gentle.jpg",
  "www.website.com/enjoy.jpg",
  "www.website.com/Heaven.jpg",
  "www.website.com/Cheer.jpg"
)

badjpg <- c(
  "www.website.com/Poison.jpg",
  "www.website.com/Evil.jpg.",
  "www.website.com/Vomit.jpg",
  "www.website.com/Ugly.jpg"
)

writeIATfull(
  IATname = "flowins",
  posname = "Pleasant",
  negname = "Unpleasant",
  Aname = "Flowers",
  Bname = "Insects",
  catType = "images",
  posimgs = goodjpg,
  negimgs = badjpg,
  tgtType = "words",
  Awords = c("Orchid", "Tulip", "Rose", "Daffodil", "Daisy", "Lilac", "Lily"),
  Bwords = c("Wasp", "Flea", "Roach", "Centipede", "Moth", "Bedbug", "Gnat"),

  # advanced options with recommended IAT settings
  n = c(20, 20, 20, 40, 40, 20, 40),
  qsf = T,
  note = T,
  correct.error = T,
  pause = 250,
  tgtCol = "black",
  catCol = "green"
)

### Example IAT with images for targets and words for categories, with recommended settings.
Ajpg <- c(
  "www.website.com/Orchid.jpg",
  "www.website.com/Tulip.jpg",
  "www.website.com/Rose.jpg",
  "www.website.com/Daisy.jpg"
)

Bjpg <- c(
  "www.website.com/Wasp.jpg",
  "www.website.com/Flea.jpg",
  "www.website.com/Moth.jpg",
  "www.website.com/Bedbug.jpg"
)

writeIATfull(
  IATname = "flowins",
  posname = "Pleasant",
  negname = "Unpleasant",
  Aname = "Flowers",
  Bname = "Insects",
  catType = "words",
  poswords = c("Gentle", "Enjoy", "Heaven", "Cheer", "Happy", "Love", "Friend"),
  negwords = c("Poison", "Evil", "Gloom", "Damage", "Vomit", "Ugly", "Hurt"),
  tgtType = "images",
  Aimgs = Ajpg,
  Bimgs = Bjpg,

  # advanced options with recommended IAT settings
  n = c(20, 20, 20, 40, 40, 20, 40),
  qsf = T,
  note = T,
  correct.error = T,
  pause = 250,
  tgtCol = "black",
  catCol = "green"
)

### EXAMPLE IAT USING 'norepeat=TRUE" TO SUPPRESS REPEAT STIMULI UNTIL ALL STIMULI
#   FROM THAT CATEGORY HAVE BEEN SEEN

writeIATfull(
  IATname = "flowins",
  posname = "Pleasant",
  negname = "Unpleasant",
  Aname = "Flowers",
  Bname = "Insects",
  catType = "words",
  poswords = c("Gentle", "Enjoy", "Heaven", "Cheer", "Happy", "Love", "Friend"),
  negwords = c("Poison", "Evil", "Gloom", "Damage", "Vomit", "Ugly", "Hurt"),
  tgtType = "words",
  Awords = c("Orchid", "Tulip", "Rose", "Daffodil", "Daisy", "Lilac", "Lily"),
  Bwords = c("Wasp", "Flea", "Roach", "Centipede", "Moth", "Bedbug", "Gnat"),

  # advanced options
  n = c(20, 20, 20, 40, 40, 20, 40),
  qsf = T,
  note = F,
  correct.error = F,
  pause = 250,
  errorpause = 300,
  tgtCol = "black",
  catCol = "green",
  norepeat = TRUE
)

## End(Not run)

iatgen/iatgen documentation built on Oct. 23, 2023, 10:55 a.m.