# Supplementary Material 2.3: Script for conducting the exploratory and confirmatory factor analsyes reported in the paper and the latent variable path analysis / SEM (author: Stefano Guidi) # cfa e efa cyberbullying library(lavaan) library(psych) library(GPArotation) library(semPlot) # load data from Rdata format (categorical predictors and outcomes are already factors) load(file = "S2_Dataset.RData") # SM2_data_regression_SEM this will be the name of the loaded object (a dataframe) # Note: data are the same used and loaded in script SM2_2_regression.R so there is no need to run this line if already loaded # determine train and test samples set.seed(17061973) indici_train = sort(sample(nrow(SM2_data_regression_SEM), nrow(SM2_data_regression_SEM)*.3)) dati_train <- SM2_data_regression_SEM[indici_train, ] dati_test <- SM2_data_regression_SEM[-indici_train, ] # EFA su subset ---- # convert to numeric items_cyb_action_num_train <- dati_train %>% dplyr::select(8:13) %>% mutate(across(everything(), as.numeric)) # %>% View() #items_cyb_action_num_train %>% View() #names(items_cyb_action_num_train) # determine the number of factors p_anal <- fa.parallel(items_cyb_action_num_train, cor = "poly") # 2 fattori o 1 componenti p_anal$nfact fa.parallel(items_cyb_action_num_train, cor = "poly", fm = "ml") # 2 fattori o 1 componenti VSS(items_cyb_action_num_train, cor = "poly") # 1 o 2 fattori # 2 fattori FA_cyb_action_train <- fa(items_cyb_action_num_train, 2, rotate="oblimin", cor="poly") summary(FA_cyb_action_train) print(FA_cyb_action_train, cut = 0.3) # cross validation ----- extractFactors <- function(df){ indici_train = sort(sample(nrow(df), nrow(df)*.3)) df <- df[indici_train, ] df <- df %>% dplyr::select(8:13) %>% mutate(across(everything(), as.numeric)) EFA <- fa(df, 2, rotate="oblimin", cor="poly") n_fact <- fa.parallel(df, cor = "poly") return( list(loadings = EFA$loadings, n_fact = n_fact$nfact )) #print(EFA$loadings, cut = 0.4) } prova <- extractFactors(SM2_data_regression_SEM) prova$n_fact set.seed(29122014) # al primo loop viene un errore al modello 16. n_fattori_estratti <- tibble() for (i in 1:100){ risultati <- extractFactors(SM2_data_regression_SEM) cat("\nModel:", i, sep = "") print(risultati$loadings, cut = 0.35) n_fattori_estratti <- bind_rows( n_fattori_estratti, tibble(n = i, n_factors = risultati$n_fact) ) } frq(n_fattori_estratti$n_factors) write_excel_csv2(n_fattori_estratti, file = "n_fattori.csv") findNumberOfFactors <- function(df){ indici_train = sort(sample(nrow(df), nrow(df)*.3)) df <- df[indici_train, ] df <- df %>% dplyr::select(8:13) %>% mutate(across(everything(), as.numeric)) EFA <- fa(df, 2, rotate="oblimin", cor="poly") return(EFA$loadings) #print(EFA$loadings, cut = 0.4) } prova <- extractFactors(SM2_data_regression_SEM) # CFA su test subset ---- modello_cyberbullying_action_2_factors_test <- ' cyberbullying_1 =~ CybBul1 + CybBul2 + CybBul4 cyberbullying_2 =~ CybBul3 + CybBul5 + CybBul6 ' #is.ordered(dati_ileana_2$CybBul1) cfa.cyberbullying_involvement_action_2_factors_test <- cfa( modello_cyberbullying_action_2_factors_test, dati_test %>% mutate_at(.vars = 8:13, as.ordered), ordered = str_c("CybBul", 1:6, sep = "") ) # as.numeric summary(cfa.cyberbullying_involvement_action_2_factors_test, fit.measures=TRUE, standardized = TRUE) # # CFA modello 1 fattore (Bauman) su test ----- modello_cyberbullying_action_1_factor_test <- ' cyberbullying =~ CybBul1 + CybBul2 + CybBul3 + CybBul4 + CybBul5 + CybBul6 ' #is.ordered(dati_ileana_2$CybBul1) cfa.cyberbullying_involvement_action_1_factor_test <- cfa( modello_cyberbullying_action_1_factor_test, dati_test %>% mutate_at(.vars = 8:13, as.ordered), ordered = str_c("CybBul", 1:6, sep = "")#%>% View() ) # as.numeric summary(cfa.cyberbullying_involvement_action_1_factor_test, fit.measures=TRUE, standardized = TRUE) # tibble( measure = names(fitMeasures(cfa.cyberbullying_involvement_action_1_factor_test)), single_factor = round(fitMeasures(cfa.cyberbullying_involvement_action_1_factor_test), digits = 3), two_Factor = round(fitMeasures(cfa.cyberbullying_involvement_action_2_factors_test), digits = 3) ) %>% View() # 2 factor model has better fit on the test data. # conclusions: the 2 factor model suggested by the EFA on the train dataset had a better fit than the single factor model on the test dataset # SEM personality observed ---- # Definizione modelli ---- # modello con mediazione di MD su cyb1 e 2, e parametri effetti diretti, indiretti e totali modello_cyberbullying_action_sem_2_factors_full_no_personality <- ' cyberbullying_1 =~ CybBul1 + CybBul2 + CybBul4 cyberbullying_2 =~ CybBul3 + CybBul5 + CybBul6 Moral_disengagement =~ MD1 + MD2 + MD3 + MD4 + MD5 + MD6 + MD7 + MD8 cyberbullying_1 ~ a1*agreeableness + c1*conscientiousness + n1*nevroticism + o1*openness + e1*extraversion + Nervoso_senza_internet + md1*Moral_disengagement cyberbullying_2 ~ a2*agreeableness + c2*conscientiousness + n2*nevroticism + o2*openness + e2*extraversion + Nervoso_senza_internet + md2*Moral_disengagement # Moral_disengagement ~ amd*agreeableness + cmd*conscientiousness + nmd*nevroticism + omd*openness + emd*extraversion # # indirect effects a_md_1 := amd*md1 c_md_1 := cmd*md1 n_md_1 := nmd*md1 o_md_1 := omd*md1 e_md_1 := emd*md1 a_md_2 := amd*md2 c_md_2 := cmd*md2 n_md_2 := nmd*md2 o_md_2 := omd*md2 e_md_2 := emd*md2 # total effects a_1 := a_md_1 + a1 c_1 := c_md_1 + c1 n_1 := n_md_1 + n1 o_1 := o_md_1 + o1 e_1 := e_md_1 + e1 a_2 := a_md_2 + a2 c_2 := c_md_2 + c2 n_2 := n_md_2 + n2 o_2 := o_md_2 + o2 e_2 := e_md_2 + e2 # differenze effetti su fattori df_a := a1 - a2 df_c := c1 - c2 df_n := n1 - n2 df_o := o1 - o2 df_e := e1 - e2 df_md := md1 - md2 ' # con effetti indiretti stimati permettendo coefficienti path diversi per ogni gruppi nelle analisi multigruppo modello_cyberbullying_action_sem_2_factors_full_no_personality_2 <- ' cyberbullying_1 =~ CybBul1 + CybBul2 + CybBul4 cyberbullying_2 =~ CybBul3 + CybBul5 + CybBul6 Moral_disengagement =~ MD1 + MD2 + MD3 + MD4 + MD5 + MD6 + MD7 + MD8 cyberbullying_1 ~ c(a1a,a1b)*agreeableness + c(c1a,c1b)*conscientiousness + c(n1a,n1b)*nevroticism + c(o1a,o1b)*openness + c(e1a,e1b)*extraversion + c(nrv1a,nrv1b)*Nervoso_senza_internet + c(md1a,md1b)*Moral_disengagement cyberbullying_2 ~ c(a2a,a2b)*agreeableness + c(c2a,c2b)*conscientiousness + c(n2a,n2b)*nevroticism + c(o2a,o2b)*openness + c(e2a,e2b)*extraversion + c(nrv2a,nrv2b)*Nervoso_senza_internet + c(md2a,md2b)*Moral_disengagement # Moral_disengagement ~ c(amd_a,amd_b)*agreeableness + c(cmd_a,cmd_b)*conscientiousness + c(nmd_a,nmd_b)*nevroticism + c(omd_a,omd_b)*openness + c(emd_a,emd_b)*extraversion # # moderator effects mod_md_cy1 := md1b - md1a mod_a_cy1 := a1b - a1a mod_c_cy1 := c1b - c1a mod_n_cy1 := n1b - n1a mod_o_cy1 := o1b - o1a mod_e_cy1 := e1b - e1a mod_nrv_cy1 := nrv1b - nrv1a mod_md_cy2 := md2b - md2a mod_a_cy2 := a2b - a2a mod_c_cy2 := c2b - c2a mod_n_cy2 := n2b - n2a mod_o_cy2 := o2b - o2a mod_e_cy2 := e2b - e2a mod_nrv_cy2 := nrv2b - nrv2a mod_a_md := amd_b - amd_a mod_c_md := cmd_b - cmd_a mod_n_md := nmd_b - nmd_a mod_o_md := omd_b - omd_a mod_e_md := emd_b - emd_a # indirect effects a_md_1a := amd_a*md1a c_md_1a := cmd_a*md1a n_md_1a := nmd_a*md1a o_md_1a := omd_a*md1a e_md_1a := emd_a*md1a a_md_1b := amd_b*md1b c_md_1b := cmd_b*md1b n_md_1b := nmd_b*md1b o_md_1b := omd_b*md1b e_md_1b := emd_b*md1b a_md_2a := amd_a*md2a c_md_2a := cmd_a*md2a n_md_2a := nmd_a*md2a o_md_2a := omd_a*md2a e_md_2a := emd_a*md2a a_md_2b := amd_b*md2b c_md_2b := cmd_b*md2b n_md_2b := nmd_b*md2b o_md_2b := omd_b*md2b e_md_2b := emd_b*md2b # total effects a_1a := a_md_1a + a1a c_1a := c_md_1a + c1a n_1a := n_md_1a + n1a o_1a := o_md_1a + o1a e_1a := e_md_1a + e1a a_1b := a_md_1b + a1b c_1b := c_md_1b + c1b n_1b := n_md_1b + n1b o_1b := o_md_1b + o1b e_1b := e_md_1b + e1b a_2a := a_md_2a + a2a c_2a := c_md_2a + c2a n_2a := n_md_2a + n2a o_2a := o_md_2a + o2a e_2a := e_md_2a + e2a a_2b := a_md_2b + a2b c_2b := c_md_2b + c2b n_2b := n_md_2b + n2b o_2b := o_md_2b + o2b e_2b := e_md_2b + e2b # moderated mediation mod_ind_n_md_cy1 := n_md_1a - n_md_1b mod_ind_n_md_cy2 := n_md_2a - n_md_2b mod_ind_c_md_cy1 := c_md_1a - c_md_1b mod_ind_c_md_cy2 := c_md_2a - c_md_2b mod_ind_e_md_cy1 := e_md_1a - e_md_1b mod_ind_e_md_cy2 := e_md_2a - e_md_2b mod_ind_o_md_cy1 := o_md_1a - o_md_1b mod_ind_o_md_cy2 := o_md_2a - o_md_2b ' # senza parametri effetti indiretti per analisi multigruppo modello_cyberbullying_action_sem_2_factors_full_no_personality_3 <- ' cyberbullying_1 =~ CybBul1 + CybBul2 + CybBul4 cyberbullying_2 =~ CybBul3 + CybBul5 + CybBul6 Moral_disengagement =~ MD1 + MD2 + MD3 + MD4 + MD5 + MD6 + MD7 + MD8 cyberbullying_1 ~ agreeableness + conscientiousness + nevroticism + openness + extraversion + Nervoso_senza_internet + Moral_disengagement cyberbullying_2 ~ agreeableness + conscientiousness + nevroticism + openness + extraversion + Nervoso_senza_internet + Moral_disengagement # Moral_disengagement ~ agreeableness + conscientiousness + nevroticism + openness + extraversion # ' dati_SEM_full[indici_completi_all, ] %>% filter(!is.na(Nervoso_senza_internet)) %>% names() # Single group SEM (reported in revision) ---- sem.cyberbullying_involvement_action_2_factors_full_no_personality <- sem( modello_cyberbullying_action_sem_2_factors_full_no_personality, dati_SEM_full[indici_completi_all, ] %>% filter(!is.na(Nervoso_senza_internet)) %>% mutate(nevroticism = 6 - nevroticism), ordered = c(str_c("CybBul", 1:6, sep = ""), str_c("MD", 1:8, sep = ""), str_c("BFI", 1:10, sep = "")) ) summary(sem.cyberbullying_involvement_action_2_factors_full_no_personality, fit.measures=TRUE, standardized = TRUE, rsquare = TRUE) # very god fit fitMeasures(sem.cyberbullying_involvement_action_2_factors_full_no_personality, fit.indices) fitMeasures(sem.cyberbullying_involvement_action_2_factors_full_no_personality) sem.cyberbullying_involvement_action_2_factors_full_no_personality_b <- sem( modello_cyberbullying_action_sem_2_factors_full_no_personality, dati_SEM_full[indici_completi_all, ] %>% filter(!is.na(Nervoso_senza_internet)) %>% mutate(nevroticism = 6 - nevroticism), ordered = c(str_c("CybBul", 1:6, sep = ""), str_c("MD", 1:8, sep = ""), str_c("BFI", 1:10, sep = "")) ) summary(sem.cyberbullying_involvement_action_2_factors_full_no_personality, fit.measures=TRUE, standardized = TRUE, rsquare = TRUE) # very god fit fitMeasures(sem.cyberbullying_involvement_action_2_factors_full_no_personality_b, fit.indices) fitMeasures(sem.cyberbullying_involvement_action_2_factors_full_no_personality_b) # strano che sia negativo l'effetto del neuroticismo cor.test(dati_SEM_full$nevroticism, dati_SEM_full$MD_mean) # test indirect effect of conscientiousness on cyb via internet addiction. modello_cyberbullying_action_sem_2_factors_full_no_personality_c <- paste0( modello_cyberbullying_action_sem_2_factors_full_no_personality, ' Nervoso_senza_internet ~ conscientiousness ' ) sem.cyberbullying_involvement_action_2_factors_full_no_personality_c <- sem( modello_cyberbullying_action_sem_2_factors_full_no_personality_c, dati_SEM_full[indici_completi_all, ] %>% filter(!is.na(Nervoso_senza_internet)) %>% mutate(nevroticism = 6 - nevroticism), ordered = c(str_c("CybBul", 1:6, sep = ""), str_c("MD", 1:8, sep = ""), str_c("BFI", 1:10, sep = "")) ) summary(sem.cyberbullying_involvement_action_2_factors_full_no_personality_c, fit.measures=TRUE, standardized = TRUE, rsquare = TRUE) # very god fit fitMeasures(sem.cyberbullying_involvement_action_2_factors_full_no_personality_c, fit.indices) # Multigruppo GENERE ---- sem.cyberbullying_involvement_action_2_factors_full_no_personality_gender <- sem( modello_cyberbullying_action_sem_2_factors_full_no_personality_3, dati_SEM_full[indici_completi_all, ] %>% filter(!is.na(Nervoso_senza_internet)), ordered = c(str_c("CybBul", 1:6, sep = ""), str_c("MD", 1:8, sep = ""), str_c("BFI", 1:10, sep = "")), group = "Genere" ) # 168 parameters summary(sem.cyberbullying_involvement_action_2_factors_full_no_personality_gender, fit.measures=TRUE, standardized = TRUE, rsquare = TRUE) # very god fit fitMeasures(sem.cyberbullying_involvement_action_2_factors_full_no_personality_gender, fit.indices) # so so fitMeasures(sem.cyberbullying_involvement_action_2_factors_full_no_personality_gender) sem.cyberbullying_involvement_action_2_factors_full_no_personality_gender1 <- sem( modello_cyberbullying_action_sem_2_factors_full_no_personality_3, dati_SEM_full[indici_completi_all, ] %>% filter(!is.na(Nervoso_senza_internet)), ordered = c(str_c("CybBul", 1:6, sep = ""), str_c("MD", 1:8, sep = ""), str_c("BFI", 1:10, sep = "")), group = "Genere", group.equal = c("loadings") ) # 168 parameters 11 equality constraints summary(sem.cyberbullying_involvement_action_2_factors_full_no_personality_gender1, fit.measures=TRUE, standardized = TRUE, rsquare = TRUE) # ok fit fitMeasures(sem.cyberbullying_involvement_action_2_factors_full_no_personality_gender1, fit.indices) # so so, not better anova(sem.cyberbullying_involvement_action_2_factors_full_no_personality_gender, sem.cyberbullying_involvement_action_2_factors_full_no_personality_gender1) # ns weak invariance holds # refit with moderators parameters (emotioinal stability) REPORTED in plot in SM 4 sem.cyberbullying_involvement_action_2_factors_full_no_personality_gender2mod <- sem( modello_cyberbullying_action_sem_2_factors_full_no_personality_2, dati_SEM_full[indici_completi_all, ] %>% filter(!is.na(Nervoso_senza_internet)) %>% mutate(nevroticism = 6 - nevroticism), ordered = c(str_c("CybBul", 1:6, sep = ""), str_c("MD", 1:8, sep = ""), str_c("BFI", 1:10, sep = "")), group = "Genere", group.equal = c("loadings", "intercepts") ) # 185 parameters 61 equality constraints !!! con "intercepts", 11 constr. con "means" "thresholds" summary(sem.cyberbullying_involvement_action_2_factors_full_no_personality_gender2mod, fit.measures=TRUE, standardized = TRUE, rsquare = TRUE) # differenze medie di cyb 1 (male > f) e moral disengagement (m > f) fitMeasures(sem.cyberbullying_involvement_action_2_factors_full_no_personality_gender2mod, fit.indices) # better # moderazione di gender sull'effetto di o -> cyb1 (-) e di e -> cy2 (+) anova(sem.cyberbullying_involvement_action_2_factors_full_no_personality_gender, sem.cyberbullying_involvement_action_2_factors_full_no_personality_gender1, sem.cyberbullying_involvement_action_2_factors_full_no_personality_gender2mod) #! REPORTED IN SM 4 # Multigruppo TEMPO SUI SOCIAL ---- # unconstrained model sem.cyberbullying_involvement_action_2_factors_full_no_personality_tempo <- sem( modello_cyberbullying_action_sem_2_factors_full_no_personality_3, dati_SEM_full[indici_completi_all, ] %>% filter(!is.na(Nervoso_senza_internet)) %>% filter(Tempo_sui_social != "Meno di 1 ora al giorno"), ordered = c(str_c("CybBul", 1:6, sep = ""), str_c("MD", 1:8, sep = ""), str_c("BFI", 1:10, sep = "")), group = "Tempo_sui_social" ) # 168 parameters summary(sem.cyberbullying_involvement_action_2_factors_full_no_personality_tempo, fit.measures=TRUE, standardized = TRUE, rsquare = TRUE) # quite god fit fitMeasures(sem.cyberbullying_involvement_action_2_factors_full_no_personality_tempo, fit.indices) # quite god fit, configural invariance holds fitMeasures(sem.cyberbullying_involvement_action_2_factors_full_no_personality_gender) # constrained loadings (test weak invariance) sem.cyberbullying_involvement_action_2_factors_full_no_personality_tempo1 <- sem( modello_cyberbullying_action_sem_2_factors_full_no_personality_3, dati_SEM_full[indici_completi_all, ] %>% filter(!is.na(Nervoso_senza_internet)) %>% filter(Tempo_sui_social != "Meno di 1 ora al giorno"), ordered = c(str_c("CybBul", 1:6, sep = ""), str_c("MD", 1:8, sep = ""), str_c("BFI", 1:10, sep = "")), group = "Tempo_sui_social", group.equal = c("loadings") ) # 168 parameters, 11 contraints summary(sem.cyberbullying_involvement_action_2_factors_full_no_personality_tempo1, fit.measures=TRUE, standardized = TRUE, rsquare = TRUE) # quite god fit fitMeasures(sem.cyberbullying_involvement_action_2_factors_full_no_personality_tempo1, fit.indices) # quite god fit, same as before anova(sem.cyberbullying_involvement_action_2_factors_full_no_personality_tempo, sem.cyberbullying_involvement_action_2_factors_full_no_personality_tempo1) # NS, weak invariance holds # constrained loadings and intercepts (test strong invariance) sem.cyberbullying_involvement_action_2_factors_full_no_personality_tempo2 <- sem( modello_cyberbullying_action_sem_2_factors_full_no_personality_3, dati_SEM_full[indici_completi_all, ] %>% filter(!is.na(Nervoso_senza_internet)) %>% filter(Tempo_sui_social != "Meno di 1 ora al giorno"), ordered = c(str_c("CybBul", 1:6, sep = ""), str_c("MD", 1:8, sep = ""), str_c("BFI", 1:10, sep = "")), group = "Tempo_sui_social", group.equal = c("loadings", "intercepts") ) # 185 parameters, 61 constraints summary(sem.cyberbullying_involvement_action_2_factors_full_no_personality_tempo2, fit.measures=TRUE, standardized = TRUE, rsquare = TRUE) # quite god fit, interecette LV non diverse tra i gruppi. # non differenze significative medie di cyb 1, 2 o moral disengagement (m > f) fitMeasures(sem.cyberbullying_involvement_action_2_factors_full_no_personality_tempo2, fit.indices) # better fit anova(sem.cyberbullying_involvement_action_2_factors_full_no_personality_tempo, sem.cyberbullying_involvement_action_2_factors_full_no_personality_tempo1, sem.cyberbullying_involvement_action_2_factors_full_no_personality_tempo2) # NS,ma c'è un problema nel confronto, il modello 2 ha più parametri del modello 1, non meno come dovrebbe essere se è annidato # refit with moderators (neuroticismo è in realtà emotional stability) sem.cyberbullying_involvement_action_2_factors_full_no_personality_tempo2mod <- sem( modello_cyberbullying_action_sem_2_factors_full_no_personality_2, dati_SEM_full[indici_completi_all, ] %>% filter(!is.na(Nervoso_senza_internet)) %>% filter(Tempo_sui_social != "Meno di 1 ora al giorno") %>% mutate(nevroticism = 6 - nevroticism), ordered = c(str_c("CybBul", 1:6, sep = ""), str_c("MD", 1:8, sep = ""), str_c("BFI", 1:10, sep = "")), group = "Tempo_sui_social", group.equal = c("loadings", "intercepts") ) # 185 parameters, 61 constraints summary(sem.cyberbullying_involvement_action_2_factors_full_no_personality_tempo2mod, fit.measures=TRUE, standardized = TRUE, rsquare = TRUE) # quite god fit, intercette LV non diverse tra i gruppi. # non differenze significative medie di cyb 1, 2 o moral disengagement (m > f) fitMeasures(sem.cyberbullying_involvement_action_2_factors_full_no_personality_tempo2mod, fit.indices) anova(sem.cyberbullying_involvement_action_2_factors_full_no_personality_tempo, sem.cyberbullying_involvement_action_2_factors_full_no_personality_tempo1, sem.cyberbullying_involvement_action_2_factors_full_no_personality_tempo2mod) # NS,ma c'è un problema nel confronto, il modello 2 ha più parametri del modello 1, non meno come dovrebbe essere se è annidato # Multigruppo N PROFILI ---- # unconstrained model sem.cyberbullying_involvement_action_2_factors_full_no_personality_profili <- sem( modello_cyberbullying_action_sem_2_factors_full_no_personality_3, dati_SEM_full[indici_completi_all, ] %>% filter(!is.na(Nervoso_senza_internet)) %>% filter(Tempo_sui_social != "Meno di 1 ora al giorno"), ordered = c(str_c("CybBul", 1:6, sep = ""), str_c("MD", 1:8, sep = ""), str_c("BFI", 1:10, sep = "")), group = "N_profili_social" ) summary(sem.cyberbullying_involvement_action_2_factors_full_no_personality_profili, fit.measures=TRUE, standardized = TRUE, rsquare = TRUE) # quite god fit fitMeasures(sem.cyberbullying_involvement_action_2_factors_full_no_personality_profili, fit.indices) # decent fit # loadings sem.cyberbullying_involvement_action_2_factors_full_no_personality_profili1 <- sem( modello_cyberbullying_action_sem_2_factors_full_no_personality_3, dati_SEM_full[indici_completi_all, ] %>% filter(!is.na(Nervoso_senza_internet)) %>% filter(Tempo_sui_social != "Meno di 1 ora al giorno"), ordered = c(str_c("CybBul", 1:6, sep = ""), str_c("MD", 1:8, sep = ""), str_c("BFI", 1:10, sep = "")), group = "N_profili_social", group.equal = c("loadings") ) summary(sem.cyberbullying_involvement_action_2_factors_full_no_personality_profili1, fit.measures=TRUE, standardized = TRUE, rsquare = TRUE) # quite god fit fitMeasures(sem.cyberbullying_involvement_action_2_factors_full_no_personality_profili1, fit.indices) anova(sem.cyberbullying_involvement_action_2_factors_full_no_personality_profili, sem.cyberbullying_involvement_action_2_factors_full_no_personality_profili1) # NS # loadings + intercepts sem.cyberbullying_involvement_action_2_factors_full_no_personality_profili2 <- sem( modello_cyberbullying_action_sem_2_factors_full_no_personality_3, dati_SEM_full[indici_completi_all, ] %>% filter(!is.na(Nervoso_senza_internet)) %>% filter(Tempo_sui_social != "Meno di 1 ora al giorno"), ordered = c(str_c("CybBul", 1:6, sep = ""), str_c("MD", 1:8, sep = ""), str_c("BFI", 1:10, sep = "")), group = "N_profili_social", group.equal = c("loadings", "intercepts") ) summary(sem.cyberbullying_involvement_action_2_factors_full_no_personality_profili2, fit.measures=TRUE, standardized = TRUE, rsquare = TRUE) # quite god fit # moral disengagement > fitMeasures(sem.cyberbullying_involvement_action_2_factors_full_no_personality_profili2, fit.indices) anova( sem.cyberbullying_involvement_action_2_factors_full_no_personality_profili, sem.cyberbullying_involvement_action_2_factors_full_no_personality_profili1, sem.cyberbullying_involvement_action_2_factors_full_no_personality_profili2) # NS # refit for moderated mediation analysis (REPORTED in PLOT in SM 4) sem.cyberbullying_involvement_action_2_factors_full_no_personality_profili2mod <- sem( modello_cyberbullying_action_sem_2_factors_full_no_personality_2, dati_SEM_full[indici_completi_all, ] %>% filter(!is.na(Nervoso_senza_internet)) %>% filter(Tempo_sui_social != "Meno di 1 ora al giorno")%>% mutate(nevroticism = 6 - nevroticism), ordered = c(str_c("CybBul", 1:6, sep = ""), str_c("MD", 1:8, sep = ""), str_c("BFI", 1:10, sep = "")), group = "N_profili_social", group.equal = c("loadings", "intercepts") ) summary(sem.cyberbullying_involvement_action_2_factors_full_no_personality_profili2mod, fit.measures=TRUE, standardized = TRUE, rsquare = TRUE) # quite god fit # moral disengagement > fitMeasures(sem.cyberbullying_involvement_action_2_factors_full_no_personality_profili2mod, fit.indices) anova( sem.cyberbullying_involvement_action_2_factors_full_no_personality_profili, sem.cyberbullying_involvement_action_2_factors_full_no_personality_profili1, sem.cyberbullying_involvement_action_2_factors_full_no_personality_profili2mod) # NS