Skip to contents

Set up

First, create an “InteRactModel” R6 object.

act <- interact(dictionary = "usfullsurveyor2015", equations = "us2010")
#>  dictionary = list(dataset = "usfullsurveyor2015", group = "all")
#>  equations = list(key = "us2010", group = "all")
act
#> 
#> ── Interact Analysis ───────────────────────────────────────────────────────────
#>  Dictionary: usfullsurveyor2015 (group: all)
#>  Equations: us2010
#>   impressionabo (group: all)

Dictionary

act$dictionary
#> # A tibble: 2,403 × 5
#>    term          component ratings   n         sd       
#>    <chr>         <chr>     <list>    <list>    <list>   
#>  1 abandon       behavior  <dbl [3]> <dbl [3]> <dbl [3]>
#>  2 abandoned     modifier  <dbl [3]> <dbl [3]> <dbl [3]>
#>  3 abduct        behavior  <dbl [3]> <dbl [3]> <dbl [3]>
#>  4 abet          behavior  <dbl [3]> <dbl [3]> <dbl [3]>
#>  5 abhor         behavior  <dbl [3]> <dbl [3]> <dbl [3]>
#>  6 able_bodied   modifier  <dbl [3]> <dbl [3]> <dbl [3]>
#>  7 abort         behavior  <dbl [3]> <dbl [3]> <dbl [3]>
#>  8 abortionist   identity  <dbl [3]> <dbl [3]> <dbl [3]>
#>  9 absent_minded modifier  <dbl [3]> <dbl [3]> <dbl [3]>
#> 10 abuse         behavior  <dbl [3]> <dbl [3]> <dbl [3]>
#> # ℹ 2,393 more rows

Equations

act$equations
#>               Ae'   Ap'   Aa'   Be'   Bp'   Ba'   Oe'   Op'   Oa'
#> (Intercept) -0.16 -0.06 -0.05 -0.26  0.09  0.21 -0.18  0.00 -0.14
#> Ae           0.62  0.00  0.00  0.52  0.00  0.00  0.00  0.00  0.00
#> Ap           0.00  0.57  0.00  0.00  0.53  0.00  0.00  0.00  0.00
#> Aa           0.00  0.00  0.26  0.00  0.00  0.15  0.00  0.00  0.00
#> Be           0.46 -0.29 -0.18  0.50 -0.21 -0.12  0.26  0.51  0.33
#> Bp           0.00  0.62  0.12  0.00  0.64  0.00  0.00 -0.57 -0.41
#> Ba           0.00  0.00  0.86  0.00  0.00  0.91  0.00  0.00  0.31
#> Oe           0.00  0.00  0.00  0.00  0.00  0.00  0.91  0.00  0.00
#> Op           0.00 -0.20  0.00  0.00  0.00  0.00  0.00  0.47  0.00
#> Oa           0.00  0.00  0.00  0.00  0.00  0.09  0.00  0.00  0.54
#> Ae:Be        0.00  0.00  0.00  0.00  0.00  0.00  0.16  0.00  0.54
#> Be:Oe        0.29  0.00  0.00  0.32  0.00  0.00  0.11  0.00  0.00
#> Bp:Oe       -0.22  0.00  0.00 -0.27  0.00  0.00 -0.15  0.00  0.00
#> Be:Oa       -0.09  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00
#> Aa:Ba:Oe     0.00  0.00  0.00  0.00  0.00  0.00  0.00 -0.10  0.00

interact() uses group = all by default for both equations and dictionaries. If this option does not exist in the actdata package, then you will see an error.

interact(dictionary = "indiana2003", equations = "nc1978")
#>  dictionary = list(dataset = "indiana2003", group = "all")
#>  equations = list(key = "nc1978", group = "all")
#> ! equations groups: male and female
#> Error:
#> ! `all` not found in `nc1978` equations in `actdata` package

You can change the defaults by specifying a second element in either argument.

For example:

interact(dictionary = "indiana2003", equations = list("nc1978", "male"))
#>  dictionary = list(dataset = "indiana2003", group = "all")
#> 
#> ── Interact Analysis ───────────────────────────────────────────────────────────
#>  Dictionary: indiana2003 (group: all)
#>  Equations: nc1978
#>   impressionabo (group: male)

InteRactModel objects come with built in methods which you can access via the $ operator.

act$fundamentals("deadbeat")
#> # Source:  ()
#> # A data frame: 1 × 5
#>   term     component     e     p     a
#> * <chr>    <chr>     <dbl> <dbl> <dbl>
#> 1 deadbeat identity   -2.8 -2.57 -1.45

Note. This is just a simple function that looks inside act$dictionary.

Deflection

