This function calculates the proportion correct of each item in the serial position curve. Data should include the participant's answers in long format (use arrange_data() in this package for help), the answer key of the items in order, and a column that denotes the order a participant listed each item. The function will then calculate the items remembered within a window of 1 before or 1 after the tested position. The first and last positions must be answered in the correct place. Specifically, this function is an extension of serial_position() for free recall when there are multiple lists or randomized lists.

serial_position_multiple(
  data,
  position,
  answer,
  key,
  key.trial,
  id.trial,
  scored,
  group.by = NULL
)

Arguments

data

a dataframe of the scored free recall that you would like to calculate - use prop_correct_multiple() for best formatting.

position

a column name in the dataframe that contains answered position of each response in quotes (i.e., "column")

answer

a column name of the answer given for that position in the original dataframe.

key

a vector containing the scoring key or data column name. This column does not have to be included in the original dataframe. We assume your answer key is in the tested position order. You should not include duplicates in your answer key.

key.trial

a vector containing the trial numbers for each answer. Note: If you input long data (i.e., repeating trial-answer responses), we will take the unique combination of the responses. If a trial number is repeated, you will receive an error. Key and key.trial can also be a separate dataframe, depending on how your output data is formatted.

id.trial

a column name containing the trial numbers for the participant data from the original dataframe. Note that the free response "key" trial and this trial number should match. The trial key will be repeated for each answer a participant gave.

scored

a column in the original dataframe indicating if the participant got the answer correct (1) or incorrect (0).

group.by

an optional argument that can be used to group the output by condition columns. These columns should be in the original dataframe and concatenated c() if there are multiple columns

Value

DF_Serial

A dataframe of the proportion correct for each tested position by any optional grouping variables included.

Details

This output can then be used to create a serial position curve visualizations, and an example can be found in our manuscript/vignettes.

Examples


data("multi_data")
data("multi_answers")

DF_long <- arrange_data(data = multi_data,
                       responses = "Response",
                       sep = " ",
                       id = "Sub.ID",
                       repeated = "List.Number")

library(reshape)
multi_answers$position <- 1:nrow(multi_answers)
answer_long <- melt(multi_answers,
                    measured = colnames(multi_answers),
                    id = "position")
colnames(answer_long) <- c("position", "List.ID", "Answer")

answer_long$List.ID <- gsub(pattern = "List",
                            replacement = "",
                            x = answer_long$List.ID)

DF_long$response <- tolower(DF_long$response)
answer_long$Answer <- tolower(answer_long$Answer)
answer_long$Answer <- gsub(" ", "", answer_long$Answer)

scored_output <- prop_correct_multiple(data = DF_long,
                                    responses = "response",
                                    key = answer_long$Answer,
                                    key.trial = answer_long$List.ID,
                                    id = "Sub.ID",
                                    id.trial = "List.Number",
                                    cutoff = 1,
                                    flag = TRUE)

head(scored_output$DF_Scored)
#>    Responses position Sub.ID List.Number     Answer Scored
#> 1      basil        8      5           1      basil      1
#> 2      basil        7      3           1      basil      1
#> 3  bayleaves        7      1           1  bayleaves      1
#> 4  bayleaves        8      3           1  bayleaves      1
#> 5  bayleaves        3      5           1  bayleaves      1
#> 6 celeryseed        1      5           1 celeryseed      1

head(scored_output$DF_Participant)
#>   Sub.ID Proportion.Correct List.Number Z.Score.Participant
#> 1      1               0.30           1          -1.1547005
#> 2      3               0.45           1           0.5773503
#> 3      5               0.45           1           0.5773503
#> 4      1               0.45           2          -0.5773503
#> 5      3               0.45           2          -0.5773503
#> 6      5               0.55           2           1.1547005


serial_output <- serial_position_multiple(data = scored_output$DF_Scored,
                                         position = "position",
                                         answer = "Answer",
                                         key = answer_long$Answer,
                                         key.trial = answer_long$List.ID,
                                         scored = "Scored",
                                         id.trial = "List.Number")

 head(serial_output)
#>   Tested.Position Freq Proportion.Correct        SE List.ID
#> 1               1    0          0.0000000 0.0000000       1
#> 2               3    0          0.0000000 0.0000000       1
#> 3               4    0          0.0000000 0.0000000       1
#> 4               5    1          0.3333333 0.2721655       1
#> 5               7    1          0.3333333 0.2721655       1
#> 6               8    0          0.0000000 0.0000000       1