
#################################################
#                                               #    
# Supplementary file for:                       #
#                                               #
# Reconsidering the Relationship between        #
# Anti-Immigration Attitudes and Preferences    #
# for the AfD Using Implicit Attitudes Measures #
#                                               #
# by Manuel Kleinert                            #
#                                               #
# published in Politische Vierteljahresschrift  #
#                                               #
#################################################

#This files analyses the GLES Panel waves 19 and 24 to support the 
#expectation of a strong association between anti-immigration
#attitudes and sympathy for the AfD. These findings are mentioned
#in the main manuscript in a footnote and in the online appendix. 

#To run this script, please download the GLES Panel waves 19 and 24:
#wave 19: https://doi.org/10.4232/1.14114
#wave 24: https://doi.org/10.4232/1.14141

#This script was performed on the following files,
#ZA6838_w19_sA_v6-0-0.sav
#ZA7730_v1-0-0.sav
#which are loaded at the beginning using the read_sav command. 

library(haven)
library(summarytools)

#load data
wave19 <- read_sav(".../ZA6838_w19_sA_v6-0-0.sav")
wave24 <- read_sav(".../ZA7730_v1-0-0.sav")

#select variables
wave19 <- subset(wave19, select = c("kp19_1110i", "kp19_1110b", "kp19_1110e", 
                                    "kp19_1270i", "kp19_1270b", "kp19_1270e", 
                                    "lfdn"))
wave24 <- subset(wave24, select = c("kp24_1110i", "kp24_1110b", "kp24_1110e", 
                                    "kp24_1270i", "kp24_1270b", "kp24_1270e", 
                                    "lfdn"))
#define missings
wave19[wave19 < 1] <- NA
wave24[wave24 < 1] <- NA

#frequency tables AfD-Migration
freq(wave19$kp19_1110i)
freq(wave24$kp24_1110i)

#merga data
both <- merge(wave19, wave24, by="lfdn")

#crosstable AfD-Migration in 2021 and 2023
ctable(both$kp19_1110i, both$kp24_1110i)

#compute and analyse "switch" of respondents
both$diff_afd_mig <- abs(both$kp24_1110i - both$kp19_1110i)
both$diff_csu_mig <- abs(both$kp24_1110b - both$kp19_1110b)
both$diff_gre_mig <- abs(both$kp24_1110e - both$kp19_1110e)

freq(both$diff_afd_mig)
freq(both$diff_csu_mig)
freq(both$diff_gre_mig)

#for comparison, the same procedure with Greens-Climate vs Economy

freq(both$kp19_1270e)
freq(both$kp24_1270e)

ctable(both$kp19_1270e, both$kp24_1270e)

both$diff_afd_cli = abs(both$kp24_1270i - both$kp19_1270i)
both$diff_csu_cli = abs(both$kp24_1270b - both$kp19_1270b)
both$diff_gre_cli = abs(both$kp24_1270e - both$kp19_1270e)

freq(both$diff_afd_cli)
freq(both$diff_csu_cli)
freq(both$diff_gre_cli)

#


