@@ -102,9 +102,11 @@ ggplot(
102
102
103
103
# Latent Growth Curve Model {#lgcm}
104
104
105
- ## Model Syntax
105
+ ## Linear Model {#linearLGCM}
106
106
107
- ### Abbreviated
107
+ ### Model Syntax
108
+
109
+ #### Abbreviated
108
110
109
111
``` {r}
110
112
lgcm1_syntax <- '
@@ -124,7 +126,7 @@ lgcm1_syntax <- '
124
126
'
125
127
```
126
128
127
- ### Full
129
+ #### Full
128
130
129
131
``` {r}
130
132
lgcm2_syntax <- '
@@ -154,9 +156,9 @@ lgcm2_syntax <- '
154
156
'
155
157
```
156
158
157
- ## Fit the Model
159
+ ### Fit the Model
158
160
159
- ### Abbreviated
161
+ #### Abbreviated
160
162
161
163
``` {r}
162
164
lgcm1_fit <- growth(
@@ -171,7 +173,7 @@ lgcm1_fit <- growth(
171
173
em.h1.iter.max = 100000)
172
174
```
173
175
174
- ### Full
176
+ #### Full
175
177
176
178
``` {r}
177
179
lgcm2_fit <- sem(
@@ -184,9 +186,9 @@ lgcm2_fit <- sem(
184
186
em.h1.iter.max = 100000)
185
187
```
186
188
187
- ## Summary Output
189
+ ### Summary Output
188
190
189
- ### Abbreviated
191
+ #### Abbreviated
190
192
191
193
``` {r}
192
194
summary(
@@ -196,7 +198,7 @@ summary(
196
198
rsquare = TRUE)
197
199
```
198
200
199
- ### Full
201
+ #### Full
200
202
201
203
``` {r}
202
204
summary(
@@ -206,7 +208,7 @@ summary(
206
208
rsquare = TRUE)
207
209
```
208
210
209
- ## Estimates of Model Fit
211
+ ### Estimates of Model Fit
210
212
211
213
``` {r}
212
214
fitMeasures(
@@ -220,29 +222,29 @@ fitMeasures(
220
222
"rmsea.robust", "cfi.robust", "tli.robust"))
221
223
```
222
224
223
- ## Residuals of Observed vs. Model-Implied Correlation Matrix
225
+ ### Residuals of Observed vs. Model-Implied Correlation Matrix
224
226
225
227
``` {r}
226
228
residuals(
227
229
lgcm1_fit,
228
230
type = "cor")
229
231
```
230
232
231
- ## Modification Indices
233
+ ### Modification Indices
232
234
233
235
``` {r}
234
236
modificationindices(
235
237
lgcm1_fit,
236
238
sort. = TRUE)
237
239
```
238
240
239
- ## Internal Consistency Reliability
241
+ ### Internal Consistency Reliability
240
242
241
243
``` {r}
242
244
compRelSEM(lgcm1_fit)
243
245
```
244
246
245
- ## Path Diagram
247
+ ### Path Diagram
246
248
247
249
``` {r}
248
250
semPaths(
@@ -252,9 +254,9 @@ semPaths(
252
254
edge.label.cex = 1.5)
253
255
```
254
256
255
- ## Plot Trajectories
257
+ ### Plot Trajectories
256
258
257
- ### Protoypical Growth Curve
259
+ #### Protoypical Growth Curve
258
260
259
261
Calculated from intercept and slope parameters:
260
262
@@ -299,7 +301,7 @@ ggplot(
299
301
geom_line()
300
302
```
301
303
302
- ### Individuals' Growth Curves
304
+ #### Individuals' Growth Curves
303
305
304
306
Calculated from intercept and slope parameters:
305
307
@@ -347,7 +349,7 @@ ggplot(
347
349
geom_line()
348
350
```
349
351
350
- ### Individuals' Trajectories Overlaid with Prototypical Trajectory
352
+ #### Individuals' Trajectories Overlaid with Prototypical Trajectory
351
353
352
354
``` {r}
353
355
newData <- as.data.frame(predict(lgcm1_fit))
@@ -374,11 +376,11 @@ ggplot(
374
376
linewidth = 2)
375
377
```
376
378
377
- # Latent Basis Growth Curve Model {#lbgcm }
379
+ ## Latent Basis Model {#latentBasisLGCM }
378
380
379
- ## Model Syntax
381
+ ### Model Syntax
380
382
381
- ### Abbreviated
383
+ #### Abbreviated
382
384
383
385
``` {r}
384
386
lbgcm1_syntax <- '
@@ -398,7 +400,7 @@ lbgcm1_syntax <- '
398
400
'
399
401
```
400
402
401
- ### Full
403
+ #### Full
402
404
403
405
``` {r}
404
406
lbgcm2_syntax <- '
@@ -428,9 +430,9 @@ lbgcm2_syntax <- '
428
430
'
429
431
```
430
432
431
- ## Fit the Model
433
+ ### Fit the Model
432
434
433
- ### Abbreviated
435
+ #### Abbreviated
434
436
435
437
``` {r}
436
438
lbgcm1_fit <- growth(
@@ -445,7 +447,7 @@ lbgcm1_fit <- growth(
445
447
em.h1.iter.max = 100000)
446
448
```
447
449
448
- ### Full
450
+ #### Full
449
451
450
452
``` {r}
451
453
lbgcm2_fit <- sem(
@@ -458,9 +460,9 @@ lbgcm2_fit <- sem(
458
460
em.h1.iter.max = 100000)
459
461
```
460
462
461
- ## Summary Output
463
+ ### Summary Output
462
464
463
- ### Abbreviated
465
+ #### Abbreviated
464
466
465
467
``` {r}
466
468
summary(
@@ -470,7 +472,7 @@ summary(
470
472
rsquare = TRUE)
471
473
```
472
474
473
- ### Full
475
+ #### Full
474
476
475
477
``` {r}
476
478
summary(
@@ -480,7 +482,7 @@ summary(
480
482
rsquare = TRUE)
481
483
```
482
484
483
- ## Estimates of Model Fit
485
+ ### Estimates of Model Fit
484
486
485
487
``` {r}
486
488
fitMeasures(
@@ -494,29 +496,29 @@ fitMeasures(
494
496
"rmsea.robust", "cfi.robust", "tli.robust"))
495
497
```
496
498
497
- ## Residuals of Observed vs. Model-Implied Correlation Matrix
499
+ ### Residuals of Observed vs. Model-Implied Correlation Matrix
498
500
499
501
``` {r}
500
502
residuals(
501
503
lbgcm1_fit,
502
504
type = "cor")
503
505
```
504
506
505
- ## Modification Indices
507
+ ### Modification Indices
506
508
507
509
``` {r}
508
510
modificationindices(
509
511
lbgcm1_fit,
510
512
sort. = TRUE)
511
513
```
512
514
513
- ## Internal Consistency Reliability
515
+ ### Internal Consistency Reliability
514
516
515
517
``` {r}
516
518
compRelSEM(lbgcm1_fit)
517
519
```
518
520
519
- ## Path Diagram
521
+ ### Path Diagram
520
522
521
523
``` {r}
522
524
semPaths(
@@ -526,9 +528,9 @@ semPaths(
526
528
edge.label.cex = 1.5)
527
529
```
528
530
529
- ## Plot Trajectories
531
+ ### Plot Trajectories
530
532
531
- ### Protoypical Growth Curve
533
+ #### Protoypical Growth Curve
532
534
533
535
``` {r}
534
536
lbgcm1_intercept <- coef(lbgcm1_fit)["intercept~1"]
@@ -556,7 +558,7 @@ ggplot(
556
558
geom_line()
557
559
```
558
560
559
- ### Individuals' Growth Curves
561
+ #### Individuals' Growth Curves
560
562
561
563
``` {r}
562
564
person_factors <- as.data.frame(predict(lbgcm1_fit))
@@ -593,30 +595,26 @@ ggplot(
593
595
geom_line()
594
596
```
595
597
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
+ )
618
612
```
619
613
614
+ ## Quadratic Model {#quadraticLGCM}
615
+
616
+ ## Spline Model {#splineLGCM}
617
+
620
618
# Latent Change Score Model {#lcsm}
621
619
622
620
## Model Syntax
0 commit comments