IAT-example"

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>", 
  #fig.path = "",
  warning = FALSE, 
  message = FALSE
)
library(implicitMeasures)

This vignette illustrates how to use the implicitMeasures package for computing the IAT D score. The illustration is based on the data set raw_data that comes with the package.

First thing first: Import and explore data

Labels containing specification .iat in variable blockcode identify IAT blocks.

data("raw_data")
# explore the dataframe
str(raw_data)
# explore the levels of the blockcode variable to identify the IAT blocks
levels(raw_data$blockcode)

Once the IAT blocks have been identified, it is possible to clean the IAT data by using the clean_iat() function. Since the data set also includes respondents' demographic information (demo in the blockcode variable), it is possible to extract and store these information in a separate data frame:

iat_cleandata <- clean_iat(raw_data, sbj_id = "Participant",
                          block_id = "blockcode",
                          mapA_practice = "practice.iat.Milkbad",
                          mapA_test = "test.iat.Milkbad",
                          mapB_practice = "practice.iat.Milkgood",
                          mapB_test = "test.iat.Milkgood",
                          latency_id = "latency",
                          accuracy_id = "correct",
                          trial_id = "trialcode",
                          trial_eliminate = c("reminder", "reminder1"),
                          demo_id = "blockcode",
                          trial_demo = "demo")

Since also the demographic data has been specified, clean_iat() results in a list of 3 elements:

str(iat_cleandata)

data_keep is a data.frame with class iat_clean. It contains the data set for the compute_iat() function.

data_eliminate is a data.frame that contains all the discarded blocks and trials.

demo is a data.frame that contains all the trials identified as demo in the blockcode variable.

Store the first data_keep element in a data frame for the compute_iat() function.

iat_data <- iat_cleandata[[1]]
head(iat_data)

Compute IAT D score

Once that IAT data have been cleaned with the clean_iat() function, it is possible to compute the D score by using the compute_iat() function.

This function only takes two arguments. The first argument is the data frame with class iat_clean, the second argument is a character specifying the D score algorithm for the computation. To compute multiple D score algorithms at the same time, use themulti_dscore() function.

dscore <- compute_iat(iat_data, Dscore = "d3")
str(dscore)

The compute_iat() function results in a data.frame with class dscore containing a number of rows equal to the number of participants. The columns contain the D score and otehr useful information on the performance of each respondent (see the documentation of the compute_iat() function for further details). The IAT_rel(), descript_d(), d_point(), and d_density() functions require the object resulting from function compute_iat().

IAT descriptive statistics and reliability

The descriptive statistics of the D scores computed on the practice and test blocks, and the actual D scores can be easily obtained with the descript_d() function:

descript_d(dscore) # Data frame containing IAT D-scores

By specifying latex = TRUE, function descript_d() print the results in LaTeX code:

descript_d(dscore, # Data frame containing IAT D-scores
           latex = TRUE) # obtain the code for latex tables

The IAT_rel() function computes the reliability of the IAT by correlating the D score obtained from practice blocks with the D score obtained from test blocks [see @gaw2017 for further details]:

IAT_rel(dscore)

Plotting the results

The implicitMeasures package comes with several functions for obtaining clear representations of the results at both individual respondent and sample levels. Additionally, it includes a function for computing and plotting multiple IAT D score algorithms at the same time.

Individual respondent plot

The d_point() function plots the IAT D score for each respondent.

d_point(dscore) # Data frame containing IAT D scores

In case of large sample size, the label identifying each respondent is difficult to read. It can be eliminated by setting x_values = FALSE.

Respondents can be arranged by increasing or decreasing D scores by setting argument order_sbj equal to "D-increasing" or "D-decreasing", respectively. Descriptive statistics ($M_{\text{D-score}}\pm 2sd$) can be added by setting include_stats = TRUE. Finally, the color of the points can be changed by using argument col_point.

d_point(dscore, # dataframe containing IAT D-scores
       order_sbj = "D-decreasing", # change respondents order
       x_values = FALSE, # remove respodents' labels
       include_stats = TRUE, # include descriptive statistics
       col_point = "lightskyblue") # change points color

Sample level plot

The d_density() function plots the distribution of the IAT D scores. It allows for choosing the most appropriate representation.

d_density(dscore) # dataframe containing IAT Dscores

The number of bins can be changed with argument n_bin. Argument graph can be used for changing the graphical representation of the data. It is possible to choose an histogram representation (graph = "histogram", default), a representation of the density distribution (graph = "density"), or a violin plot (graph = "violin"). Argument col_fill can be used to change the color of the points representing each respondent's score in the violin plot. Descriptive statistics (i.e., $M_{\text{D-score}} \pm 2sd$) can be added to the graph by setting argument include_stats = TRUE.

```rd_density() function with settings change"} d_density(dscore, # dataframe containing IAT Dscores graph = "violin", # change graphical representation include_stats = TRUE) # include descriptive statistics

#### Multiple D scores

The `multi_dscore()` function computes and plot multiple *D* score algorithms. The *D* score algorithms that can be computed depend on the IAT administration. If the IAT administration included a feedback strategy (i.e., built-in correction), only *D1* and *D2* algorithms should be computed. If the IAT administration did not include a feedback strategy, then algorithms *D3*, *D4*, *D5*, and *D6* should be computed. An exhaustive and detailed illustration of the *D* score algorithms is provided in the "Implicit Measures" vignette. To specify the algorithms that can be computed, argument `ds` must be set equal to either `"built-in"` (for the computation of *D1* and *D2*) or `error-inflation` (for the computation of all other algorithms). 

```r
multi_scores <- multi_dscore(iat_data, # object with class "iat_clean"
                             ds = "error-inflation") # string specifying the 
                                            # algorithms to compute

The multi_dscore() function results in a list containing two objects. The first object is a data.frame that contains all the computed algorithms and the respondent IDs.

multi_d <- multi_scores[[1]]
head(multi_d)
str(multi_d)

The second object is a ggplot graph displaying the distribution of the D scores computed with each algorithm in violin plots.

multi_scores[[2]]

References



Try the implicitMeasures package in your browser

Any scripts or data that you put into this service are public.

implicitMeasures documentation built on March 18, 2022, 5:17 p.m.