trinker / wakefield

Generate random data sets
256 stars 28 forks source link

Retain the likert scale when using r_series #24

Open danawanzer opened 4 years ago

danawanzer commented 4 years ago

When performing r_series(likert, 5, 100, name ="Item", relate = "-.5_.1") (as in the readme file), it does not retain the original likert range. For example, running the code above results in the following ranges for the five items:

  1. Item_1: 1-5
  2. Item_2: 0-5
  3. Item_3: -1-5
  4. Item_4: -2-5
  5. Item_5: -3-4

I would like to be able to create likert scales with the same response scales (e.g., 1 through 5) that are related to one another (e.g., alpha = .80). The current code creates scales that are related but no longer on the same response scale.

danawanzer commented 4 years ago

As a follow-up, I figured out a solution in the meantime using rescale in the scales package:

r_data_frame(
  n = 300,
  id,
  race, 
  education,
  level,
  `age` = rpois(lambda = 3), #Need to add 17 to this value
  r_series(likert, 5, name = "SWLS", relate = "-.5_.1")
) %>%
  mutate_at(vars(starts_with("SWLS")), rescale, to = c(1, 5))

This rescales the variables back to the original response scales but preserving the relationship between the items (e.g., alpha = .97).