Skip to content

Commit e212fc6

Browse files
20260116 - update figures
1 parent 74067a1 commit e212fc6

File tree

1 file changed

+37
-13
lines changed

1 file changed

+37
-13
lines changed

sem.qmd

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,12 @@ ggplot(
886886
ylab("Score") +
887887
scale_y_continuous(
888888
limits = c(0, 5)) +
889-
geom_line()
889+
geom_smooth(
890+
method = "lm",
891+
formula = y ~ x + I(x^2),
892+
se = FALSE,
893+
linewidth = 0.5
894+
)
890895
```
891896

892897
#### Individuals' Growth Curves
@@ -927,28 +932,47 @@ ggplot(
927932
ylab("Score") +
928933
scale_y_continuous(
929934
limits = c(-10, 20)) +
930-
geom_line()
935+
geom_smooth(
936+
method = "lm",
937+
formula = y ~ x + I(x^2),
938+
se = FALSE,
939+
linewidth = 0.5
940+
)
931941
```
932942

933943
#### Individuals' Trajectories Overlaid with Prototypical Trajectory
934944

935945
```{r}
936-
ggplot() +
937-
geom_line( # individuals' model-implied trajectories
938-
data = individual_trajectories,
939-
aes(
940-
x = time,
941-
y = value,
942-
group = id),
946+
ggplot(
947+
data = individual_trajectories,
948+
mapping = aes(
949+
x = time,
950+
y = value,
951+
group = id)) +
952+
geom_smooth( # individuals' model-implied trajectories
953+
method = "lm",
954+
formula = y ~ x + I(x^2),
955+
se = FALSE,
956+
linewidth = 0.5,
957+
color = "gray",
958+
alpha = 0.30
943959
) +
944-
geom_line( # prototypical trajectory
960+
geom_smooth( # prototypical trajectory
945961
data = newData,
946-
aes(
962+
mapping = aes(
947963
x = time,
948964
y = predictedValue),
949-
color = "blue",
965+
inherit.aes = FALSE,
966+
method = "lm",
967+
formula = y ~ x + I(x^2),
968+
se = FALSE,
950969
linewidth = 2
951-
)
970+
) +
971+
labs(
972+
x = "Age (years)",
973+
y = "Depression Symptoms"
974+
) +
975+
theme_classic()
952976
```
953977

954978
## Spline (Piecewise) Growth Curve Model {#sec-splineLGCM}

0 commit comments

Comments
 (0)