Skip to contents

ar_correlate_targets calculates the correlations between the response occurrence of targets and participant variables, such as gender or age.

Usage

ar_correlate_targets(associations, participant_vars, metric = "auto")

Arguments

associations

an associatoR object containing association data as generated by ar_import.

participant_vars

a character vector specifying the participant variables to assess. The variables must exist in associations$participants.

metric

a character scalar of c("auto", "point-biserial", "phi", "cramer") specifying the metric to calculate for the correlation of participant_vars and targets. Defaults to "auto".

Value

Returns an associatoR object containing a list of tibbles, with targets gaining correlation column(s):

participants

A tibble of participants including a participant id and potential participant attributes.

cues

A tibble of cues including a cue variable and potential cue attributes.

responses

A tibble of responses including a participant id, the cues, the responses, the response level, and additional response attributes.

targets

A tibble of targets including the specified analysis target, and correlation column(s).

Details

Function calculates the point-biserial correlation for numeric and Cramer's V for categorical participant_vars.

Examples

ar_import(intelligence,
          participant = participant_id,
          cue = cue,
          response = response,
          participant_vars = c(gender, education),
          response_vars = c(response_position, response_level)) %>%
  ar_set_targets(targets = "cues") %>%
  ar_correlate_targets(participant_vars = c(education, gender))
#> Joining with `by = join_by(target)`
#> 
#> ── An associatoR object ────────────────────────────────────────────────────────
#> 
#> participants
#> # A tibble: 1,000 × 3
#>      id gender education  
#>   <dbl> <chr>  <chr>      
#> 1     1 male   high school
#> 2     2 male   high school
#> 3     3 male   high school
#> 4     4 male   high school
#> 5     5 male   high school
#> # ℹ 995 more rows
#> 
#> cues
#> # A tibble: 804 × 1
#>   cue         
#>   <chr>       
#> 1 intelligence
#> 2 Einstein    
#> 3 books       
#> 4 IQ tests    
#> 5 college     
#> # ℹ 799 more rows
#> 
#> responses
#> # A tibble: 29,882 × 5
#>      id cue          response     response_position response_level
#>   <dbl> <chr>        <chr>                    <dbl>          <dbl>
#> 1     1 intelligence Einstein                     1              1
#> 2     1 intelligence books                        2              1
#> 3     1 intelligence IQ tests                     3              1
#> 4     1 intelligence college                      4              1
#> 5     1 intelligence smart people                 5              1
#> # ℹ 29,877 more rows
#> 
#> targets
#> # A tibble: 804 × 3
#>   target       education_corr gender_corr
#>   <chr>                 <dbl>       <dbl>
#> 1 intelligence        -0.0417    -0.0139 
#> 2 Einstein            -0.0950     0.102  
#> 3 books               -0.0959     0.0511 
#> 4 IQ tests             0.0446     0.0446 
#> 5 college             -0.206      0.00936
#> # ℹ 799 more rows
#>