Skip to content

vyqlua/avi_functions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 

Repository files navigation

avi_functions

Functions for calculating and plotting AVI variables easily. These are some intended future updates (i.e., currently, the functions are unable to...):

  • Modify ipsatize_avi() function to calculate a composite score combining all 3 arousal levels
  • Modify ipsatize_avi() function to calculate cronbach alphas
  • Modify plot_avi() function to be more modifiable (e.g., color scheme, plot avoided affect, etc.)

to use:

To import these functions in R, use source("https://raw.githubusercontent.com/vyqlua/avi_functions/refs/heads/main/ipsatize_fn.R").

  1. ipsatize_avi(data, item_stem, full_avi = FALSE, remove = NULL, maximizing_pos = FALSE)

This is a function for ipsatizing AVI items and calculating composite AVI scores.

All AVI items should start with the same starting string (e.g., "i." for ideal affect AVI items), and the items should contain the names of the emotion (or shortened 4-letter versions of the names. for sad, it can be labelled as sad or sadx). The different AVI composite scores are calculated as follows:

  • HAP = enth | exci | elat | euph

  • LAP = rela | calm | peac | sere

  • HAN = fear | host | nerv | angr

  • LAN = dull | slee | slug

  • POS = happ | cont | sati

  • NEG = unha | sad | lone

Note that functions do not automatically calculate POS and NEG. Add argument full_avi = TRUE if you want to calculate those two variables as well. If you'd like to remove any items (e.g., euphoric) from the computation of the composite score(s), specify remove = "euphoric". The remove argument can also be a vector (e.g., c("euphoric","elated")), and the function does a dplyr::select(contains()) search on the specified string/ vector. Add argument maximizing_pos = TRUE to calculate maximizing positivity (ideal HAP, POS, and NEG minus ideal HAN, NEG, and LAN).

  1. plot_avi(data, group_id, full_avi = FALSE, flip_color = FALSE, ipsatized_only = TRUE)

This is a function for plotting composite AVI scores and getting descriptives for AVI scores.

If the plot comes out and the colors are flipped, indicate flip_color = TRUE. If you want to plot the raw scores as well, indicate ipsatized_only = FALSE. If you want to plot POS and NEG as well, indicate full_avi = TRUE.


log of changes/ updates:

22 Sep 2024: Uploaded first version of functions

23 Sep 2024: Modified ipsatize_avi() function to allow for removing specific items in composite score (since euphoric is often removed to improve internal reliability of HAP composite scores)

25 Sep 2025: Updated function to be able to calculate maximizing positivity.

27 Jan 2026: Made the codebook that's printed mapping successfully computed AVI variables to the items used in the computation much much prettier and less annoying to read when printed.

10 Mar 2026: Saved codebook to environment instead of printing it out.

11 Mar 2026: Changed tail of ipsatized variables to _i instead of _ip

About

Functions for calculating and plotting Affect Valuation Index (AVI; Tsai et al., 2007) variables easily

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages