Skip to contents

ar_project generates a 2D projection of the target embedding.

Usage

ar_project_embedding(associations, method = "umap", n_dim = 2, ...)

Arguments

associations

an associatoR object including targets.

method

a character specifying the type of projection. One of c("pca", "mds", "umap"). Default is "umap".

n_dim

an integer specifying the number of projection dimensions. Default is 2.

...

additional parguments passed to the projection method.

Value

The function returns the associatoR object with the target_embeddings overwritten by the projected embeddings.

References

Aeschbach, S., Mata, R., Wulff, D. U. (2024). associatoR. psyArXiv

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_embed_targets() %>%
  ar_project_embedding()
#> 456 targets with count < min_count were dropped from embedding.
#> 
#> ── 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 × 1
#>   target      
#>   <chr>       
#> 1 intelligence
#> 2 Einstein    
#> 3 books       
#> 4 IQ tests    
#> 5 college     
#> # ℹ 799 more rows
#> 
#> target_embedding
#> # A tibble: 348 × 3
#>   target        dim_1   dim_2
#>   <chr>         <dbl>   <dbl>
#> 1 intelligence -1.05  -0.327 
#> 2 Einstein      0.293 -0.555 
#> 3 books         0.926  0.0493
#> 4 IQ tests     -2.35   0.0617
#> 5 college       1.89  -0.580 
#> # ℹ 343 more rows
#>