Short version:
Given I have a list of 120 traits (happy, sad, etc.) evaluated on a number of scales ranging from -5 (for example highly negative) to +5 (for example highly positive), how can I group these traits into 6 sets of 20 items each, so that each set has a similar mean and variance of those scales?
A word of explanation: The 120 traits will be judged on whether or not they describe one of 6 social objects (20 traits per object) (using a 1-5 scale). Traits I will be using come from a bigger set (of 300 unique items) where each has been evaluated on measures like: valence, agency, communion and a couple of others.
I'd like to make sure that each social object was judged on traits that overall had a similar mean and (possibly) standard deviation, so that I don't end up, with one object that had very extreme traits (highly negative and highly positive) while others where somewhere in the middle.
R data example:
This is a minimal data example.
Note that in my real data, measures (valence etc) are not necessarily normally distributed and most likely correlated with other measures.
I did some reading and found out my problem might be partitioning related.
Here is a R
code I made up that does (more or less) what I'd like, but only based on one variable (let's pretented x are ratings of valence).
library(tidyverse)
set.seed(1)
x<- rnorm(120) # normal distribution is just an example
x<- sort(x)
g1<- rep(1:6, 20) # grouping strategy 1
g2<- rep(c(1:6, 6:1), 10) # grouping strategy 2
df<- tibble(x, g1, g2)
df %>%
group_by(g1) %>%
summarise(mean = mean(x), var = var(x))
df %>%
group_by(g2) %>%
summarise(mean = mean(x), var = var(x))
With the above code I can see that strategy #2 yields better results, as means of groups are more similar than with strategy #1. q
# A tibble: 6 x 3
g1 mean var
<int> <dbl> <dbl>
1 1 0.01216328 0.8462127
2 2 0.05113158 0.8146632
3 3 0.08567107 0.7907553
4 4 0.13632257 0.7679591
5 5 0.16613787 0.7915441
6 6 0.20683895 0.8273733
# A tibble: 6 x 3
g2 mean var
<int> <dbl> <dbl>
1 1 0.1078368 0.9842131
2 2 0.1094842 0.8930841
3 3 0.1104103 0.8232504
4 4 0.1115834 0.7368137
5 5 0.1077852 0.7200830
6 6 0.1111654 0.7093138
What I can't figure out is how to work with a couple of ranking variables (above example had only x
).
In other words, what would be the best strategy to find the best possible grouping solution for a dataframe like this:
data<- data.frame(
trait_number = seq(1:120),
valence_rating = rnorm(120, mean = 0, sd = 3),
agency_rating = rnorm(120, mean = 0, sd = 3),
communion_rating = rnorm(120, mean = 0, sd = 3),
grouping = NA)
(note: once again rnorm is just an example for sample data. My real data is not normally distributed)
If I can explain anything more, please let me know in comments. Thank you.
for a dataframe like this:
, and then follows some code, not the data. It is a very bad practice to not show data, only to show uncommented code, R in this instance, - because some people may be not R users. $\endgroup$