File: SVOSM_analyses_final.R

Comment: mean level of transitive respondents per wave
Category: Data Variable
Code:
aggregate(long_svo_multi$trans,list(long_svo_multi$wave_cat),FUN=mean,na.rm =T)

Comment: create variable with only NA values
Category: Data Variable
Code:
long_svo_multi$vlengths = rep(NA, times = 2970)

Comment: calculate vector length per row
Category: Data Variable
Code:
for (i in 1:2970) {long_svo_multi$vlengths[i]=calculate_vlength(mean_self[i], mean_other[i])}

Comment: criterion to select applicable cases select only rows with transitive and good vector length response profiles as well as respondents with NA values this criterion used to select applicable cases for data analyses and figures
Category: Data Variable
Code:
data_criterion <- (long_svo_multi$trans == "TRUE" & long_svo_multi$trans_vlenght == "TRUE" | is.na(long_svo_multi$trans) | is.na(long_svo_multi$trans_vlenght))

Comment: KolmogorovSmirnov ksamples test for SVO angles
Category: Statistical Test
Code:
ks.test(dropouts$SVO_angle, stayers$SVO_angle) ks.test(dropouts$SVO_angle, stayers$SVO_angle) ks.test(dropouts$SVO_angle, stayers$SVO_angle) ks.test(dropouts$SVO_angle, stayers$SVO_angle) ks.test(dropouts$SVO_angle, stayers$SVO_angle)

Comment: Fishersexact test for SVO types
Category: Statistical Test
Code:
fisher.test(table(dropouts$SVO_dicho_num),table( stayers$SVO_dicho_num)) fisher.test(table(dropouts$SVO_dicho_num),table( stayers$SVO_dicho_num)) fisher.test(table(dropouts$SVO_dicho_num),table( stayers$SVO_dicho_num)) fisher.test(table(dropouts$SVO_dicho_num),table( stayers$SVO_dicho_num)) fisher.test(table(dropouts$SVO_dicho_num),table( stayers$SVO_dicho_num))

Comment: lagged variables of distance to 45 boundary in SVO
Category: Data Variable
Code:
long_svo_multi$distance_45<-round(abs(45 - long_svo_multi$prior_SVO),digits = 2)

Comment: alter a variable to label dropouts as 1 and stayers as 0 for ML analysis and this variable as dependent variable
Category: Data Variable
Code:
data_adjusted$stay_dropout <- data_adjusted$change_cat data_adjusted$stay_dropout <- ifelse(data_adjusted$stay_dropout == 1,0, ifelse(data_adjusted$stay_dropout == 0,0,1)) data_adjusted$stay_dropout <- replace_na(data_adjusted$stay_dropout,value = 1) data_adjusted_1 <- data_adjusted %>% filter(trans == "TRUE" & trans_vlenght == "TRUE" | is.na(trans) | is.na(trans_vlenght))

Comment: grid arrange to create figure with distribution of angles and SVO categories
Category: Visualization
Code:
get_legend<-function(myggplot){ tmp <- ggplot_gtable(ggplot_build(myggplot)) leg <- which(sapply(tmp$grobs, function(x) x$name) == "guide-box") legend <- tmp$grobs[[leg]] return(legend)} bp <- theme(legend.position="none")

Comment: Assessing minor longitudinal differences in SVO angles select applicable cases and variables
Category: Data Variable
Code:
adjust <-dplyr::select(long_svo_multi,id,SVO_angle,wave_cat,trans,trans_vlenght) data_input <- na.omit(adjust) data_input$SVO_angle <- round(data_input$SVO_angle, digits = 2) data_input <- data_input %>% filter(trans == "TRUE" & trans_vlenght == "TRUE") data_wide_2 <- dcast(data_input, id ~ wave_cat, value.var="SVO_angle") data_wide_2 <- na.omit(data_wide_2)

Comment: cumulative change of difference in SVO angles wave per wave
Category: Data Variable
Code:
data_wide_6$change_wave_1 <- data_wide_6$diff_w1 data_wide_6$change_wave_1_2 <- data_wide_6$diff_w1_w2 data_wide_6$change_wave_1_2_3 <- data_wide_6$change_wave_1_2 + data_wide_6$diff_w2_w3 data_wide_6$change_wave_1_2_3_4 <- data_wide_6$change_wave_1_2_3 + data_wide_6$diff_w3_w4 data_wide_6$change_wave_1_2_3_4_5 <- data_wide_6$change_wave_1_2_3_4 + data_wide_6$diff_w4_w5 data_wide_6$change_wave_1_2_3_4_5_6 <- data_wide_6$change_wave_1_2_3_4_5 + data_wide_6$diff_w5_w6 data_wide_7 <- data_wide_6[, c(1,8:13)] long_SVO_4 <- melt(data = data_wide_7, id.vars = c("id"), variable.name = "wave_compare", value.name = "cumulative_change_in_SVO")