library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5 ✓ purrr 0.3.4
## ✓ tibble 3.1.6 ✓ dplyr 1.0.7
## ✓ tidyr 1.1.4 ✓ stringr 1.4.0
## ✓ readr 2.1.1 ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(readr)
library(haven)
library(readxl)
#Intercept
intercept <- read_excel("/Users/idlhy/Library/CloudStorage/OneDrive-개인/바탕 화면/Research/Puberty Delinquency(HRB)/sas print/220401_female_w2_w6.xlsx", sheet = "intercept_prevalence")
colors <- c("late" = "#0000CC",
"early" = "#CC0000",
"normal" = "#1B9E77")
linetypes <- c("late" = 5,
"early" = 1,
"normal" = 6)
ggplot(intercept) +
aes(x = Grade) +
geom_line(aes(y = early, color = "early", lty = "early"), size = 1) +
geom_line(aes(y = normal, color = "normal", lty = "normal"), size = 1) +
geom_line(aes(y = late, color = "late", lty = "late"), size = 1) +
geom_ribbon(aes(ymin = e_l, ymax = e_u), color = "#CC0000", alpha = 0.05, lty = "dotted") +
geom_ribbon(aes(ymin = n_l, ymax = n_u), color = "#1B9E77", alpha = 0.05, lty = "dotted") +
geom_ribbon(aes(ymin = l_l, ymax = l_u), color = "#0000CC", alpha = 0.05, lty = "dotted") +
theme_bw() +
scale_color_manual(values = colors) +
scale_linetype_manual(values = linetypes) +
labs(x = "Grade"
, y = "Prevalence"
, title = "Estimated prevalence"
, color = "Puberty Group"
, lty = "Puberty Group") +
theme(legend.position = "bottom",
plot.title = element_text(family = "Times New Roman", size = (16)),
legend.title = element_text(family = "Times New Roman", size = (16)),
legend.text = element_text(family = "Times New Roman", size = (16)),
axis.title = element_text(family = "Times New Roman", size = (16)),
axis.text = element_text(family = "Times New Roman", size = (16)))
ggplot(intercept) +
aes(x = Grade) +
geom_line(aes(y = early, color = "early", lty = "early"), size = 1) +
geom_line(aes(y = late, color = "late", lty = "late"), size = 1) +
geom_ribbon(aes(ymin = e_l, ymax = e_u), color = "#CC0000", alpha = 0.1, lty = "dotted") +
geom_ribbon(aes(ymin = l_l, ymax = l_u), color = "#0000CC", alpha = 0.1, lty = "dotted") +
theme_bw() +
scale_color_manual(values = colors
, limits = c("early", "late")) +
labs(x = "Grade"
, y = "Prevalence"
, lty = "Puberty Group"
, title = "Estimated prevalence"
, color = "Puberty Group") +
theme(legend.position = "bottom",
plot.title = element_text(family = "Times New Roman", size = (16)),
legend.title = element_text(family = "Times New Roman", size = (16)),
legend.text = element_text(family = "Times New Roman", size = (16)),
axis.title = element_text(family = "Times New Roman", size = (16)),
axis.text = element_text(family = "Times New Roman", size = (16)))
PeerSubstanceUse <- read_excel("/Users/idlhy/Library/CloudStorage/OneDrive-개인/바탕 화면/Research/Puberty Delinquency(HRB)/sas print/220401_female_w2_w6.xlsx", sheet = "Peer Substance Use")
ggplot(PeerSubstanceUse) +
aes(x = Grade) +
geom_line(aes(y = early, color = "early", lty = "early"), size = 1) +
geom_line(aes(y = normal, color = "normal", lty = "normal"), size = 1) +
geom_line(aes(y = late, color = "late", lty = "late"), size = 1) +
geom_line(aes(y = 0), size = 1) +
geom_ribbon(aes(ymin = e_l, ymax = e_u), color = "#CC0000", alpha = 0.04, lty = "dotted") +
geom_ribbon(aes(ymin = n_l, ymax = n_u), color = "#1B9E77", alpha = 0.04, lty = "dotted") +
geom_ribbon(aes(ymin = l_l, ymax = l_u), color = "#0000CC", alpha = 0.04, lty = "dotted") +
theme_bw() +
scale_color_manual(values = colors
, limits = c("early", "late", "normal")) +
labs(x = "Grade"
, y = "Coefficient"
, lty = "Puberty Group"
, title = "Number of Peers with Substance Abuse"
, color = "Puberty Group") +
theme(legend.position = "bottom",
plot.title = element_text(family = "Times New Roman", size = (16)),
legend.title = element_text(family = "Times New Roman", size = (16)),
legend.text = element_text(family = "Times New Roman", size = (16)),
axis.title = element_text(family = "Times New Roman", size = (16)),
axis.text = element_text(family = "Times New Roman", size = (16)))+
ylim(-3.5, 3.5)
ggplot(PeerSubstanceUse) +
aes(x = Grade) +
geom_line(aes(y = early, color = "early", lty = "early"), size = 1) +
geom_line(aes(y = late, color = "late", lty = "late"), size = 1) +
geom_line(aes(y = 0), size = 1) +
geom_ribbon(aes(ymin = e_l, ymax = e_u), color = "#CC0000", alpha = 0.1, lty = "dotted") +
geom_ribbon(aes(ymin = l_l, ymax = l_u), color = "#0000CC", alpha = 0.1, lty = "dotted") +
theme_bw() +
scale_color_manual(values = colors
, limits = c("early", "late")) +
labs(x = "Grade"
, y = "Coefficient"
, lty = "Puberty Group"
, color = "Puberty Group"
, title = "Number of Peers with Substance Abuse") +
theme(legend.position = "bottom",
plot.title = element_text(family = "Times New Roman", size = (16)),
legend.title = element_text(family = "Times New Roman", size = (16)),
legend.text = element_text(family = "Times New Roman", size = (16)),
axis.title = element_text(family = "Times New Roman", size = (16)),
axis.text = element_text(family = "Times New Roman", size = (16))) +
ylim(-3.5, 3.5)
# PeerTime
PeerTime <- read_excel("/Users/idlhy/Library/CloudStorage/OneDrive-개인/바탕 화면/Research/Puberty Delinquency(HRB)/sas print/220401_female_w2_w6.xlsx", sheet = "Peer Time")
ggplot(PeerTime) +
aes(x = Grade) +
geom_line(aes(y = early, color = "early", lty = "early"), size = 1) +
geom_line(aes(y = normal, color = "normal", lty = "normal"), size = 1) +
geom_line(aes(y = late, color = "late", lty = "late"), size = 1) +
geom_line(aes(y = 0), size = 1) +
geom_ribbon(aes(ymin = e_l, ymax = e_u), color = "#CC0000", alpha = 0.04, lty = "dotted") +
geom_ribbon(aes(ymin = n_l, ymax = n_u), color = "#1B9E77", alpha = 0.04, lty = "dotted") +
geom_ribbon(aes(ymin = l_l, ymax = l_u), color = "#0000CC", alpha = 0.04, lty = "dotted") +
theme_bw() +
scale_color_manual(values = colors
, limits = c("early", "late", "normal")) +
labs(x = "Grade"
, y = "Coefficient"
, lty = "Puberty Group"
, title = "Time Spending with Peers"
, color = "Puberty Group") +
theme(legend.position = "bottom",
plot.title = element_text(family = "Times New Roman", size = (16)),
legend.title = element_text(family = "Times New Roman", size = (16)),
legend.text = element_text(family = "Times New Roman", size = (16)),
axis.title = element_text(family = "Times New Roman", size = (16)),
axis.text = element_text(family = "Times New Roman", size = (16)))+
ylim(-3.5, 3.5)
ggplot(PeerTime) +
aes(x = Grade) +
geom_line(aes(y = early, color = "early", lty = "early"), size = 1) +
geom_line(aes(y = late, color = "late", lty = "late"), size = 1) +
geom_line(aes(y = 0), size = 1) +
geom_ribbon(aes(ymin = e_l, ymax = e_u), color = "#CC0000", alpha = 0.1, lty = "dotted") +
geom_ribbon(aes(ymin = l_l, ymax = l_u), color = "#0000CC", alpha = 0.1, lty = "dotted") +
theme_bw() +
scale_color_manual(values = colors
, limits = c("early", "late")) +
labs(x = "Grade"
, y = "Coefficient"
, lty = "Puberty Group"
, color = "Puberty Group"
, title = "Time Spending with Peers") +
theme(legend.position = "bottom",
plot.title = element_text(family = "Times New Roman", size = (16)),
legend.title = element_text(family = "Times New Roman", size = (16)),
legend.text = element_text(family = "Times New Roman", size = (16)),
axis.title = element_text(family = "Times New Roman", size = (16)),
axis.text = element_text(family = "Times New Roman", size = (16)))+
ylim(-3.5, 3.5)
# ParentAttachment
ParentAttachment <- read_excel("/Users/idlhy/Library/CloudStorage/OneDrive-개인/바탕 화면/Research/Puberty Delinquency(HRB)/sas print/220401_female_w2_w6.xlsx", sheet = "Parent Attachment")
ggplot(ParentAttachment) +
aes(x = Grade) +
geom_line(aes(y = early, color = "early", lty = "early"), size = 1) +
geom_line(aes(y = normal, color = "normal", lty = "normal"), size = 1) +
geom_line(aes(y = late, color = "late", lty = "late"), size = 1) +
geom_line(aes(y = 0), size = 1) +
geom_ribbon(aes(ymin = e_l, ymax = e_u), color = "#CC0000", alpha = 0.04, lty = "dotted") +
geom_ribbon(aes(ymin = n_l, ymax = n_u), color = "#1B9E77", alpha = 0.04, lty = "dotted") +
geom_ribbon(aes(ymin = l_l, ymax = l_u), color = "#0000CC", alpha = 0.04, lty = "dotted") +
theme_bw() +
scale_color_manual(values = colors
, limits = c("early", "late", "normal")) +
labs(x = "Grade"
, y = "Coefficient"
, lty = "Puberty Group"
, title = "Parent Attachment"
, color = "Puberty Group") +
theme(legend.position = "bottom",
plot.title = element_text(family = "Times New Roman", size = (16)),
legend.title = element_text(family = "Times New Roman", size = (16)),
legend.text = element_text(family = "Times New Roman", size = (16)),
axis.title = element_text(family = "Times New Roman", size = (16)),
axis.text = element_text(family = "Times New Roman", size = (16)))+
ylim(-3.5, 3.5)
ggplot(ParentAttachment) +
aes(x = Grade) +
geom_line(aes(y = early, color = "early", lty = "early"), size = 1) +
geom_line(aes(y = late, color = "late", lty = "late"), size = 1) +
geom_line(aes(y = 0), size = 1) +
geom_ribbon(aes(ymin = e_l, ymax = e_u), color = "#CC0000", alpha = 0.1, lty = "dotted") +
geom_ribbon(aes(ymin = l_l, ymax = l_u), color = "#0000CC", alpha = 0.1, lty = "dotted") +
theme_bw() +
scale_color_manual(values = colors
, limits = c("early", "late")) +
labs(x = "Grade"
, y = "Coefficient"
, lty = "Puberty Group"
, title = "Parent Attachment"
, color = "Puberty Group") +
theme(legend.position = "bottom",
plot.title = element_text(family = "Times New Roman", size = (16)),
legend.title = element_text(family = "Times New Roman", size = (16)),
legend.text = element_text(family = "Times New Roman", size = (16)),
axis.title = element_text(family = "Times New Roman", size = (16)),
axis.text = element_text(family = "Times New Roman", size = (16)))+
ylim(-3.5, 3.5)
Coeducation <- read_excel("/Users/idlhy/Library/CloudStorage/OneDrive-개인/바탕 화면/Research/Puberty Delinquency(HRB)/sas print/220401_female_w2_w6.xlsx", sheet = "Coeducation")
ggplot(Coeducation) +
aes(x = Grade) +
geom_line(aes(y = early, color = "early", lty = "early"), size = 1) +
geom_line(aes(y = normal, color = "normal", lty = "normal"), size = 1) +
geom_line(aes(y = late, color = "late", lty = "late"), size = 1) +
geom_line(aes(y = 0), size = 1) +
geom_ribbon(aes(ymin = e_l, ymax = e_u), color = "#CC0000", alpha = 0.04, lty = "dotted") +
geom_ribbon(aes(ymin = n_l, ymax = n_u), color = "#1B9E77", alpha = 0.04, lty = "dotted") +
geom_ribbon(aes(ymin = l_l, ymax = l_u), color = "#0000CC", alpha = 0.04, lty = "dotted") +
theme_bw() +
scale_color_manual(values = colors
, limits = c("early", "late", "normal")) +
labs(x = "Grade"
, y = "Coefficient"
, title = "Coeducation"
, lty = "Puberty Group"
, color = "Puberty Group") +
theme(legend.position = "bottom",
plot.title = element_text(family = "Times New Roman", size = (16)),
legend.title = element_text(family = "Times New Roman", size = (16)),
legend.text = element_text(family = "Times New Roman", size = (16)),
axis.title = element_text(family = "Times New Roman", size = (16)),
axis.text = element_text(family = "Times New Roman", size = (16)))+
ylim(-3.5, 3.5)
ggplot(Coeducation) +
aes(x = Grade) +
geom_line(aes(y = early, color = "early", lty = "early"), size = 1) +
geom_line(aes(y = late, color = "late", lty = "late"), size = 1) +
geom_line(aes(y = 0), size = 1) +
geom_ribbon(aes(ymin = e_l, ymax = e_u), color = "#CC0000", alpha = 0.1, lty = "dotted") +
geom_ribbon(aes(ymin = l_l, ymax = l_u), color = "#0000CC", alpha = 0.1, lty = "dotted") +
theme_bw() +
scale_color_manual(values = colors
, limits = c("early", "late")) +
labs(x = "Grade"
, y = "Coefficient"
, title = "Coeducation"
, lty = "Puberty Group"
, color = "Puberty Group") +
theme(legend.position = "bottom",
plot.title = element_text(family = "Times New Roman", size = (16)),
legend.title = element_text(family = "Times New Roman", size = (16)),
legend.text = element_text(family = "Times New Roman", size = (16)),
axis.title = element_text(family = "Times New Roman", size = (16)),
axis.text = element_text(family = "Times New Roman", size = (16)))+
ylim(-3.5, 3.5)
save.image("graph_0401.Rdata")