#S1 Text. R code used for the analyses ## This script first restricts the dataset to participants who filled out # information for PS/PVG/demographic info. Then it models relationships # between PS/PVG and associated measures, as well as STRAT/GTRAT. Next, # it assesses the effect of PS on relationships between PVG and associated # health correlates. # # Start by uploading dataset rm(list=ls()) df <- read.csv("C:/Users/13473/Desktop/Behavioral Addictions Research/dataset_PLoS_Release_3.csv") list(df) df summary(df) # # Start with preparing demographic variables for easy interpretation # Prepare grade: grade was recorded in q5 as 1 = grade 9, 2 = grade10, # 3 = grade11, 4 = grade 12. Here, we create new constructs for each grade df$grade<- as.factor(df$q5) df$grade9 <- ifelse((df$q5==1), 1, 0) df$grade9 [is.na(df$q5)] <- NA df$grade10 <- ifelse((df$q5==2), 1, 0) df$grade10 [is.na(df$q5)] <- NA df$grade11 <- ifelse((df$q5==3), 1, 0) df$grade11 [is.na(df$q5)] <- NA df$grade12 <- ifelse((df$q5==4), 1, 0) df$grade12 [is.na(df$q5)] <- NA df$grade9 <- as.factor(df$grade9) df$grade10 <- as.factor(df$grade10) df$grade11 <- as.factor(df$grade11) df$grade12 <- as.factor(df$grade12) # Prepare sex as factor: sex recorded in q2- answer 1 = Male, 2 = female df$sex<- as.factor(df$q2) # # Prepare family structure: recorded in q9 as 1 = Two parents, 2 = One parent, # 3= Foster family, 4 = grandparents, 5 = other relatives, 6 = other # reclassified family structure as single parent, two parents and other. df$q9 [(df$q9 == 1)] <- "1Two Parents" df$q9 [(df$q9 == 2)] <- "2One Parent" df$q9 [(df$q9 == 3) | (df$q9 == 4) | (df$q9 == 5) |(df$q9 == 6)] <- "3Other" df$family <- as.factor(df$q9) df$family # #Prepare data for regression: Ethnicity # Q3 asked for racial background with q3a = Black, q3b = White, q3c = Asian # q3d = other. then asked for Other to specify. Next, q4 asked if hispanic/latino # with 1 = yes, 2 = no. # Here, if the particular race was not marked and another race was marked, # the corresponding field was labeled "no" with a 0 (but only if another race # was marked. If the question was skipped altogether, then the field was not # filled in with a 0, and that participant will soon be excluded.) df$q4 [(df$q3a ==1) | (df$q3b == 1) | (df$q3c == 1)| (df$q4 == 2)] <- 0 df$q3a [(df$q3b == 1) | (df$q3c == 1) | (df$q3d == 1) | (df$q4 ==1)]<- 0 df$q3b [(df$q3a == 1) | (df$q3c == 1) | (df$q3d == 1) | (df$q4 ==1)]<- 0 df$q3c [(df$q3a == 1) | (df$q3b == 1) | (df$q3d == 1) | (df$q4 ==1)]<- 0 df$q3d [(df$q3a == 1) | (df$q3b == 1) | (df$q3c == 1) | (df$q4 ==1)]<- 0 df$hisp<- as.factor(df$q4) df$black<- as.factor(df$q3a) df$white<- as.factor(df$q3b) df$asian<- as.factor(df$q3c) df$other<- as.factor(df$q3d) # remove participants who excluded ethnicity, family structure, sex, and # grade level. df<- subset(df, (!is.na(df$hisp))) df<- subset(df, (!is.na(df$white))) df<- subset(df, (!is.na(df$black))) df<- subset(df, (!is.na(df$asian))) df<- subset(df, (!is.na(df$other))) df<- subset(df, (!is.na(df$family))) df<- subset(df, (!is.na(df$sex))) df<- subset(df, (!is.na(df$grade))) # #Missing Demographic Data (4524--> 4339) ##################################################################################### ##################################################################################### # Now, we organize shopping data. First create a new dataframe in case mistakes are made. # Next, question q114 asks whether a person shops. If not, then all the associated # shopping questions were designated as "0", or "no". # Shopping questions were as follows: # q115 = cutting back, 116 = family concern, 117= missing activities, # 118 = problem with shopping, 119 = urges to shop, 120 = anxiety/tension # PS was defined as answering yes (1) to q115, q119, and q120. Participants # missing PS questions excluded dfPS<- df dfPS$q115 [dfPS$q114 == 1] <- 0 dfPS$q116 [dfPS$q114 == 1] <- 0 dfPS$q117 [dfPS$q114 == 1] <- 0 dfPS$q118 [dfPS$q114 == 1] <- 0 dfPS$q119 [dfPS$q114 == 1] <- 0 dfPS$q120 [dfPS$q114 == 1] <- 0 # PS defined as endorsing attempt to cut back, urge, and tension (115, 119, 120) dfPS<-subset(dfPS, ((!is.na(dfPS$q115)))) dfPS<-subset(dfPS, ((!is.na(dfPS$q119)))) dfPS<-subset(dfPS, ((!is.na(dfPS$q120)))) dfPS$PS <- ifelse((dfPS$q115 == 1) & (dfPS$q119 == 1) & (dfPS$q120 == 1), 1, 0) dfPS<-subset(dfPS, ((!is.na(dfPS$PS)))) # Answering yes to shopping to relieve anxiety/tension is designated as STRA dfPS$STRA <- ifelse ((dfPS$q120 == 1), 1, 0) # # # # Now, we organize gaming data. # Next, question q130 asks whether a person games. If not, then all the associated # gaming questions were designated as "0", or "no". # gaming questions were as follows: # q131 = cutting back, 132 = family concern, 133= missing activities, # 134 = problem with shopping, 135 = urges to shop, 136 = anxiety/tension # PVG was defined as answering yes (1) to q131, q135, and q136. Participants # who didn't answer PVG questions were excluded dfPS$q131 [dfPS$q130 == 1] <- 0 dfPS$q132 [dfPS$q130 == 1] <- 0 dfPS$q133 [dfPS$q130 == 1] <- 0 dfPS$q134 [dfPS$q130 == 1] <- 0 dfPS$q135 [dfPS$q130 == 1] <- 0 dfPS$q136 [dfPS$q130 == 1] <- 0 # # #Change all "No"s to 0 dfPS$q131 [dfPS$q131 == 2] <- 0 dfPS$q132 [dfPS$q132 == 2] <- 0 dfPS$q133 [dfPS$q133 == 2] <- 0 dfPS$q134 [dfPS$q134 == 2] <- 0 dfPS$q135 [dfPS$q135 == 2] <- 0 dfPS$q136 [dfPS$q136 == 2] <- 0 # dfVG<- dfPS dfVG<-subset(dfVG, ((!is.na(dfVG$q131)))) dfVG<-subset(dfVG, ((!is.na(dfVG$q132)))) dfVG<-subset(dfVG, ((!is.na(dfVG$q133)))) dfVG<-subset(dfVG, ((!is.na(dfVG$q134)))) dfVG<-subset(dfVG, ((!is.na(dfVG$q135)))) dfVG<-subset(dfVG, ((!is.na(dfVG$q136)))) # # dfVG$VG <- ifelse((dfVG$q131 == 1) & (dfVG$q135 == 1) & (dfVG$q136 == 1), 1, 0) dfVG<-subset(dfVG, ((!is.na(dfVG$VG)))) dfPS<-dfVG # Final Dataset: 3657 students # # ######################################################################################## ######################################################################################## ######################################################################################## # Demographic data for each condition df<-dfPS #chi square analyses used for demographic features of PVG tbl1<- table("sex"= df$q2, "VG" = df$VG) tbl2<-table("grade"= df$q5,"VG" = df$VG) tbl3<-table("family"= df$q9, "VG" = df$VG) tbl4<-table("hisp"= df$hisp, "VG" = df$VG) tbl5<-table("asian"= df$asian, "VG" = df$VG) tbl6<-table("white"= df$white, "VG" = df$VG) tbl7<-table("black"= df$black, "VG" = df$VG) tbl8<-table("other"= df$other, "VG" = df$VG) tbl9<-table("PS"= df$PS, "VG" = df$VG) tbl10<- table("STRA" = df$STRA, "VG" = df$VG) # # # VgDemos<- capture.output( tbl1, chisq.test(tbl1), tbl2, chisq.test(tbl2), tbl3, chisq.test(tbl3), fisher.test(tbl3), tbl4, chisq.test(tbl4), tbl5, chisq.test(tbl5), fisher.test(tbl5), tbl6, chisq.test(tbl6), tbl7, chisq.test(tbl7), tbl8, chisq.test(tbl8), fisher.test(tbl8), tbl9, chisq.test(tbl9), fisher.test(tbl9), tbl10, chisq.test(tbl10) ) cat("PS_Demos", VgDemos, file="C:/Users/13473/Desktop/Behavioral Addictions Research/VG_Demos_New.txt", sep="\n", append=FALSE) # #chi square analyses determined for PS tbl1<- table("sex"= df$q2, "PS" = df$PS) tbl2<-table("grade"= df$q5,"PS" = df$PS) tbl3<-table("family"= df$q9, "PS" = df$PS) tbl4<-table("hisp"= df$hisp, "PS" = df$PS) tbl5<-table("asian"= df$asian, "PS" = df$PS) tbl6<-table("white"= df$white, "PS" = df$PS) tbl7<-table("black"= df$black, "PS" = df$PS) tbl8<-table("other"= df$other, "PS" = df$PS) tbl9<-table("VG"= df$VG, "PS" = df$PS) tbl10<-table("STRA"= df$STRA, "PS" = df$PS) # # # PsDemos<- capture.output( tbl1, chisq.test(tbl1), tbl2, chisq.test(tbl2), tbl3, chisq.test(tbl3), tbl4, chisq.test(tbl4), tbl5, chisq.test(tbl5), tbl6, chisq.test(tbl6), tbl7, chisq.test(tbl7), tbl8, chisq.test(tbl8), tbl9, chisq.test(tbl9), tbl10, chisq.test(tbl10) ) cat("PS_Demos", PsDemos, file="C:/Users/13473/Desktop/Behavioral Addictions Research/PS_Demos_New.txt", sep="\n", append=FALSE) # ########################################################################################### ### # #Demographics for STRA # #chi square analyses for demographics of sTRA groups tbl1<- table("sex"= df$q2, "STRA" = df$STRA) tbl2<-table("grade"= df$q5,"STRA" = df$STRA) tbl3<-table("family"= df$q9, "STRA" = df$STRA) tbl4<-table("hisp"= df$hisp, "STRA" = df$STRA) tbl5<-table("asian"= df$asian, "STRA" = df$STRA) tbl6<-table("white"= df$white, "STRA" = df$STRA) tbl7<-table("black"= df$black, "STRA" = df$STRA) tbl8<-table("other"= df$other, "STRA" = df$STRA) tbl9<-table("VG"= df$VG, "STRA" = df$STRA) tbl10<-table("PS"= df$PS, "STRA" = df$STRA) # # # STRADemos<- capture.output( tbl1, chisq.test(tbl1), tbl2, chisq.test(tbl2), tbl3, chisq.test(tbl3), fisher.test(tbl3), tbl4, chisq.test(tbl4), tbl5, chisq.test(tbl5), fisher.test(tbl5), tbl6, chisq.test(tbl6), tbl7, chisq.test(tbl7), tbl8, chisq.test(tbl8), fisher.test(tbl8), tbl9, chisq.test(tbl9), fisher.test(tbl9), tbl10, chisq.test(tbl10) ) cat("PS_Demos", STRADemos, file="C:/Users/13473/Desktop/Behavioral Addictions Research/STRA_Demos_New.txt", sep="\n", append=FALSE) ### #Demographics for GTRAT group # #chi square analyses for demographics of GTRA groups df<- dfPS df$GTRA <- df$q136 tbl1<- table("sex"= df$q2, "GTRA" = df$GTRA) tbl2<-table("grade"= df$q5,"GTRA" = df$GTRA) tbl3<-table("family"= df$q9, "GTRA" = df$GTRA) tbl4<-table("hisp"= df$hisp, "GTRA" = df$GTRA) tbl5<-table("asian"= df$asian, "GTRA" = df$GTRA) tbl6<-table("white"= df$white, "GTRA" = df$GTRA) tbl7<-table("black"= df$black, "GTRA" = df$GTRA) tbl8<-table("other"= df$other, "GTRA" = df$GTRA) tbl9<-table("VG"= df$VG, "GTRA" = df$GTRA) tbl10<-table("PS"= df$PS, "GTRA" = df$GTRA) # # # GTRADemos<- capture.output( tbl1, chisq.test(tbl1), tbl2, chisq.test(tbl2), tbl3, chisq.test(tbl3), fisher.test(tbl3), tbl4, chisq.test(tbl4), tbl5, chisq.test(tbl5), fisher.test(tbl5), tbl6, chisq.test(tbl6), tbl7, chisq.test(tbl7), tbl8, chisq.test(tbl8), fisher.test(tbl8), tbl9, chisq.test(tbl9), fisher.test(tbl9), tbl10, chisq.test(tbl10) ) cat("PS_Demos", GTRADemos, file="C:/Users/13473/Desktop/Behavioral Addictions Research/GTRA_Demos_New.txt", sep="\n", append=FALSE) # # # # ## Next, we want demographics of adolescents only in the PVG group, with # and without PS dfVG<- subset(dfVG, (dfVG$VG == 1)) # Final Dataset: comparing only VG students (79) # #Demographics # #chi square analyses df<-dfVG tbl1<- table("sex"= df$q2, "PS" = df$PS) tbl2<-table("grade"= df$q5,"PS" = df$PS) tbl3<-table("family"= df$q9, "PS" = df$PS) tbl4<-table("hisp"= df$hisp, "PS" = df$PS) tbl5<-table("asian"= df$asian, "PS" = df$PS) tbl6<-table("white"= df$white, "PS" = df$PS) tbl7<-table("black"= df$black, "PS" = df$PS) tbl8<-table("other"= df$other, "PS" = df$PS) tbl9<-table("VG"= df$VG, "PS" = df$PS) tbl10<-table("STRA"= df$STRA, "PS" = df$PS) # # # PsDemos<- capture.output( tbl1, chisq.test(tbl1), fisher.test(tbl1), tbl2, chisq.test(tbl2), fisher.test(tbl2), tbl3, chisq.test(tbl3), fisher.test(tbl3), tbl4, chisq.test(tbl4), fisher.test(tbl4), tbl5, chisq.test(tbl5), fisher.test(tbl5), tbl6, chisq.test(tbl6), fisher.test(tbl6), tbl7, chisq.test(tbl7), fisher.test(tbl7), tbl8, chisq.test(tbl8), fisher.test(tbl8), tbl9, chisq.test(tbl9), fisher.test(tbl9), tbl10, chisq.test(tbl10), fisher.test(tbl10) ) cat("PS_Demos", PsDemos, file="C:/Users/13473/Desktop/Behavioral Addictions Research/PS_Demos_WithinVG_New.txt", sep="\n", append=FALSE) # ############################################################################ ############################################################################ # Next we run regressions of PS~VG measures, PVG~Shop measures, STRAT~PVG, # GTRAT~PS measures and # interaction analyses with health correlates df<-dfPS dfVG<-df # Regressions: PS and VG first #Set up VG data dfVG$VGcut<- ifelse((dfVG$q131 == 1), 1, 0) dfVG$VGfam<- ifelse((dfVG$q132 == 1), 1, 0) dfVG$VGmiss<- ifelse((dfVG$q133 == 1), 1, 0) dfVG$VGexcess<- ifelse((dfVG$q134 == 1), 1, 0) dfVG$VGurge<- ifelse((dfVG$q135 == 1), 1, 0) dfVG$VGanxiety<- ifelse((dfVG$q136 == 1), 1, 0) # PsVG <- glm(dfVG$VG~ dfVG$PS + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) PsVGCut <- glm(dfVG$VGcut~ dfVG$PS + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) # PsVGFam <- glm(dfVG$VGfam~ dfVG$PS + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) # PsVGMiss <- glm(dfVG$VGmiss~ dfVG$PS + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) # PsVGExcess <- glm(dfVG$VGexcess~ dfVG$PS + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) # PsVGUrge <- glm(dfVG$VGurge~ dfVG$PS + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) # PsVGAnxiety <- glm(dfVG$VGanxiety~ dfVG$PS + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) # PS_VGREgs<- capture.output(summary(PsVG), summary(PsVGCut), summary(PsVGFam), summary(PsVGMiss), summary(PsVGExcess), summary(PsVGUrge), summary(PsVGAnxiety) ) cat("PS_VGRegs", PS_VGREgs, file="C:/Users/13473/Desktop/Behavioral Addictions Research/PS_VG_New.txt", sep="\n", append=FALSE) # # # Regressions: Each VG measure stratified by STRA PsVG <- glm(dfVG$VG~ dfVG$STRA + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) PsVGCut <- glm(dfVG$VGcut~ dfVG$STRA + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) # PsVGFam <- glm(dfVG$VGfam~ dfVG$STRA + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) # PsVGMiss <- glm(dfVG$VGmiss~ dfVG$STRA + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) # PsVGExcess <- glm(dfVG$VGexcess~ dfVG$STRA + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) # PsVGUrge <- glm(dfVG$VGurge~ dfVG$STRA + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) # PsVGAnxiety <- glm(dfVG$VGanxiety~ dfVG$STRA + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) # STRA_VGREgs<- capture.output(summary(PsVG), summary(PsVGCut), summary(PsVGFam), summary(PsVGMiss), summary(PsVGExcess), summary(PsVGUrge), summary(PsVGAnxiety) ) summary(PsVG) cat("PS_VGRegs", STRA_VGREgs, file="C:/Users/13473/Desktop/Behavioral Addictions Research/STRA_VG_New.txt", sep="\n", append=FALSE) # # ## Regressions: PVG stratified by each shopping measure (q115-120) # PsVGCut <- glm(dfVG$VG~ dfVG$q115 + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) PsVGFam <- glm(dfVG$VG~ dfVG$q116 + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) PsVGMiss <- glm(dfVG$VG~ dfVG$q117 + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) PsVGExcess <- glm(dfVG$VG~ dfVG$q118 + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) PsVGUrge <- glm(dfVG$VG~ dfVG$q119 + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) PsVGAnxiety <- glm(dfVG$VG~ dfVG$q120 + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) # PS_VGREgs<- capture.output( summary(PsVGCut), summary(PsVGFam), summary(PsVGMiss), summary(PsVGExcess), summary(PsVGUrge), summary(PsVGAnxiety) ) # # # Each shopping measure stratified by GTRA dfVG<-df dfPS<-dfVG dfPS$q115 [dfPS$q114 == 1] <- 0 dfPS$q116 [dfPS$q114 == 1] <- 0 dfPS$q117 [dfPS$q114 == 1] <- 0 dfPS$q118 [dfPS$q114 == 1] <- 0 dfPS$q119 [dfPS$q114 == 1] <- 0 dfPS$q120 [dfPS$q114 == 1] <- 0 dfPS$q115 [dfPS$q115 == 2] <- 0 dfPS$q116 [dfPS$q116 == 2] <- 0 dfPS$q117 [dfPS$q117 == 2] <- 0 dfPS$q118 [dfPS$q118 == 2] <- 0 dfPS$q119 [dfPS$q119 == 2] <- 0 dfPS$q120 [dfPS$q120 == 2] <- 0 dfPS<-subset(dfPS, ((!is.na(dfPS$q115)))) dfPS<-subset(dfPS, ((!is.na(dfPS$q116)))) dfPS<-subset(dfPS, ((!is.na(dfPS$q117)))) dfPS<-subset(dfPS, ((!is.na(dfPS$q118)))) dfPS<-subset(dfPS, ((!is.na(dfPS$q119)))) dfPS<-subset(dfPS, ((!is.na(dfPS$q120)))) dfVG<-dfPS dfVG$GTRA <- dfVG$q136 PsGtra <- glm(dfVG$PS~ dfVG$GTRA + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) PsCutGtra <- glm(dfVG$q115~ dfVG$GTRA + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) # PsFamGtra <- glm(dfVG$q116~ dfVG$GTRA + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) # PsMissGtra <- glm(dfVG$q117~ dfVG$GTRA + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) # PsExcessGtra <- glm(dfVG$q118~ dfVG$GTRA + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) # PsUrgeGtra <- glm(dfVG$q119~ dfVG$GTRA + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) # PsAnxietyGtra <- glm(dfVG$q120~ dfVG$GTRA + dfVG$sex + dfVG$hisp + dfVG$white +dfVG$black +dfVG$asian + dfVG$other + dfVG$grade + dfVG$family, family=binomial("logit")) # GTRA_PSREgs<- capture.output(summary(PsGtra), summary(PsCutGtra), summary(PsFamGtra), summary(PsMissGtra), summary(PsExcessGtra), summary(PsUrgeGtra), summary(PsAnxietyGtra) ) cat("PS_VGRegs", GTRA_PSREgs, file="C:/Users/13473/Desktop/Behavioral Addictions Research/GTRA_PS_New.txt", sep="\n", append=FALSE) # # # # # # Interaction regressions: dfPS<- df dfVG<- df # Prepare correlate categories- q97 measures dysphoria/depression- 1 = yes, 2 = no df$Dep [(df$q97 == 1)] <- 1 df$Dep [(df$q97 == 2)] <- 0 dfHC<- df # # # q7 measures extracurriculars- marking any of them is labeled as yes (1), otherwise marked no (0) dfHC$ExCurric [(dfHC$q7a == 1) | (dfHC$q7b == 1) | (dfHC$q7c == 1) | (dfHC$q7d == 1)] <- 1 dfHC$ExCurric [is.na(dfHC$q7a) & is.na(dfHC$q7b) & is.na(dfHC$q7c) & is.na(dfHC$q7d)] <- 0 # # Marijuana lifetime (q64) Y/N dfHC$LifeMari [(dfHC$q64 == 1)] <- 0 dfHC$LifeMari[(dfHC$q64 == 2) | (dfHC$q64 == 3)] <- 1 dfHC$LifeMari [(dfHC$q64 == 4) | (dfHC$q64 == 5)] <- 1 # # # Alcohol Problem Y/N (self reported, question 76) dfHC$AlcProb [(dfHC$q76 == 1)] <- 1 dfHC$AlcProb [(dfHC$q76 == 2)] <- 0 dfHC$AlcProb [(dfHC$q71 == 2)] <- 0 dfHC$AlcProb [(dfHC$q73 == 1)] <- 0 # REgular Smoking (question 53)- regular smoking vs occassional or none dfHC$Smoking [(dfHC$q53 == 4) | (dfHC$q53 == 5)] <- 1 dfHC$Smoking [(dfHC$q53 == 1) | (dfHC$q53 == 2)|(dfHC$q53 == 3)] <- 0 # # #Alcohol Binging Y/N (question 75) dfHC$LifeBinge [(dfHC$q75 == 1)] <- 0 dfHC$LifeBinge [(dfHC$q71 == 2)] <- 0 dfHC$LifeBinge [(dfHC$q73 == 1)] <- 0 dfHC$LifeBinge[(dfHC$q75 == 2) | (dfHC$q75 == 3)] <- 1 dfHC$LifeBinge [(dfHC$q75 == 4) | (dfHC$q75 == 5)] <- 1 dfHC$LifeBinge [(dfHC$q75 == 6) | (dfHC$q75 == 7)] <- 1 # # # # Drugs Life Y/N (q80) dfHC$LifeDrugs [(dfHC$q80 == 1)] <- 0 dfHC$LifeDrugs[(dfHC$q80 == 2) | (dfHC$q80 == 3)] <- 1 dfHC$LifeDrugs [(dfHC$q80 == 4) | (dfHC$q80 == 5)] <-1 # # # # Violence, defined by any physical fight, q95, Y/N dfHC$Fight [(dfHC$q95 == 1)] <- 0 dfHC$Fight[(dfHC$q95 == 2) | (dfHC$q95 == 3)] <- 1 dfHC$Fight [(dfHC$q95 == 4) | (dfHC$q95 == 5)] <- 1 dfHC$Fight[(dfHC$q95 == 6) | (dfHC$q95 == 7)] <- 1 dfHC$Fight [(dfHC$q95 == 8) ]<- 1 # # Violence, Serious Fight Y/N, q96 dfHC$SerFight [(dfHC$q96 == 1)] <- 0 dfHC$SerFight[(dfHC$q96 == 2) | (dfHC$q96 == 3)] <- 1 dfHC$SerFight [(dfHC$q96 == 4) | (dfHC$q96 == 5)] <- 1 # # Carry Weapon, q92 dfHC$Weapon [(dfHC$q92 == 1)] <- 0 dfHC$Weapon[(dfHC$q92 == 2) | (dfHC$q92 == 3)] <- 1 dfHC$Weapon [(dfHC$q92 == 4) | (dfHC$q92 == 5)] <- 1 # # # df<-dfHC PS_VG_extra <- glm(dfHC$ExCurric~ dfHC$VG+ dfHC$PS + dfHC$PS* dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # PS_VG_Smoking <- glm(dfHC$Smoking~ dfHC$VG+ dfHC$PS + dfHC$PS* dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # PS_VG_Mari <- glm(dfHC$LifeMari~ dfHC$VG+ dfHC$PS + dfHC$PS* dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # Alcohol binge PS_VG_AlcBinge <- glm(dfHC$LifeBinge~ dfHC$VG+ dfHC$PS + dfHC$PS* dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # PS_VG_AlcProblem<- glm(dfHC$AlcProb~ dfHC$VG+ dfHC$PS + dfHC$PS* dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # # # PS_VG_drug<- glm(dfHC$LifeDrugs~dfHC$VG+ dfHC$PS + dfHC$PS* dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # # # PS_VG_dep<- glm(dfHC$Dep~ dfHC$VG+ dfHC$PS + dfHC$PS* dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # # # fight PS_VG_fight<- glm(dfHC$Fight~ dfHC$VG+ dfHC$PS + dfHC$PS* dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # # PS_VG_serfight<- glm(dfHC$SerFight~ dfHC$VG+ dfHC$PS + dfHC$PS* dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # # PS_VG_weapon<- glm(dfHC$Weapon~ dfHC$VG+ dfHC$PS + dfHC$PS* dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # # # PsOut_1<- capture.output( summary(PS_VG_extra), summary(PS_VG_Mari), summary(PS_VG_AlcBinge), summary(PS_VG_AlcProblem), summary(PS_VG_Smoking), summary(PS_VG_drug), summary(PS_VG_dep), summary(PS_VG_fight), summary(PS_VG_serfight), summary(PS_VG_weapon) ) # cat("PS_ICD_HCs", PsOut_1, file="C:/Users/13473/Desktop/Behavioral Addictions Research/PS_VG_HC_inter_New.txt", sep="\n", append=TRUE) # # # # ## Association of PVG with HC, with and without PS # noPS PVG HC dfHC<- subset(dfHC, (dfHC$PS == 0)) PS_VG_extra <- glm(dfHC$ExCurric~ dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # PS_VG_Smoking <- glm(dfHC$Smoking~ dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # PS_VG_Mari <- glm(dfHC$LifeMari~ dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # Alcohol binge PS_VG_AlcBinge <- glm(dfHC$LifeBinge~ dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # PS_VG_AlcProblem<- glm(dfHC$AlcProb~ dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # # # PS_VG_drug<- glm(dfHC$LifeDrugs~dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # # # PS_VG_dep<- glm(dfHC$Dep~ dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # # # fight PS_VG_fight<- glm(dfHC$Fight~ dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # # PS_VG_serfight<- glm(dfHC$SerFight~ dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # # PS_VG_weapon<- glm(dfHC$Weapon~ dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # PsOut_2<- capture.output( summary(PS_VG_extra), summary(PS_VG_Mari), summary(PS_VG_AlcBinge), summary(PS_VG_AlcProblem), summary(PS_VG_Smoking), summary(PS_VG_drug), summary(PS_VG_dep), summary(PS_VG_fight), summary(PS_VG_serfight), summary(PS_VG_weapon) ) # cat("PS_ICD_HCs", PsOut_2, file="C:/Users/13473/Desktop/Behavioral Addictions Research/PS_VG_HC_noPS_New.txt", sep="\n", append=TRUE) # # # PVG~HC with PS dfHC<- df dfHC<- subset(dfHC, (dfHC$PS == 1)) PS_VG_extra <- glm(dfHC$ExCurric~ dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # PS_VG_Smoking <- glm(dfHC$Smoking~ dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # PS_VG_Mari <- glm(dfHC$LifeMari~ dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # Alcohol binge PS_VG_AlcBinge <- glm(dfHC$LifeBinge~ dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # PS_VG_AlcProblem<- glm(dfHC$AlcProb~ dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # # # PS_VG_drug<- glm(dfHC$LifeDrugs~dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # # # # PS_VG_dep<- glm(dfHC$Dep~ dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # # # fight PS_VG_fight<- glm(dfHC$Fight~ dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # # PS_VG_serfight<- glm(dfHC$SerFight~ dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # # PS_VG_weapon<- glm(dfHC$Weapon~ dfHC$VG+ dfHC$sex + dfHC$hisp + dfHC$white +dfHC$black +dfHC$asian + dfHC$other + dfHC$grade + dfHC$family, family=binomial("logit")) # # PsOut_3<- capture.output( summary(PS_VG_extra), summary(PS_VG_Mari), summary(PS_VG_AlcBinge), summary(PS_VG_AlcProblem), summary(PS_VG_Smoking), summary(PS_VG_drug), summary(PS_VG_dep), summary(PS_VG_fight), summary(PS_VG_serfight), summary(PS_VG_weapon) ) # cat("PS_ICD_HCs", PsOut_3, file="C:/Users/13473/Desktop/Behavioral Addictions Research/PS_VG_HC_wPS_New.txt", sep="\n", append=TRUE) #