d <- act$deflection(data.frame(A = "god", B = "kill", O = "deadbeat"))
d
#> # Event deflection
#> # A data frame: 1 × 4
#>   A     B     O        deflection
#> * <chr> <chr> <chr>         <dbl>
#> 1 god   kill  deadbeat       173.

You can also extract useful metadata from these scores.

get_fundamentals(d)
#> # A tibble: 1 × 9
#>      Ae    Ap    Aa    Be    Bp    Ba    Oe    Op    Oa
#>   <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1  3.19  3.45 -0.46 -4.26  1.95 -0.11  -2.8 -2.57 -1.45
get_transients(d)
#> # A tibble: 1 × 9
#>      Ae    Ap    Aa    Be    Bp    Ba    Oe    Op    Oa
#>   <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1  3.96  4.86 0.737  4.56  4.06 0.422 -3.88 -4.48 -10.5
get_element_wise_deflection(d)
#> # A tibble: 1 × 9
#>      Ae    Ap    Aa    Be    Bp    Ba    Oe    Op    Oa
#>   <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 0.597  2.00  1.43  77.8  4.46 0.283  1.16  3.64  81.9

Behaviors and Reidentification

Optimal behaviors and/or reidentification uses the deflection scores estimated by $deflection() and stored in d. They require you specify the perspective of the one doing the behaving or the reidentifying.

Behaviors

act$optimal_behavior(d, who = "actor")
#> # A tibble: 1 × 3
#>      Be    Bp     Ba
#>   <dbl> <dbl>  <dbl>
#> 1  1.90  1.18 -0.637
act$optimal_behavior(d, who = "object")
#> # A tibble: 1 × 3
#>      Be     Bp    Ba
#>   <dbl>  <dbl> <dbl>
#> 1 0.111 -0.525 0.233

Reidentification

act$reidentify(d, who = "actor")
#> # A tibble: 1 × 3
#>       Ae    Ap    Aa
#>    <dbl> <dbl> <dbl>
#> 1 -0.999  2.35 0.848
act$reidentify(d, who = "object")
#> # A tibble: 1 × 3
#>      Oe    Op    Oa
#>   <dbl> <dbl> <dbl>
#> 1 -1.26 -4.85 -11.1

Closest Terms

act$closest_terms(list(e = 1, p = 0, a = -1), component = "behavior", max_dist = 0.5)
#>        obey      bow_to      nuzzle comply_with  curtsey_to     gaze_at 
#>      0.0581      0.1419      0.2141      0.2822      0.2948      0.4301 
#>      stroke 
#>      0.4806

deadbeat <- act$fundamentals("deadbeat")
deadbeat
#> # Source:  ()
#> # A data frame: 1 × 5
#>   term     component     e     p     a
#> * <chr>    <chr>     <dbl> <dbl> <dbl>
#> 1 deadbeat identity   -2.8 -2.57 -1.45

act$closest_terms(deadbeat, component = "modifier", max_dist = 0.5)
#>  uneducated incompetent    helpless    cowardly        poor  unemployed 
#>      0.1581      0.2489      0.3126      0.3507      0.3901      0.4555

Deference Score

You can also create the deference scores discussed by Freeland & Hoey (2018).

But this requires to modify the existing dictionary so we get the right combination of identities and behaviors.

This seems to be the easiest way to do this:

act <- interact()
#>  dictionary = list(dataset = "usfullsurveyor2015", group = "all")
#>  equations = list(key = "us2010", group = "all")

defer_to <- act$dictionary |> ## save for later use
  dplyr::filter(term == "defer_to")

occ <- interact(dictionary = "occs2019")
#>  equations = list(key = "us2010", group = "all")
#>  dictionary = list(dataset = "occs2019", group = "all")
occ$dictionary
#> # A tibble: 650 × 5
#>    term                             component ratings   n         sd       
#>    <chr>                            <chr>     <list>    <list>    <list>   
#>  1 911_dispatcher                   identity  <dbl [3]> <dbl [3]> <dbl [3]>
#>  2 accountant                       identity  <dbl [3]> <dbl [3]> <dbl [3]>
#>  3 actor                            identity  <dbl [3]> <dbl [3]> <dbl [3]>
#>  4 actress                          identity  <dbl [3]> <dbl [3]> <dbl [3]>
#>  5 actuary_for_an_insurance_company identity  <dbl [3]> <dbl [3]> <dbl [3]>
#>  6 acupuncturist                    identity  <dbl [3]> <dbl [3]> <dbl [3]>
#>  7 administrative_assistant         identity  <dbl [3]> <dbl [3]> <dbl [3]>
#>  8 advertising_executive            identity  <dbl [3]> <dbl [3]> <dbl [3]>
#>  9 advertising_salesman             identity  <dbl [3]> <dbl [3]> <dbl [3]>
#> 10 aerobics_instructor              identity  <dbl [3]> <dbl [3]> <dbl [3]>
#> # ℹ 640 more rows

