combined_response: Calculates the combined response variable given the available...

Description Usage Arguments Details Value Examples

View source: R/combined_response.R

Description

combined_response calculates combined responses given the information about the stimulus, ratings, and accuracy or decision.

Usage

1
combined_response(stimulus, rating = NULL, accuracy = NULL, decision = NULL)

Arguments

stimulus

a vector encoding the stimulus class. This can be of any type as long as it contains only two kinds of values, which will be converted to 1 and 2 if necessary.

rating

a vector of ratings. Ratings have to be encoded as intergers and all the possible values between min(rating) and max(rating) have to be present in the data. Either ratings or accuracy has to be provided. When ratings are not provided the resulting combined response is just the binary classification response calculated based on the provided accuracy and stimulus information.

accuracy

an optional numeric vector: 1 = a correct, 0 = an incorrect binary classification response. Either accuracy or decision has to be provided.

decision

an optional numeric vector: i = participant decided that the stimulus belongs to class 1, j = participant decided that the stimulus belongs to class 2, where j > i. Either accuracy or decision has to be provided.

Details

This function calculates the variable distribution of which is modelled by Signal Detection Theory. If ratings are not provided this becomes a simple binary classification decision: 1 (2) = participant decided that the stimulus belongs to class 1 (2). If ratings are provided the resulting variable indicates how strongly does the participant feel that the stimulus belongs to the second class. For example, if ratings represent confidence on a 1-4 scale and participant decided that stimulus = 1 with maximum confidence then response = 1, if participant decided that stimulus = 1 with confidence 1 then response = 4, if participant decided that stimulus = 2 with confidence 1 then response = 5, if participant decided that stimulus = 2 with confidence = 4 then response = 8.

Value

a vector of combined or binary response values.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
data(gabor)
## Using this function we can obtain binary classification decisions from stimulus and accuracy data
gabor$dec = combined_response(gabor$stim, accuracy = gabor$acc)
## ... or we can obtain combined response values
gabor$resp = combined_response(gabor$stim, gabor$rating, gabor$acc)
aggregate(resp ~ rating + dec, gabor, unique)
## This is false, because gabor$stim encodes stimulus classess as 0 or 1 and dec encodes the decision as 1 or 2
all(gabor$acc == (gabor$stim == gabor$dec))
## but this is true so we're fine
all(gabor$acc == ((gabor$stim+1) == gabor$dec))

boryspaulewicz/bhsdtr documentation built on March 8, 2020, 8:24 a.m.