getPhase2Optimal: Determine if the neutral image is preferred to negative...

Description Usage Arguments Value Examples

View source: R/examineChoices.R

Description

This function takes in the data frame that contains the subject choice and rating data as well as a TRUE/FALSE value signifying whether the subject prefers the neutral gray image over the negative reinforcers as measured by the average rating of the negative reinforcers showed and the rating for the neutral image. It then mutates the data frame with an optimal column based on their preference. Specifically, if an individual does prefer gray, then the optimal choice is to choose icons that have the lowest probability of getting a reinforcer. If they don't prefer gray, then the optimal choice is to choose icons that have the highest probability of getting a reinforcer.

Usage

1
getPhase2Optimal(df, posValue, negValue, ID)

Arguments

df

The data frame that contains the subject choice and rating data (see examples).

posValue

Logical: TRUE or FALSE signifying whether or not an individual prefers the neutral gray image to positive reinforcers.

negValue

Logical: TRUE or FALSE signifying whether or not an individual prefers the neutral gray image to negative reinforcers.

ID

Character: Subject ID for whom we are determining preference.

Value

A data frame consisting of the phase 2 information for the specified subject. It has, in addition to the choice and rating information for a subject, an optimal column based on the subject's preference for the neutral image relative to the reinforcers.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
choiced <- processChoiceData(sampleChoiceData) %>%
  dplyr::mutate(subject = "RJT", .before = phase)

rated <- processRatingsData(sampleRatingsData) %>%
  regSetup() %>%
  dplyr::mutate(subject = "RJT", .before = IAPS)

testDF <- dplyr::left_join(choiced, rated %>%
dplyr::rename(reinforcer = IAPS),
by = c("subject", "reinforcer")) %>%
 dplyr::filter(reinforcer != "7006") %>%
 dplyr::mutate(reinforcer =
 base::ifelse(reinforcer == "neutral", "neutral", "reinforcer"))

testValue <- testDF %>%
  dplyr::filter(phase == 1) %>%
  dplyr::group_by(subject, reinforcer) %>%
  dplyr::summarize(meanNeg = -mean(negative), .groups = "drop") %>%
  tidyr::pivot_wider(names_from = reinforcer, values_from = meanNeg) %>%
  dplyr::mutate(prefersGrayNegative = base::ifelse(neutral > reinforcer, TRUE, FALSE)) %>%
  dplyr::pull(prefersGrayNegative, subject) %>%
  base::as.list()

testID <- base::names(testValue)

#iapsr:::getPhase2Optimal(testDF, testValue[[1]], testID)

jdtrat/iapsr documentation built on Oct. 2, 2021, 12:36 a.m.