1. Data Preparation
Data Import
Raw Data
We start by importing the data from the original sav file exported from Qualtrics.
Code
# Create mapping table with variable names and labels
mapping_df <- data.frame(
label = sapply(dt_raw_jih, function(x) attr(x, "label")),
stringsAsFactors = FALSE
)
# Clean the label: remove everything before and including the first colon
mapping_df$label <- str_remove(mapping_df$label, "^.*?:\\s*")
# Extract the item names from rownames
mapping_df$item <- rownames(mapping_df)
# Add number prefix to description if item ends with _<number>
mapping_df <- mapping_df %>%
mutate(
label = ifelse(
str_detect(item, "_(\\d+)$"),
paste0(str_extract(item, "\\d+$"), ". ", label),
label
)
)
# Display table
mapping_df %>%
select(item, label) %>%
kable(
col.names = c("item", "description"),
row.names = FALSE,
caption = "Scale items and their description. We use them to harmonize the Jihadist dataset with the base dataset if possible."
) %>%
kable_styling(
full_width = FALSE,
latex_options = c("hold_position", "scale-down")
) %>%
scroll_box(width = "100%", height = "600px")| item | description |
|---|---|
| survey_date | Survey date |
| NIS | NIS |
| Group | Group |
| Participant_control | Participant - Control - Non-radicalized control |
| Gender | Gender |
| JCL_COGNITIVE_RESTRUCTURATION | Cognitive_Restructuration_1 + Cognitive_Restructuration_2 |
| JCL_NEGATIVE_IMPACT | Cognitive_Restructuration_3 + Cognitive_Restructuration_4 |
| JCL_VICTIM | Cognitive_Restructuration_5 + Cognitive_Restructuration_6 |
| JCL_ASSUMING_WORST | Cognitive_Restructuration_7 + Cognitive_Restructuration_8 |
| JCL_FUSION | Fusion_Religion_Present_Dic |
| JCL_INGROUP_SUPERIORITY | Superiority_3 + Superiority_4. |
| JCL_PERCEIVED_DISCRIMINATION | Discrimination_1 + Discrimination_3 |
| JCL_ANGER_REACTION | Anger_1 + Anger_2 |
| JCL_ANGER_TEMPERAMENT | Anger_1 + Anger_2 |
| JCL_GROUP_RELATED_DEPRIVATION | Discrimination_7 |
| JCL_RADICAL_ATTITUDE | Radical_Attitudes_1 + Radical_Attitudes_2 |
| JCL_OBSESSIVE_PASSION | Passion_1 + Passion_2 |
| JCL_HARMONIOUS_PASSION | Passion_3 + Passion_4 |
| JCL_IDEOLOGICAL_COMMITMENT | Superiority_1 + Superiority_2 |
| JCL_RADICAL_INTENTIONS | Radical_Attitudes_3 + Radical_Attitudes_4 |
| JCL_PEACEFUL_INTENTIONS | Peaceful_Intentions_1 + Peaceful_Intentions_2 |
| JCL_POSITIVE_EMOTIONS | Affection_7 + Affection_10 |
| JCL_NEGATIVE_EMOTIONS | Affection_9 + Affection_1 |
| JCL_PAST_ACTIVISM | Past_Activism_1 + Past_Activism_2 |
| Fusion_Respect_Dic | Fusion Respect No Yes |
| Fusion_Tolerance_Dic | Fusion Tolerance No Yes |
| Fusion_Equality_Dic | Fusion Equality No Yes |
| Fusion_Justice_Dic | Fusion Justice No Yes |
| Fusion_Freedom_Dic | Fusion Freedom No Yes |
| Self_Esteem_topic_1 | 1. Throughout my life I have had high self-esteem. |
| Self_Esteem_topic_2 | 2. Currently, I consider that I have high self-esteem. |
| Self_Esteem_topic_3 | 3. In the future, I consider that I will have high self-esteem. |
| Time_1 | 1. The past (before I went to prison) is vey important to me. |
| Time_2 | 2. The present is very important to me. |
| Time_3 | 3. The future, when I get out of prison, is very important to me. |
| Fusion_Family_Dic | Fusion Family No Yes |
| Fusion_Friends_Dic | Fusion Friends No Yes |
| Fusion_Therapist_Present_Dic | Fusion Therapist Present No Yes |
| Fusion_Therapist_Future_Dic | Fusion Therapist Future No Yes |
| Fusion_Prophet_Past_Dic | Fusion Prophet Past No Yes |
| Fusion_Prophet_Present_Dic | Fusion Prophet Present No Yes |
| Fusion_Prophet_Future_Dic | Fusion Prophet Future No Yes |
| Fusion_Muslims_Past_Dic | Fusion Muslims Past No Yes |
| Fusion_Muslims_Present_Dic | Fusion Muslims Present No Yes |
| Fusion_Muslims_Future_Dic | Fusion Muslims Future No Yes |
| Fusion_Religion_Past_Dic | Fusion Religion Past No Yes |
| Fusion_Religion_Present_Dic | Fusion Religion Present No Yes |
| Fusion_Religion_Future_Dic | Fusion Religion Future No Yes |
| Fusion_Officials_Present_Dic | Fusion Officials Present No Yes |
| Fusion_Officials_Future_Dic | Fusion Officials Future No Yes |
| Fusion_Islamists_Past_Dic | Fusion Islamists Past No Yes |
| Fusion_Islamists_Present_Dic | Fusion Islamists Present No Yes |
| Fusion_Islamists_Future_Dic | Fusion Islamists Future No Yes |
| Discrimination_1 | 1. I am personally a victim of discrimination because I belong to the Muslim community. |
| Discrimination_2 | 2. I consider myself to be a person who has been deprived of opportunities because I belong to the Muslim community. |
| Discrimination_3 | 3. I feel that I am a victim of society because I belong to the Muslim community. |
| Discrimination_4 | 4. Our existence as a group and as individuals is under constant threat. |
| Discrimination_5 | 5. Many people hate us. |
| Discrimination_6 | 6. The suffering we have endured cannot be compared to that of any other group. |
| Discrimination_7 | 7. I think Muslims are disadvantaged because others oppress them. |
| Self_acceptance_1_1 | 1. When I review my life history I am happy with how things have turned out. |
| Self_acceptance_1_2 | 2. I often feel lonely because I have few close friends with whom to share my concerns. |
| Self_acceptance_1_3 | 3. I am afraid to express my opinions. |
| Self_acceptance_1_4 | 4. I am concerned about how other people evaluate the choices I have made in my life. |
| Self_acceptance_1_5 | 5. In general, I feel confident and positive about myself. |
| Self_acceptance_1_6 | 6. I have a lot of people who want to listen to me when I need to talk. |
| Self_acceptance_1_7 | 7. I tend to worry about what other people think of me |
| Self_acceptance_2_1 | 1. I feel that my friendships bring me many things. |
| Self_acceptance_2_2 | 2. I tend to be influenced by people with strong convictions. |
| Self_acceptance_2_3 | 3. I like most aspects of my personality. |
| Self_acceptance_2_4 | 4. I am confident in my opinions even if they are contrary to the general consensus. |
| Self_acceptance_2_5 | 5. I have experienced many close and trusting relationships. |
| Self_acceptance_2_6 | 6. It is difficult for me to express my own opinions on controversial issues. |
| Self_acceptance_2_7 | 7. For the most part, I am proud of who I am and the life I lead |
| Self_acceptance_2_8 | 8. I know I can trust my friends, and they know they can trust me. |
| Social_Integration_1 | 1. I feel that I am an important part of my community. |
| Social_Integration_2 | 2. I believe that people value me as a person. |
| Social_Integration_3 | 3. If I have something to say, I think most people would listen to me. |
| Social_Integration_4 | 4. I feel close to other people. |
| Loss_Self_Importance_1 | 1. Not valued. |
| Loss_Self_Importance_2 | 2. Insignificant. |
| Loss_Self_Importance_3 | 3. Embarrased. |
| Loss_Self_Importance_4 | 4. As if no one cared. |
| Loss_Self_Importance_5 | 5. Humiliated. |
| Loss_Self_Importance_6 | 6. Like a stranger. |
| Loss_Self_Importance_7 | 7. Nostalgic. |
| Quest_Significance_1 | 1. I would like to be more respected. |
| Quest_Significance_2 | 2. I want to be more valued by the people who are important to me. |
| Quest_Significance_3 | 3. I want to be more valued by society. |
| Quest_Significance_4 | 4. I would like others to be more proud of me. |
| Quest_Significance_5 | 5. I want to be more important. |
| Self_verification_1 | 1. The team of therapists treats me in a way that makes me feel understood. |
| Self_verification_2 | 2. The team of therapists makes me feel that I can be myself. |
| Self_verification_3 | 3. The therapy team understands me |
| Self_verification_4 | 4. I feel a great sense of gratitude towards the team of therapists. |
| Self_verification_5 | 5. I feel very grateful to be doing the program. |
| Self_verification_6 | 6. I trust the team of therapists to do for me what I would do for them. |
| Self_verification_7 | 7. I have as much confidence in the team of therapists as I have in myself. |
| Self_verification_8 | 8. I have confidence that the program can help me. |
| Feelings_1 | 1. Prison conditions are adequate. |
| Feelings_2 | 2. I have suffered a lot in prison. |
| Feelings_3 | 3. Prison officials treat inmates with respect. |
| Feelings_4 | 4. Prison officials treat inmates with dignity. |
| Empathy_1 | 1. When someone feels excited, I also tend to feel excited with him/her, it is as if I feel the same (e.g., if someone is sad, I feel sad; if he/she is happy, I feel happy). |
| Empathy_2 | 2. I think I am "in tune" with other people's moods, that is, I can feel the way they feel. |
| Empathy_3 | 3. I get angry when someone cries. |
| Empathy_4 | 4. I feel a strong impulse to help a person when I see that he/she is unwell or upset. |
| Empathy_5 | 5. I think it is silly for people to cry out of happiness. |
| Empathy_6 | 6. I feel like helping and protecting a person when I see that he/she is being taken advantage of or wants to be taken advantage of. |
| Resilience_1 | 1. I know how to adapt to changes. |
| Resilience_2 | 2. After a serious setback, I usually "get back on track." |
| Resilience_3 | 3. I can maintain my concentration under pressure. |
| Resilience_4 | 4. I am hardly discouraged by failures. |
| Resilience_5 | 5. I can handle unpleasant feelings. |
| Emotion_Regulation_1 | 1. I pay attention to how I feel. |
| Emotion_Regulation_2 | 2. I have difficulty understanding my feelings. |
| Emotion_Regulation_3 | 3. I am attentive to my feelings. |
| Emotion_Regulation_4 | 4. I am confused about how I feel. |
| Emotion_Regulation_5 | 5. When I feel bad, I am embarrassed about feeling that way. |
| Emotion_Regulation_6 | 6. When I feel bad, I have difficulty getting work done. |
| Emotion_Regulation_7 | 7. When I feel bad, I lose control. |
| Emotion_Regulation_8 | 8. When I feel bad, I feel out of control. |
| Emotion_Regulation_9 | 9. When I feel bad, I feel ashamed of myself for feeling that way. |
| Emotion_Regulation_10 | 10. When I feel bad, I have difficulty concentrating. |
| Anger_1 | 1. I feel infuriated when I do a good job and receive a poor evaluation. |
| Anger_2 | 2. It makes me furious when I am criticized in front of others. |
| Anger_3 | 3. I am a hotheaded person. |
| Anger_4 | 4. I am quick-tempered. |
| Affection_1 | 1. Upset |
| Affection_2 | 2. Hostile |
| Affection_3 | 3. Alert |
| Affection_4 | 4. Embarrassed |
| Affection_5 | 5. Inspired |
| Affection_6 | 6. Nervous |
| Affection_7 | 7. Determined |
| Affection_8 | 8. Attentive |
| Affection_9 | 9. Afraid |
| Affection_10 | 10. Active |
| Coping_Strategy_1 | 1. I tend to blame myself for being too emotional about the situation. |
| Coping_Strategy_2 | 2. I try to be with other people. |
| Coping_Strategy_3 | 3. I tend to try to be organized to stay on top of the situation. |
| Coping_Strategy_4 | 4. I try to adjust my priorities. |
| Coping_Strategy_5 | 5. I tend to call a friend. |
| Coping_Strategy_6 | 6. I tend to decide on an action to take and carry it out. |
| Coping_Strategy_7 | 7. I tend to get very tense. |
| Coping_Strategy_8 | 8. I tend to talk to someone whose advice I value. |
| Coping_Strategy_9 | 9. I tend to blame myself for putting off making decisions. |
| Coping_Strategy_10 | 10. I tend to go see a friend. |
| Coping_Strategy_11 | 11. I tend to tell myself that this can't be happening to me. |
| Coping_Strategy_12 | 12. I tend to focus on the problem and see how to solve it. |
| Radical_Attitudes_1 | 1. Violence is necessary for social change. |
| Radical_Attitudes_2 | 2. Violence is an acceptable means to further a cause. |
| Radical_Attitudes_3 | 3. Muslims should perform risky or illegal actions to help the cause of Islam. |
| Radical_Attitudes_4 | 4. Muslims should use any means, even violent, to help the cause of Islam. |
| Past_Activism_1 | 1. Donated money to a political candidate who supports Islam? |
| Past_Activism_2 | 2. Donated money to an organization that supports Islam? |
| Violent_Radicalism_1 | 1. I would join or belong to an organization that fights for Muslim's political and legal rights, even if it sometimes goes beyond the law. |
| Violent_Radicalism_2 | 2. I would join or belong to an organization that fights for Muslim's political and legal rights, even if it sometimes uses violence. |
| Violent_Radicalism_3 | 3. I would participate in a protest against the oppression of Muslims, even if I thought the protest might turn violent. |
| Violent_Radicalism_4 | 4. I would attack the police or security forces if I saw them beating members of my group. |
| Superiority_1 | 1. My religious beliefs are important for me. |
| Superiority_2 | 2. My religious beliefs are a passion for me. |
| Superiority_3 | 3. I think everyone should be a Muslim. |
| Superiority_4 | 4. Islam is better than other religious beliefs. |
| Peaceful_Intentions_1 | 1. Raising public awareness about Islam. |
| Peaceful_Intentions_2 | 2. Organizing social activities to increase people's awareness about Islam. |
| Passion_1 | 1. My religious beliefs are so exciting that I sometimes lose control over them. |
| Passion_2 | 2. My religious beliefs are the only thing that captivates me. |
| Passion_3 | 3. My religious beliefs reflect the qualities I like about myself. |
| Passion_4 | 4. My religious beliefs are in harmony with other things that are part of me. |
| Cognitive_Restructuration_1 | 1. Sometimes it is okay to bully other people. |
| Cognitive_Restructuration_2 | 2. People sometimes need to be bashed. |
| Cognitive_Restructuration_3 | 3. Some people need to be picked on just to teach them a lesson. |
| Cognitive_Restructuration_4 | 4. Getting bullied helps to make people tougher. |
| Cognitive_Restructuration_5 | 5. Some people get bullied because they deserve it. |
| Cognitive_Restructuration_6 | 6. Most people who get bullied bring it on themselves. |
| Cognitive_Restructuration_7 | 7. You should hurt people first, before they hurt you. |
| Cognitive_Restructuration_8 | 8. It is ok to bad-mouth other people, they bad-mouth you too. |
| Quality_1 | 1. I have been focused during the interview. |
| Quality_2 | 2. I have been honest in my answers. |
| Quality_3 | 3. I think my answers may influence the time I spend in prison. |
| Sincerity_1 | 1. Sometimes I tell lies. |
| Sincerity_2 | 2. Sometimes I think things that are too bad to talk about. |
| Sincerity_3 | 3. Sometimes I say bad things about other people. |
| Education_Level | Education Level |
| Marital_Status | Marital Status |
| Children_Number | Children Number |
| Children_Relationship | Children Relationship |
| Parents_Relationship | Parents Relationship |
| Siblings_Number | Siblings Number |
| Siblings_Relationship | Siblings Relationship |
| Mental_Illness | Mental Illness |
| Medication_1 | 1. Medication 1 |
| Medication_2 | 2. Medication 2 |
| PAIEM | PAIEM |
| PPS | PPS |
| Sanctions | Sanctions |
| Sanctions_Number | Numero Sanciones |
| Furlough | Furlough |
| Furlough_Number | Furlough Number |
| Activities_1_choice_1 | 1. School |
| Activities_1_choice_2 | 2. Prison Labor |
| Activities_1_choice_3 | 3. Training courses |
| Activities_1_choice_4 | 4. Paid work |
| Activities_1_choice_5 | 5. Occupational workshop |
| Activities_1_choice_6 | 6. Gym/sports |
| Activities_1_choice_7 | 7. Reading |
| Activities_1_choice_8 | 8. Others |
| Activities_2 | 2. Activities 2 |
| Substance_Use_1_topic_1_option_1 | 1. alcohol - never |
| Substance_Use_1_topic_1_option_2 | 2. alcohol - once or twice |
| Substance_Use_1_topic_1_option_3 | 3. alcohol - often |
| Substance_Use_1_topic_1_option_4 | 4. alcohol - every day |
| Substance_Use_1_topic_2_option_1 | 1. marijuana - never |
| Substance_Use_1_topic_2_option_2 | 2. marijuana - once or twice |
| Substance_Use_1_topic_2_option_3 | 3. marijuana - often |
| Substance_Use_1_topic_2_option_4 | 4. marijuana - every day |
| Substance_Use_1_topic_3_option_1 | 1. cocaine - never |
| Substance_Use_1_topic_3_option_2 | 2. cocaine - once or twice |
| Substance_Use_1_topic_3_option_3 | 3. cocaine - often |
| Substance_Use_1_topic_3_option_4 | 4. cocaine - every day |
| Substance_Use_1_topic_4_option_1 | 1. heroin - never |
| Substance_Use_1_topic_4_option_2 | 2. heroin - once or twice |
| Substance_Use_1_topic_4_option_3 | 3. heroin - often |
| Substance_Use_1_topic_4_option_4 | 4. heroin - every day |
| Substance_Use_1_topic_5_option_1 | 1. tranquilizers or sleeping pills - never |
| Substance_Use_1_topic_5_option_2 | 2. tranquilizers or sleeping pills - once or twice |
| Substance_Use_1_topic_5_option_3 | 3. tranquilizers or sleeping pills - often |
| Substance_Use_1_topic_5_option_4 | 4. tranquilizers or sleeping pills - every day |
| Substance_Use_1_topic_6_option_1 | 1. amphetamines - never |
| Substance_Use_1_topic_6_option_2 | 2. amphetamines - once or twice |
| Substance_Use_1_topic_6_option_3 | 3. amphetamines - often |
| Substance_Use_1_topic_6_option_4 | 4. amphetamines - every day |
| Substance_Use_1_topic_7_option_1 | 1. designer drugs: ecstasy, MDA - never |
| Substance_Use_1_topic_7_option_2 | 2. designer drugs: ecstasy, MDA - once or twice |
| Substance_Use_1_topic_7_option_3 | 3. designer drugs: ecstasy, MDA - often |
| Substance_Use_1_topic_7_option_4 | 4. designer drugs: ecstasy, MDA - every day |
| Substance_Use_1_topic_8_option_1 | 1. others - never |
| Substance_Use_1_topic_8_option_2 | 2. others - once or twice |
| Substance_Use_1_topic_8_option_3 | 3. others - often |
| Substance_Use_1_topic_8_option_4 | 4. others - every day |
| Substance_Use_2 | 2. Substance Use 2 |
| Date_Born | Date of birth |
| Age | Age |
| Nationality | Nationality |
| Country_Origin | Country of origin |
| Offense | Offense |
| Number_Income | Income number |
| Last_Admission | Date of last entry |
| First_Admission | Date of first admission |
| Time_Permanence | Time of permanence in prison |
| Degree | Degree |
| Activities | Activities |
| Number_Furlough | Number of furloughs |
| Number_Sanctions | Number of sanctions |
| Number_Rewards | Number of rewards |
| Comments | Comments |
| Incidents | Incidents |
| ZDehumanization_1 | 1. Dehumanization 1: Persons belonging to the Muslim community. |
| ZDehumanization_2 | 2. Dehumanization 2: Justice system, Security Forces and prison staff. |
| ZDehumanization_3 | 3. Dehumanization 3: Non-Muslims in general. |
| ZDehumanization_4 | 4. Dehumanization 4: Members of radical Islamist groups. |
| ZDehumanization_5 | 5. Dehumanization 5: Team of therapists. |
| ZMetadehumanization_1 | 1. Metadehumanization 1: How non-Muslims perceive Muslims. |
| ZMetadehumanization_2 | 2. Metadehumanization 2: How the team of therapists perceive Muslim people. |
| ZMetadehumanization_3 | 3. Metadehumanization 3: How the team of therapists perceive me. |
| ZFormidability_Personal_Physical | Formidability Personal Physical |
| ZFormidability_Personal_Spiritual | Formidability Personal Spiritual |
| ZFormidability_Muslims_Physics | Formidability Muslims Physical |
| ZFormidability_Muslims_Spiritual | Formidability Muslims Spiritual |
| ZFormidability_Prophet_Physics | Formidability Prophet Physical |
| ZFormidability_Prophet_Spiritual | Formidability Prophet Spiritual |
| ZFormidability_Therapists_Physics | Formidability Therapists Physical |
| ZFormidability_Therapists_Spiritual | Formidability Therapists Spiritual |
| ZFormidability_Islamists_Physics | Formidability Islamists Physical |
| ZFormidability_Islamists_Spiritual | Formidability Islamists Spiritual |
Data Cleaning
Recode Info
Code
# Define maps as named vectors
gender_map <- c(
"1" = "Female",
"0" = "Male"
)
education_map <- c(
"0 = Unfinished basic education" = "Primary education",
"1 = Basic education" = "Primary education",
"2 = Secondary" = "General secondary education",
"3 = University studies" = "Higher education"
)
# Turn maps into a data.frame
map_df <- bind_rows(
tibble(scale = "gender", original = names(gender_map), recoded = unname(gender_map)),
tibble(scale = "education", original = names(education_map),recoded = unname(education_map))
)
# 3. Print as a table
map_df %>%
select(scale, original, recoded) %>%
kable(
caption = "Scale items and their description.<br>We use them to harmonize the Jihadist dataset with the base dataset.",
col.names = c("Scale","Original label","Recoded label")
) %>%
kable_styling(
full_width = FALSE,
latex_options = c("hold_position", "scale-down")
)| Scale | Original label | Recoded label |
|---|---|---|
| gender | 1 | Female |
| gender | 0 | Male |
| education | 0 = Unfinished basic education | Primary education |
| education | 1 = Basic education | Primary education |
| education | 2 = Secondary | General secondary education |
| education | 3 = University studies | Higher education |
Wrangle
Code
Creating merge dataframe. NIS gets set to response_id. Demographics get recoded in the same way as the base survey..
Code
Also adding items that were measured the same across all surveys. These include moral neutralization, radical attitudes, anger as well as positive and negative affect. Item names correspond to the base survey
Code
Only item does not allign. In the original dataframe it was measured with the item ‘Sad’. In the Jihadist data it was measured with ‘Upset’.
Code
dt_base_jih <- dt_raw_jih %>%
zap_labels() %>% # remove variable labels
zap_formats() %>% # drop SPSS formats
zap_widths() %>% # drop SPSS widths
zap_missing() # drop SPSS/user-missing specs
# 2) Build your dataset (now operating on plain base vectors)
dt_items_jih <- dt_base_jih %>%
transmute(
response_id = as.character(nis),
age = as.numeric(age),
# --- Gender (force into same factor coding: Female=0, Male=1, Other=2)
gender = {
g <- as.character(gender)
tmp <- dplyr::case_when(
g == "0" ~ 1L, # Male
g == "1" ~ 0L, # Female
TRUE ~ 2L
)
factor(tmp, levels = c(0, 1, 2), labels = c("Female", "Male", "Other"))
},
# --- Education (map jihadist 0–3 into same 0–6 scheme as dt_clean)
education = {
e <- as.character(education_level)
tmp <- dplyr::case_when(
e %in% c("0", "1") ~ 0, # Primary
e == "2" ~ 1, # Secondary
e == "3" ~ 4, # Higher
TRUE ~ NA_real_
)
factor(
tmp,
levels = c(0, 1, 2, 3, 4, 5, 6),
labels = c("Primary", "Secondary", "Vocational", "Bachelor", "Higher", "Master", "PhD")
)
},
# --- Religion (always Muslim, code=2 in shared scheme)
religion = factor(
2,
levels = c(0, 1, 2, 3, 4, 5),
labels = c("No_religion", "Christian", "Muslim", "Buddhist", "Jewish", "Other")
),
country = "Jihadist",
# intuition and logic
intuition_1 = NA_real_, # not measured in Jihadist data
logic_2 = NA_real_, # not measured in Jihadist data
# violent intent
violent_intent_1 = as.numeric(radical_attitudes_3),
violent_intent_6 = as.numeric(radical_attitudes_4),
# peaceful intent
peaceful_intent_9 = as.numeric(peaceful_intentions_1),
peaceful_intent_11 = as.numeric(peaceful_intentions_2),
# past activism
past_activism_4 = dplyr::if_else(as.numeric(past_activism_2) == 0, 1L, 0L),
past_activism_2 = dplyr::if_else(as.numeric(past_activism_1) == 0, 1L, 0L),
# harmonious passion
harmonious_passion_5 = as.numeric(passion_3),
harmonious_passion_10 = as.numeric(passion_4),
# obsessive passion
obsessive_passion_11 = as.numeric(passion_1),
obsessive_passion_7 = as.numeric(passion_2),
# commitment passion
commitment_passion_15 = as.numeric(superiority_1),
commitment_passion_16 = as.numeric(superiority_2),
# identity fusion
identity_fusion = as.numeric(1 + as.numeric(fusion_religion_present_dic) * (7 - 1)), # rescaling yes/no to endpoints from base
# ingroup superiority
ingroup_superiority_2 = as.numeric(superiority_3),
ingroup_superiority_4 = as.numeric(superiority_4),
# collective relative deprivation
collective_relative_deprivation_4 = as.numeric(discrimination_7),
# perceived discrimination
perceived_discrimination_7 = as.numeric(discrimination_1),
perceived_discrimination_8 = as.numeric(discrimination_3),
# activist intent
activist_intent = NA_real_, # not measured in Jihadist data
# moral neutralization
moral_neutralization_4 = as.numeric(cognitive_restructuration_1),
moral_neutralization_6 = as.numeric(cognitive_restructuration_2),
moral_neutralization_10 = as.numeric(cognitive_restructuration_3),
moral_neutralization_11 = as.numeric(cognitive_restructuration_4),
moral_neutralization_13 = as.numeric(cognitive_restructuration_5),
moral_neutralization_14 = as.numeric(cognitive_restructuration_6),
moral_neutralization_15 = as.numeric(cognitive_restructuration_7),
moral_neutralization_16 = as.numeric(cognitive_restructuration_8),
# radical attitudes
radical_attitudes_3 = as.numeric(radical_attitudes_2),
radical_attitudes_2 = as.numeric(radical_attitudes_1),
# anger
anger_1 = as.numeric(anger_1),
anger_3 = as.numeric(anger_2),
anger_9 = as.numeric(anger_3),
anger_10 = as.numeric(anger_4),
# positive affect
positive_affect_1 = as.numeric(affection_7),
positive_affect_2 = as.numeric(affection_8),
positive_affect_3 = as.numeric(affection_3),
positive_affect_4 = as.numeric(affection_5),
positive_affect_5 = as.numeric(affection_10),
# negative affect
negative_affect_6 = as.numeric(affection_9),
negative_affect_7 = as.numeric(affection_6),
negative_affect_8 = as.numeric(affection_1),
negative_affect_9 = as.numeric(affection_4),
negative_affect_10 = as.numeric(affection_2)
) %>%
# 3) (Paranoia pass) Ensure no haven attributes survived
zap_labels()
# rm(dt_raw_jih)Rescale
Function
Code
# --- pure linear rescale: [a,b] -> [c,d]
.rescale_linear <- function(x, a, b, c, d) {
if (isTRUE(all.equal(a, b))) {
warning("from_min == from_max; cannot rescale a constant range. Returning NA for that column.")
return(rep(NA_real_, length(x)))
}
c + (x - a) * (d - c) / (b - a)
}
# --- main helper: rescale selected columns per an explicit spec tibble
# spec must have: variable, from_min, from_max, to_min, to_max
rescale_with_spec <- function(df, spec, dataset = "unknown") {
stopifnot(all(c("variable","from_min","from_max","to_min","to_max") %in% names(spec)))
out <- df
log <- pmap_dfr(spec, function(variable, from_min, from_max, to_min, to_max) {
if (!variable %in% names(out)) {
return(tibble(
dataset = dataset, variable = variable,
from_min = from_min, from_max = from_max,
to_min = to_min, to_max = to_max,
observed_old_min = NA_real_, observed_old_max = NA_real_,
observed_new_min = NA_real_, observed_new_max = NA_real_,
n_non_missing = 0L, n_changed = 0L,
status = "missing_column"
))
}
v_before <- suppressWarnings(as.numeric(out[[variable]]))
obs_old_min <- suppressWarnings(if (all(is.na(v_before))) NA_real_ else min(v_before, na.rm = TRUE))
obs_old_max <- suppressWarnings(if (all(is.na(v_before))) NA_real_ else max(v_before, na.rm = TRUE))
v_after <- .rescale_linear(v_before, from_min, from_max, to_min, to_max)
out[[variable]] <<- v_after
tibble(
dataset = dataset, variable = variable,
from_min = from_min, from_max = from_max,
to_min = to_min, to_max = to_max,
observed_old_min = obs_old_min, observed_old_max = obs_old_max,
observed_new_min = suppressWarnings(if (all(is.na(v_after))) NA_real_ else min(v_after, na.rm = TRUE)),
observed_new_max = suppressWarnings(if (all(is.na(v_after))) NA_real_ else max(v_after, na.rm = TRUE)),
n_non_missing = sum(!is.na(v_before)),
n_changed = sum(!is.na(v_before) & !is.na(v_after) & v_before != v_after),
status = "rescaled"
)
})
list(data = out, log = log)
}Code
spec_jih <- tribble(
~variable, ~from_min, ~from_max, ~to_min, ~to_max,
"ingroup_superiority_2", 0, 6, 1, 7,
"ingroup_superiority_4", 0, 6, 1, 7,
"collective_relative_deprivation_4", 0, 6, 1, 7,
"commitment_passion_15", 0, 6, 1, 7,
"commitment_passion_16", 0, 6, 1, 7,
"harmonious_passion_10", 0, 6, 1, 7,
"harmonious_passion_5", 0, 6, 1, 7,
"obsessive_passion_11", 0, 6, 1, 7,
"obsessive_passion_7", 0, 6, 1, 7,
"moral_neutralization_10", 0, 6, 1, 7,
"moral_neutralization_11", 0, 6, 1, 7,
"moral_neutralization_13", 0, 6, 1, 7,
"moral_neutralization_14", 0, 6, 1, 7,
"moral_neutralization_15", 0, 6, 1, 7,
"moral_neutralization_16", 0, 6, 1, 7,
"moral_neutralization_4", 0, 6, 1, 7,
"moral_neutralization_6", 0, 6, 1, 7,
"perceived_discrimination_7", 0, 6, 1, 7,
"perceived_discrimination_8", 0, 6, 1, 7,
"radical_attitudes_2", 0, 6, 1, 8,
"radical_attitudes_3", 0, 6, 1, 8,
"violent_intent_1", 0, 6, 1, 8,
"violent_intent_6", 0, 6, 1, 8,
"peaceful_intent_11", 0, 4, 1, 8,
"peaceful_intent_9", 0, 4, 1, 8,
"anger_1", 0, 6, 1, 6,
"anger_3", 0, 6, 1, 6,
"anger_9", 0, 6, 1, 6,
"anger_10", 0, 6, 1, 6,
"positive_affect_1", 0, 6, 1, 5,
"positive_affect_2", 0, 6, 1, 5,
"positive_affect_3", 0, 6, 1, 5,
"positive_affect_4", 0, 6, 1, 5,
"positive_affect_5", 0, 6, 1, 5,
"negative_affect_10", 0, 6, 1, 5,
"negative_affect_6", 0, 6, 1, 5,
"negative_affect_7", 0, 6, 1, 5,
"negative_affect_8", 0, 6, 1, 5,
"negative_affect_9", 0, 6, 1, 5
)Execute
Code
# rescale
dt_items_jih_rescale <- rescale_with_spec(dt_items_jih, spec_jih, dataset = "Jihadist")
# show differences
dt_items_jih_rescale$log %>%
kable(., caption = "Items that were rescaled") %>%
kable_styling(full_width = F, latex_options = c("hold_position", "scale-down")) %>%
scroll_box(width = "100%", height = "600px")| dataset | variable | from_min | from_max | to_min | to_max | observed_old_min | observed_old_max | observed_new_min | observed_new_max | n_non_missing | n_changed | status |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Jihadist | ingroup_superiority_2 | 0 | 6 | 1 | 7 | 0 | 6 | 1 | 7 | 64 | 64 | rescaled |
| Jihadist | ingroup_superiority_4 | 0 | 6 | 1 | 7 | 0 | 6 | 1 | 7 | 67 | 67 | rescaled |
| Jihadist | collective_relative_deprivation_4 | 0 | 6 | 1 | 7 | 0 | 6 | 1 | 7 | 70 | 70 | rescaled |
| Jihadist | commitment_passion_15 | 0 | 6 | 1 | 7 | 0 | 6 | 1 | 7 | 69 | 69 | rescaled |
| Jihadist | commitment_passion_16 | 0 | 6 | 1 | 7 | 0 | 6 | 1 | 7 | 68 | 68 | rescaled |
| Jihadist | harmonious_passion_10 | 0 | 6 | 1 | 7 | 0 | 6 | 1 | 7 | 68 | 68 | rescaled |
| Jihadist | harmonious_passion_5 | 0 | 6 | 1 | 7 | 0 | 6 | 1 | 7 | 68 | 68 | rescaled |
| Jihadist | obsessive_passion_11 | 0 | 6 | 1 | 7 | 0 | 6 | 1 | 7 | 67 | 67 | rescaled |
| Jihadist | obsessive_passion_7 | 0 | 6 | 1 | 7 | 0 | 6 | 1 | 7 | 69 | 69 | rescaled |
| Jihadist | moral_neutralization_10 | 0 | 6 | 1 | 7 | 0 | 6 | 1 | 7 | 72 | 72 | rescaled |
| Jihadist | moral_neutralization_11 | 0 | 6 | 1 | 7 | 0 | 6 | 1 | 7 | 73 | 73 | rescaled |
| Jihadist | moral_neutralization_13 | 0 | 6 | 1 | 7 | 0 | 6 | 1 | 7 | 71 | 71 | rescaled |
| Jihadist | moral_neutralization_14 | 0 | 6 | 1 | 7 | 0 | 6 | 1 | 7 | 72 | 72 | rescaled |
| Jihadist | moral_neutralization_15 | 0 | 6 | 1 | 7 | 0 | 6 | 1 | 7 | 73 | 73 | rescaled |
| Jihadist | moral_neutralization_16 | 0 | 6 | 1 | 7 | 0 | 6 | 1 | 7 | 73 | 73 | rescaled |
| Jihadist | moral_neutralization_4 | 0 | 6 | 1 | 7 | 0 | 6 | 1 | 7 | 71 | 71 | rescaled |
| Jihadist | moral_neutralization_6 | 0 | 6 | 1 | 7 | 0 | 6 | 1 | 7 | 73 | 73 | rescaled |
| Jihadist | perceived_discrimination_7 | 0 | 6 | 1 | 7 | 0 | 6 | 1 | 7 | 77 | 77 | rescaled |
| Jihadist | perceived_discrimination_8 | 0 | 6 | 1 | 7 | 0 | 6 | 1 | 7 | 78 | 78 | rescaled |
| Jihadist | radical_attitudes_2 | 0 | 6 | 1 | 8 | 0 | 6 | 1 | 8 | 74 | 74 | rescaled |
| Jihadist | radical_attitudes_3 | 0 | 6 | 1 | 8 | 0 | 6 | 1 | 8 | 73 | 73 | rescaled |
| Jihadist | violent_intent_1 | 0 | 6 | 1 | 8 | 0 | 6 | 1 | 8 | 69 | 69 | rescaled |
| Jihadist | violent_intent_6 | 0 | 6 | 1 | 8 | 0 | 6 | 1 | 8 | 69 | 69 | rescaled |
| Jihadist | peaceful_intent_11 | 0 | 4 | 1 | 8 | 0 | 4 | 1 | 8 | 65 | 65 | rescaled |
| Jihadist | peaceful_intent_9 | 0 | 4 | 1 | 8 | 0 | 4 | 1 | 8 | 66 | 66 | rescaled |
| Jihadist | anger_1 | 0 | 6 | 1 | 6 | 0 | 6 | 1 | 6 | 74 | 56 | rescaled |
| Jihadist | anger_3 | 0 | 6 | 1 | 6 | 0 | 6 | 1 | 6 | 75 | 55 | rescaled |
| Jihadist | anger_9 | 0 | 6 | 1 | 6 | 0 | 6 | 1 | 6 | 75 | 55 | rescaled |
| Jihadist | anger_10 | 0 | 6 | 1 | 6 | 0 | 6 | 1 | 6 | 72 | 64 | rescaled |
| Jihadist | positive_affect_1 | 0 | 6 | 1 | 5 | 0 | 6 | 1 | 5 | 71 | 54 | rescaled |
| Jihadist | positive_affect_2 | 0 | 6 | 1 | 5 | 0 | 6 | 1 | 5 | 74 | 62 | rescaled |
| Jihadist | positive_affect_3 | 0 | 6 | 1 | 5 | 0 | 6 | 1 | 5 | 74 | 58 | rescaled |
| Jihadist | positive_affect_4 | 0 | 6 | 1 | 5 | 0 | 6 | 1 | 5 | 72 | 58 | rescaled |
| Jihadist | positive_affect_5 | 0 | 6 | 1 | 5 | 0 | 6 | 1 | 5 | 74 | 60 | rescaled |
| Jihadist | negative_affect_10 | 0 | 6 | 1 | 5 | 0 | 6 | 1 | 5 | 72 | 60 | rescaled |
| Jihadist | negative_affect_6 | 0 | 6 | 1 | 5 | 0 | 6 | 1 | 5 | 72 | 57 | rescaled |
| Jihadist | negative_affect_7 | 0 | 6 | 1 | 5 | 0 | 6 | 1 | 5 | 75 | 59 | rescaled |
| Jihadist | negative_affect_8 | 0 | 6 | 1 | 5 | 0 | 6 | 1 | 5 | 74 | 52 | rescaled |
| Jihadist | negative_affect_9 | 0 | 6 | 1 | 5 | 0 | 6 | 1 | 5 | 75 | 60 | rescaled |
Create Scales
Functions
Code
# helper: identify 0/1 items (ignoring NA)
is_binary01 <- function(x) {
ux <- unique(na.omit(x))
length(ux) > 0 && all(ux %in% c(0, 1))
}
# Function to calculate Cronbach's alpha (returns raw alpha)
# Filters out items with zero variance or all NA
calculate_cronbach_alpha <- function(df) {
cat(' [Alpha] Original items:', ncol(df), 'columns<br>')
df0 <- na.omit(df)
var_vals <- apply(df0, 2, function(x) var(x, na.rm = TRUE))
keep_cols <- names(var_vals)[which(var_vals > 0 & !is.na(var_vals))]
cat(' [Alpha] Keeping', length(keep_cols), 'varying items after filtering<br>')
df0 <- df0[, keep_cols, drop = FALSE]
if (ncol(df0) < 2) {
cat(' [Alpha] Less than 2 items remain; returning NA<br>')
return(NA_real_)
}
alpha_out <- psych::alpha(df0, warnings = FALSE)
raw_alpha <- alpha_out$total$raw_alpha
cat(' [Alpha] Cronbach\'s alpha:', round(raw_alpha, 3), '<br>')
raw_alpha
}
# Function to calculate raw scale scores
# Drops items with no variance before scoring
calculate_scale_scores <- function(df) {
n <- nrow(df)
cat(' [Score] Original items:', ncol(df), 'columns for scoring<br>')
if (ncol(df) == 0) {
cat(' [Score] No items; returning NA vector<br>')
return(rep(NA_real_, n))
}
var_vals <- sapply(df, function(x) if (all(is.na(x))) NA_real_ else var(x, na.rm = TRUE))
keep <- which(var_vals > 0)
cat(' [Score] Keeping', length(keep), 'varying items after filtering<br>')
df <- df[, keep, drop = FALSE]
if (ncol(df) == 0) {
cat(' [Score] No varying items; returning NA vector<br>')
return(rep(NA_real_, n))
}
if (ncol(df) == 1) {
cat(' [Score] Single item scale; returning raw values<br>')
return(df[[1]])
}
# --- NEW: binary-only scoring branch (proportion endorsed) ---
is_bin_all <- all(vapply(df, is_binary01, logical(1)))
if (is_bin_all) {
cat(' [Score] Detected dichotomous subscale; returning proportion endorsed (0–1)<br>')
return(rowMeans(df, na.rm = TRUE))
}
# -------------------------------------------------------------
# Determine common min and max across items (Likert-only at this point)
mins <- sapply(df, min, na.rm = TRUE)
maxs <- sapply(df, max, na.rm = TRUE)
minval <- as.numeric(names(sort(table(mins), decreasing = TRUE))[1])
maxval <- as.numeric(names(sort(table(maxs), decreasing = TRUE))[1])
cat(' [Score] Using min', minval, 'and max', maxval, 'for scoring<br>')
keys <- rep(1, ncol(df))
scores <- psych::scoreItems(keys, df, min = minval, max = maxval)$scores
as.numeric(scores)
}
# Main wrapper to generate scale scores and reliabilities
create_scales <- function(df) {
cat('Starting scale creation for', nrow(df), 'responses<br>')
item_cols <- setdiff(names(df), c('response_id', 'age', 'gender', 'education', 'religion', 'country'))
subscales <- unique(stringr::str_replace(item_cols, '_\\d+$', ''))
cat('Found', length(subscales), 'subscales<br>')
results <- purrr::map(subscales, function(sub) {
cols <- grep(paste0('^', sub, '_\\d+$'), item_cols, value = TRUE)
n_items <- length(cols)
cat('<br><b>Processing subscale:', sub, 'with', n_items, 'items</b><br>')
sub_df <- df[cols]
# Compute scores first (handles binary-only internally)
raw_scores <- calculate_scale_scores(sub_df)
if (n_items == 2) {
if (var(sub_df[[1]], na.rm = TRUE) > 0 && var(sub_df[[2]], na.rm = TRUE) > 0) {
rel_raw <- cor(sub_df[[1]], sub_df[[2]], use = 'pairwise.complete.obs')
cat(' [Rel] Pearson correlation:', round(rel_raw, 3), '<br>')
} else {
rel_raw <- NA_real_
cat(' [Rel] Correlation not defined (zero variance)<br>')
}
stat <- 'Correlation'
} else if (n_items >= 3) {
# Decide label based on whether (after dropping zero-variance) all items are binary
var_vals <- sapply(sub_df, function(x) if (all(is.na(x))) NA_real_ else var(x, na.rm = TRUE))
keep2 <- which(var_vals > 0)
sub_df_kept <- if (length(keep2)) sub_df[, keep2, drop = FALSE] else sub_df[, 0]
is_all_binary <- ncol(sub_df_kept) > 1 && all(vapply(sub_df_kept, is_binary01, logical(1)))
rel_raw <- calculate_cronbach_alpha(sub_df) # raw α; equals KR-20 for binary
stat <- if (is_all_binary) 'KR-20 (α)' else 'Cronbach\'s α'
} else {
rel_raw <- NA_real_
stat <- NA_character_
cat(' [Rel] Not enough items for reliability estimate<br>')
}
rel_val <- if (is.numeric(rel_raw)) round(rel_raw, 3) else NA_real_
tib_scores <- tibble::tibble(
response_id = df$response_id,
!!paste0(sub, '_score') := raw_scores
)
tib_reli <- tibble::tibble(
Subscale = sub,
Items = n_items,
Reliability = rel_val,
Statistic = stat
)
list(scores = tib_scores, reliability = tib_reli)
})
all_scores <- purrr::reduce(purrr::map(results, 'scores'), dplyr::left_join, by = 'response_id')
all_reli <- dplyr::bind_rows(purrr::map(results, 'reliability'))
cat('<br>Scale creation complete.<br>')
list(scores = all_scores, reliability = all_reli)
}Create
Starting scale creation for 80 responses
Found 18 subscales
Processing subscale: intuition with 1 items
[Score] Original items: 1 columns for scoring
[Score] Keeping 0 varying items after filtering
[Score] No varying items; returning NA vector
[Rel] Not enough items for reliability estimate
Processing subscale: logic with 1 items
[Score] Original items: 1 columns for scoring
[Score] Keeping 0 varying items after filtering
[Score] No varying items; returning NA vector
[Rel] Not enough items for reliability estimate
Processing subscale: violent_intent with 2 items
[Score] Original items: 2 columns for scoring
[Score] Keeping 2 varying items after filtering
[Score] Using min 1 and max 8 for scoring
[Rel] Pearson correlation: 0.821
Processing subscale: peaceful_intent with 2 items
[Score] Original items: 2 columns for scoring
[Score] Keeping 2 varying items after filtering
[Score] Using min 1 and max 8 for scoring
[Rel] Pearson correlation: 0.779
Processing subscale: past_activism with 2 items
[Score] Original items: 2 columns for scoring
[Score] Keeping 2 varying items after filtering
[Score] Detected dichotomous subscale; returning proportion endorsed (0–1)
[Rel] Pearson correlation: 0.39
Processing subscale: harmonious_passion with 2 items
[Score] Original items: 2 columns for scoring
[Score] Keeping 2 varying items after filtering
[Score] Using min 1 and max 7 for scoring
[Rel] Pearson correlation: 0.62
Processing subscale: obsessive_passion with 2 items
[Score] Original items: 2 columns for scoring
[Score] Keeping 2 varying items after filtering
[Score] Using min 1 and max 7 for scoring
[Rel] Pearson correlation: 0.488
Processing subscale: commitment_passion with 2 items
[Score] Original items: 2 columns for scoring
[Score] Keeping 2 varying items after filtering
[Score] Using min 1 and max 7 for scoring
[Rel] Pearson correlation: 0.743
Processing subscale: identity_fusion with 0 items
[Score] Original items: 0 columns for scoring
[Score] No items; returning NA vector
[Rel] Not enough items for reliability estimate
Processing subscale: ingroup_superiority with 2 items
[Score] Original items: 2 columns for scoring
[Score] Keeping 2 varying items after filtering
[Score] Using min 1 and max 7 for scoring
[Rel] Pearson correlation: 0.623
Processing subscale: collective_relative_deprivation with 1 items
[Score] Original items: 1 columns for scoring
[Score] Keeping 1 varying items after filtering
[Score] Single item scale; returning raw values
[Rel] Not enough items for reliability estimate
Processing subscale: perceived_discrimination with 2 items
[Score] Original items: 2 columns for scoring
[Score] Keeping 2 varying items after filtering
[Score] Using min 1 and max 7 for scoring
[Rel] Pearson correlation: 0.624
Processing subscale: activist_intent with 0 items
[Score] Original items: 0 columns for scoring
[Score] No items; returning NA vector
[Rel] Not enough items for reliability estimate
Processing subscale: moral_neutralization with 8 items
[Score] Original items: 8 columns for scoring
[Score] Keeping 8 varying items after filtering
[Score] Using min 1 and max 7 for scoring
[Alpha] Original items: 8 columns
[Alpha] Keeping 8 varying items after filtering
[Alpha] Cronbach’s alpha: 0.814
Processing subscale: radical_attitudes with 2 items
[Score] Original items: 2 columns for scoring
[Score] Keeping 2 varying items after filtering
[Score] Using min 1 and max 8 for scoring
[Rel] Pearson correlation: 0.93
Processing subscale: anger with 4 items
[Score] Original items: 4 columns for scoring
[Score] Keeping 4 varying items after filtering
[Score] Using min 1 and max 6 for scoring
In smc, smcs < 0 were set to .0
[Alpha] Original items: 4 columns
[Alpha] Keeping 4 varying items after filtering
Warning in cor.smooth(r): Matrix was not positive definite, smoothing was done
In smc, smcs < 0 were set to .0
In smc, smcs < 0 were set to .0
In smc, smcs < 0 were set to .0
In smc, smcs < 0 were set to .0
[Alpha] Cronbach’s alpha: 0.79
Processing subscale: positive_affect with 5 items
[Score] Original items: 5 columns for scoring
[Score] Keeping 5 varying items after filtering
[Score] Using min 1 and max 5 for scoring
[Alpha] Original items: 5 columns
[Alpha] Keeping 5 varying items after filtering
[Alpha] Cronbach’s alpha: 0.767
Processing subscale: negative_affect with 5 items
[Score] Original items: 5 columns for scoring
[Score] Keeping 5 varying items after filtering
[Score] Using min 1 and max 5 for scoring
[Alpha] Original items: 5 columns
[Alpha] Keeping 5 varying items after filtering
[Alpha] Cronbach’s alpha: 0.812
Scale creation complete.
Code
# Print reliability table
out_scales$reliability %>%
arrange(Subscale) %>%
kable(.,
col.names = c("Subscale", "Number of Items", "Reliability", "Statistic"),
caption = "Reliability Scores per Scale"
) %>%
kable_styling(full_width = F, latex_options = c("hold_position", "scale-down")) %>%
scroll_box(width = "100%", height = "600px")| Subscale | Number of Items | Reliability | Statistic |
|---|---|---|---|
| activist_intent | 0 | NA | NA |
| anger | 4 | 0.790 | Cronbach's α |
| collective_relative_deprivation | 1 | NA | NA |
| commitment_passion | 2 | 0.743 | Correlation |
| harmonious_passion | 2 | 0.620 | Correlation |
| identity_fusion | 0 | NA | NA |
| ingroup_superiority | 2 | 0.623 | Correlation |
| intuition | 1 | NA | NA |
| logic | 1 | NA | NA |
| moral_neutralization | 8 | 0.814 | Cronbach's α |
| negative_affect | 5 | 0.812 | Cronbach's α |
| obsessive_passion | 2 | 0.488 | Correlation |
| past_activism | 2 | 0.390 | Correlation |
| peaceful_intent | 2 | 0.779 | Correlation |
| perceived_discrimination | 2 | 0.624 | Correlation |
| positive_affect | 5 | 0.767 | Cronbach's α |
| radical_attitudes | 2 | 0.930 | Correlation |
| violent_intent | 2 | 0.821 | Correlation |
Create dt_ana_base
Code
dt_ana_base_jih <- tibble(
response_id = as.character(dt_items_jih$response_id),
age = dt_items_jih$age,
gender = dt_items_jih$gender,
education = dt_items_jih$education,
education_num = as.numeric(education),
religion = dt_items_jih$religion,
country = dt_items_jih$country, # should probably be moved out of scale collapse script
moral_neutralization = as.numeric(out_scales$scores$moral_neutralization_score),
anger = as.numeric(out_scales$scores$anger_score),
radical_attitudes = as.numeric(out_scales$scores$radical_attitudes_score),
positive_affect = as.numeric(out_scales$scores$positive_affect_score),
negative_affect = as.numeric(out_scales$scores$negative_affect_score),
past_activism = as.numeric(out_scales$scores$past_activism_score),
collective_relative_deprivation = as.numeric(out_scales$scores$collective_relative_deprivation_score),
perceived_discrimination = as.numeric(out_scales$scores$perceived_discrimination_score),
ingroup_superiority = as.numeric(out_scales$scores$ingroup_superiority_score),
activist_intent = as.numeric(dt_items_jih$activist_intent), # not measured here
harmonious_passion = as.numeric(out_scales$scores$harmonious_passion_score),
obsessive_passion = as.numeric(out_scales$scores$obsessive_passion_score),
commitment_passion = as.numeric(out_scales$scores$commitment_passion_score),
identity_fusion = as.numeric(dt_items_jih$identity_fusion), # only one item and different from base survey
intuition = as.numeric(dt_items_jih$intuition_1), # not measure here
logic = as.numeric(dt_items_jih$logic_2), # not measure here
violent_intent = as.numeric(out_scales$scores$violent_intent_score),
peaceful_intent = as.numeric(out_scales$scores$peaceful_intent_score)
)Save data
Saving dataframe dt_items_jih…. Dataframe saved as ../data/wrangled_data/dt_items_jih.RData and ../data/wrangled_data/dt_items_jih.csv
Saving dataframe dt_ana_base_jih…. Dataframe saved as ../data/wrangled_data/dt_ana_base_jih.RData and ../data/wrangled_data/dt_ana_base_jih.csv