occupations <- occ$dictionary$term ## save for later use

## replace original dictionary
occ$dictionary <- dplyr::bind_rows(defer_to, occ$dictionary)
#>  added new dictionary

Note that a message appeared signaling that the replacement was successful.

occ 
#> 
#> ── Interact Analysis ───────────────────────────────────────────────────────────
#>  Dictionary: External [!] (group: ?)
#>  Equations: us2010
#>   impressionabo (group: all)

Now you just create another grid of events, calculate the deflection scores, and average over the As.

events <- tidyr::crossing(
  A = occupations,
  B = "defer_to",
  O = occupations
)

output <- occ$deflection(events)

output |> 
  filter(A != O) |> 
  group_by(A) |> 
  summarize(avg = mean(deflection)) |> 
  arrange(desc(avg)) 
#> # A tibble: 650 × 2
#>    A                            avg
#>    <chr>                      <dbl>
#>  1 firefighter                 16.6
#>  2 fireman                     15.0
#>  3 paramedic                   13.9
#>  4 professional_athlete        12.4
#>  5 fire_department_lieutenant  12.3
#>  6 ambulance_driver            11.4
#>  7 auctioneer                  11.1
#>  8 dynamite_blaster            10.9
#>  9 911_dispatcher              10.9
#> 10 surgeon                     10.6
#> # ℹ 640 more rows

Experimental

The things here are still experimental. The API may change a lot.

Modify Identity

You can create modified identities by combining them with modifier terms in the ACT dictionaries. These use the traitid equations in the actdata package.

The $modify_identity method does not work unless you first specify the traitid equation.

act$modify_identity(list(M = "angry", I = "doctor"))
#> Error in `act$modify_identity()`:
#> ! must first set up `traitid` equation with the `$add_equation` method

In order to do this you must use the $add_equation() method.

act$add_equation(type = "traitid", group = "all")
#>  traitid = list(key = "us2010", group = "all")
act$modify_identity(list(M = "angry", I = "doctor")) 
#> # A tibble: 1 × 3
#>   term          component ratings  
#>   <chr>         <chr>     <list>   
#> 1 angry__doctor identity  <dbl [3]>

act$fundamentals("academic")
#> # Source:  ()
#> # A data frame: 1 × 5
#>   term     component     e     p     a
#> * <chr>    <chr>     <dbl> <dbl> <dbl>
#> 1 academic identity   2.34  2.26 -0.12

grid <- data.frame(
  M = c("tired", "taciturn", "angry", "happy"), 
  I = c("academic", "academic", "academic", "academic")
)

out <- act$modify_identity(grid) 
out |> tidyr::unnest_wider(ratings)
#> # A tibble: 4 × 5
#>   term               component      e     p      a
#>   <chr>              <chr>      <dbl> <dbl>  <dbl>
#> 1 tired__academic    identity  -0.233 0.548 -1.53 
#> 2 taciturn__academic identity   0.694 0.931 -0.834
#> 3 angry__academic    identity  -1.11  1.83   0.786
#> 4 happy__academic    identity   3.10  2.42   0.276

Characteristic Emotion

act$add_equation("emotionid", "male")
#>  emotionid = list(key = "us2010", group = "male")
act$characteristic_emotion(list(I = "brute"))
#> # A tibble: 1 × 3
#>      Me    Mp    Ma
#>   <dbl> <dbl> <dbl>
#> 1 -1.40  3.05  1.46

grid <- act$dictionary |> 
  dplyr::filter(component == "identity") |> 
  dplyr::sample_n(size = 10) |> 
  dplyr::select(I = term)

glimpse(grid)
#> Rows: 10
#> Columns: 1
#> $ I <chr> "censor", "grandson", "infant", "australian", "job_seeker", "truck_d…

act$characteristic_emotion(grid)
#> # A tibble: 10 × 3
#>        Me      Mp    Ma
#>     <dbl>   <dbl> <dbl>
#>  1  1.82   0.759  0.945
#>  2 -0.289  2.62   0.230
#>  3  1.81   2.11   0.377
#>  4  2.43   0.692  1.42 
#>  5 -4.82  -0.686  0.599
#>  6  2.43  -2.71   1.26 
#>  7  2.05  -0.0783 0.893
#>  8  2.49   3.90   0.527
#>  9  1.56   1.10   0.883
#> 10  1.66  -0.279  0.347