File: 3_Regression analyses.R

Comment: create dummy variables gender
Category: Data Variable
Code:
Sample2$Dfemale <- recode(Sample2$gender, "'weiblich'=1;; 'maennlich'=0;; 'divers'=0;; 'keine Angabe'=0") Sample2$Dmale <- recode(Sample2$gender, "'maennlich'=1;; 'weiblich'=0;; 'divers'=0;; 'keine Angabe'=0") Sample2$Ddiverse <- recode(Sample2$gender, "'divers'=1;; 'weiblich'=0;; 'maennlich'=0;; 'keine Angabe'=0") Sample2$DNoGenderInd <- recode(Sample2$gender, "'keine Angabe'=1;;'weiblich'=0;; 'maennlich'=0;; 'divers'=0") Sample2$DComplianceFully <- recode(Sample2$complianceCurrent, "'Ja'=1;; 'Ja, teilweise'=0;; 'Nein auch zuvor nicht'=0;; 'Nein, nicht mehr'=0") Sample2$DCompliancePartly <- recode(Sample2$complianceCurrent, "'Ja'=0;; 'Ja, teilweise'=1;; 'Nein auch zuvor nicht'=0;; 'Nein, nicht mehr'=0") Sample2$DComplianceNever <- recode(Sample2$complianceCurrent, "'Ja'=0;; 'Ja, teilweise'=0;; 'Nein auch zuvor nicht'=1;; 'Nein, nicht mehr'=0") Sample2$DComplianceNotAnymore <- recode(Sample2$complianceCurrent, "'Ja'=0;; 'Ja, teilweise'=0;; 'Nein auch zuvor nicht'=0;; 'Nein, nicht mehr'=1")

Comment: Plots Anxiety main effects LISD
Category: Visualization
Code:
ggplot(Sample2_Reg,aes(y=Anxiety,x=z_LISD_State_F1))+ geom_point(color = "indianred4")+geom_smooth(method="lm", color = "black", size = 0.5)+theme_classic() ggplot(Sample2_Reg,aes(y=Anxiety,x=z_LISD_Trait_F1))+ geom_point(color = "indianred4")+geom_smooth(method="lm", color = "black", size = 0.5)+theme_classic() ggplot(Sample2_Reg,aes(y=Anxiety,x=z_LISD_Trait_F2))+ geom_point(color = "indianred4")+geom_smooth(method="lm", color = "black", size = 0.5)+theme_classic()

Comment: Plots Depressed plot preparation: divide z_age into SD, mean, +SD
Category: Visualization
Code:
attach(Sample2_Reg) Sample2_Reg$age_3groups <- case_when(z_age > mean(z_age)+sd(z_age) ~ "high", z_age < mean(z_age)+sd(z_age) & z_age > mean(z_age)-sd(z_age) ~ "mean", z_age < mean(z_age)-sd(z_age) ~ "low") detach(Sample2_Reg)

Comment: Plots Manuscript Plots Manuscript with raw WLISD scores Anxiety
Category: Visualization
Code:
plot1_1 <- Sample2_Reg %>% ggplot(aes(x = LISD_State_F1, y = Anxiety)) + geom_point(color = "#00AFBB")+ geom_smooth(method = lm, color = "black", size = 0.5)+ xlim(1,5)+ ylim(-2,3)+ labs(x = "lonely & isolated (State 1)", y = "Anxiety (z)", Title = "State Factor 1")+ theme_classic() plot2_1 <- Sample2_Reg %>% ggplot(aes(x = LISD_State_F2, y = Anxiety)) + geom_point(color = "#55C667FF")+ geom_smooth(method = lm, color = "black", size = 0.5)+ xlim(1,5)+ ylim(-2,3)+ labs(x = "supported & connected (State 2)", y = "Anxiety (z)", Title = "State Factor 2")+ theme_classic() plot3_1 <- Sample2_Reg %>% ggplot(aes(x = LISD_Trait_F1, y = Anxiety)) + geom_point(color = "#E7B800")+ geom_smooth(method = lm, color = "black", size = 0.5)+ xlim(1,5)+ ylim(-2,3)+ labs(x = "loneliness & isolation (Trait 1)", y = "Anxiety (z)", Title = "Trait Factor 1")+ theme_classic() plot4_1 <- Sample2_Reg %>% ggplot(aes(x = LISD_Trait_F2, y = Anxiety)) + geom_point(color = "#FC4E07")+ geom_smooth(method = lm, color = "black", size = 0.5)+ xlim(1,5)+ ylim(-2,3)+ labs(x = "sociability & sense of belonging (Trait 2)", y = "Anxiety (z)", Title = "Trait Factor 1")+ theme_classic() plot1_1 plot2_1 plot3_1 plot4_1