@@ -102,9 +102,11 @@ ggplot(
102102
103103# Latent Growth Curve Model {#lgcm}
104104
105- ## Model Syntax
105+ ## Linear Model {#linearLGCM}
106106
107- ### Abbreviated
107+ ### Model Syntax
108+
109+ #### Abbreviated
108110
109111``` {r}
110112lgcm1_syntax <- '
@@ -124,7 +126,7 @@ lgcm1_syntax <- '
124126'
125127```
126128
127- ### Full
129+ #### Full
128130
129131``` {r}
130132lgcm2_syntax <- '
@@ -154,9 +156,9 @@ lgcm2_syntax <- '
154156'
155157```
156158
157- ## Fit the Model
159+ ### Fit the Model
158160
159- ### Abbreviated
161+ #### Abbreviated
160162
161163``` {r}
162164lgcm1_fit <- growth(
@@ -171,7 +173,7 @@ lgcm1_fit <- growth(
171173 em.h1.iter.max = 100000)
172174```
173175
174- ### Full
176+ #### Full
175177
176178``` {r}
177179lgcm2_fit <- sem(
@@ -184,9 +186,9 @@ lgcm2_fit <- sem(
184186 em.h1.iter.max = 100000)
185187```
186188
187- ## Summary Output
189+ ### Summary Output
188190
189- ### Abbreviated
191+ #### Abbreviated
190192
191193``` {r}
192194summary(
@@ -196,7 +198,7 @@ summary(
196198 rsquare = TRUE)
197199```
198200
199- ### Full
201+ #### Full
200202
201203``` {r}
202204summary(
@@ -206,7 +208,7 @@ summary(
206208 rsquare = TRUE)
207209```
208210
209- ## Estimates of Model Fit
211+ ### Estimates of Model Fit
210212
211213``` {r}
212214fitMeasures(
@@ -220,29 +222,29 @@ fitMeasures(
220222 "rmsea.robust", "cfi.robust", "tli.robust"))
221223```
222224
223- ## Residuals of Observed vs. Model-Implied Correlation Matrix
225+ ### Residuals of Observed vs. Model-Implied Correlation Matrix
224226
225227``` {r}
226228residuals(
227229 lgcm1_fit,
228230 type = "cor")
229231```
230232
231- ## Modification Indices
233+ ### Modification Indices
232234
233235``` {r}
234236modificationindices(
235237 lgcm1_fit,
236238 sort. = TRUE)
237239```
238240
239- ## Internal Consistency Reliability
241+ ### Internal Consistency Reliability
240242
241243``` {r}
242244compRelSEM(lgcm1_fit)
243245```
244246
245- ## Path Diagram
247+ ### Path Diagram
246248
247249``` {r}
248250semPaths(
@@ -252,9 +254,9 @@ semPaths(
252254 edge.label.cex = 1.5)
253255```
254256
255- ## Plot Trajectories
257+ ### Plot Trajectories
256258
257- ### Protoypical Growth Curve
259+ #### Protoypical Growth Curve
258260
259261Calculated from intercept and slope parameters:
260262
@@ -299,7 +301,7 @@ ggplot(
299301 geom_line()
300302```
301303
302- ### Individuals' Growth Curves
304+ #### Individuals' Growth Curves
303305
304306Calculated from intercept and slope parameters:
305307
@@ -347,7 +349,7 @@ ggplot(
347349 geom_line()
348350```
349351
350- ### Individuals' Trajectories Overlaid with Prototypical Trajectory
352+ #### Individuals' Trajectories Overlaid with Prototypical Trajectory
351353
352354``` {r}
353355newData <- as.data.frame(predict(lgcm1_fit))
@@ -374,11 +376,11 @@ ggplot(
374376 linewidth = 2)
375377```
376378
377- # Latent Basis Growth Curve Model {#lbgcm }
379+ ## Latent Basis Model {#latentBasisLGCM }
378380
379- ## Model Syntax
381+ ### Model Syntax
380382
381- ### Abbreviated
383+ #### Abbreviated
382384
383385``` {r}
384386lbgcm1_syntax <- '
@@ -398,7 +400,7 @@ lbgcm1_syntax <- '
398400'
399401```
400402
401- ### Full
403+ #### Full
402404
403405``` {r}
404406lbgcm2_syntax <- '
@@ -428,9 +430,9 @@ lbgcm2_syntax <- '
428430'
429431```
430432
431- ## Fit the Model
433+ ### Fit the Model
432434
433- ### Abbreviated
435+ #### Abbreviated
434436
435437``` {r}
436438lbgcm1_fit <- growth(
@@ -445,7 +447,7 @@ lbgcm1_fit <- growth(
445447 em.h1.iter.max = 100000)
446448```
447449
448- ### Full
450+ #### Full
449451
450452``` {r}
451453lbgcm2_fit <- sem(
@@ -458,9 +460,9 @@ lbgcm2_fit <- sem(
458460 em.h1.iter.max = 100000)
459461```
460462
461- ## Summary Output
463+ ### Summary Output
462464
463- ### Abbreviated
465+ #### Abbreviated
464466
465467``` {r}
466468summary(
@@ -470,7 +472,7 @@ summary(
470472 rsquare = TRUE)
471473```
472474
473- ### Full
475+ #### Full
474476
475477``` {r}
476478summary(
@@ -480,7 +482,7 @@ summary(
480482 rsquare = TRUE)
481483```
482484
483- ## Estimates of Model Fit
485+ ### Estimates of Model Fit
484486
485487``` {r}
486488fitMeasures(
@@ -494,29 +496,29 @@ fitMeasures(
494496 "rmsea.robust", "cfi.robust", "tli.robust"))
495497```
496498
497- ## Residuals of Observed vs. Model-Implied Correlation Matrix
499+ ### Residuals of Observed vs. Model-Implied Correlation Matrix
498500
499501``` {r}
500502residuals(
501503 lbgcm1_fit,
502504 type = "cor")
503505```
504506
505- ## Modification Indices
507+ ### Modification Indices
506508
507509``` {r}
508510modificationindices(
509511 lbgcm1_fit,
510512 sort. = TRUE)
511513```
512514
513- ## Internal Consistency Reliability
515+ ### Internal Consistency Reliability
514516
515517``` {r}
516518compRelSEM(lbgcm1_fit)
517519```
518520
519- ## Path Diagram
521+ ### Path Diagram
520522
521523``` {r}
522524semPaths(
@@ -526,9 +528,9 @@ semPaths(
526528 edge.label.cex = 1.5)
527529```
528530
529- ## Plot Trajectories
531+ ### Plot Trajectories
530532
531- ### Protoypical Growth Curve
533+ #### Protoypical Growth Curve
532534
533535``` {r}
534536lbgcm1_intercept <- coef(lbgcm1_fit)["intercept~1"]
@@ -556,7 +558,7 @@ ggplot(
556558 geom_line()
557559```
558560
559- ### Individuals' Growth Curves
561+ #### Individuals' Growth Curves
560562
561563``` {r}
562564person_factors <- as.data.frame(predict(lbgcm1_fit))
@@ -593,30 +595,26 @@ ggplot(
593595 geom_line()
594596```
595597
596- ### Individuals' Trajectories Overlaid with Prototypical Trajectory
597-
598- ``` {r}
599- #ggplot(
600- # data = newData) +
601- # xlab("Timepoint") +
602- # ylab("Score") +
603- # scale_x_continuous(
604- # limits = c(0, 3),
605- # labels = 1:4) +
606- # scale_y_continuous(
607- # limits = c(-10, 20)) +
608- # geom_abline(
609- # mapping = aes(
610- # slope = slope,
611- # intercept = intercept)) +
612- # geom_abline(
613- # mapping = aes(
614- # slope = lgcm1_slope,
615- # intercept = lgcm1_intercept),
616- # color = "blue",
617- # linewidth = 2)
598+ #### Individuals' Trajectories Overlaid with Prototypical Trajectory
599+
600+ ``` {r}
601+ ggplot() +
602+ geom_line( # individuals' model-implied trajectories
603+ data = individual_trajectories,
604+ aes(x = time, y = value, group = id),
605+ ) +
606+ geom_line( # prototypical trajectory
607+ data = newData,
608+ aes(x = time, y = predictedValue),
609+ color = "blue",
610+ linewidth = 2
611+ )
618612```
619613
614+ ## Quadratic Model {#quadraticLGCM}
615+
616+ ## Spline Model {#splineLGCM}
617+
620618# Latent Change Score Model {#lcsm}
621619
622620## Model Syntax
0 commit comments