knitr::opts_chunk$set(echo = TRUE)
library(lavaan)
## This is lavaan 0.6-15
## lavaan is FREE software! Please report any bugs.
library(semTools)
##
## ###############################################################################
## This is semTools 0.5-6
## All users of R (or SEM) are invited to submit functions or ideas for functions.
## ###############################################################################
library(semPlot)
library(haven)
library(psych)
##
## Attaching package: 'psych'
## The following objects are masked from 'package:semTools':
##
## reliability, skew
## The following object is masked from 'package:lavaan':
##
## cor2cov
library(GAIPE)
library(naniar) #downloading packages
HW2_TimeData <- read.csv("WLS_HW2_Time.csv", header=TRUE)
head(HW2_TimeData) #reading in data file
## idpub sexrsp byear educ92 age04 age11 Simil_2004 Digits_2004 LFLU_2004
## 1 905087 1 37 13 66 NA 8 12 12
## 2 905118 2 39 12 65 71 2 9 13
## 3 901295 2 40 12 64 70 10 10 8
## 4 922383 2 38 12 66 NA 0 NA 6
## 5 904612 1 38 12 65 73 4 9 6
## 6 900877 1 37 12 66 73 7 7 14
## CFLU_2004 Simil_2011 Digits_2011 LFLU_2011 CFLU_2011 TotRecall_2004
## 1 17 NA NA NA NA 12
## 2 NA 3 9 13 NA 9
## 3 NA 7 7 11 NA 6
## 4 16 NA NA NA NA NA
## 5 18 6 10 7 23 9
## 6 NA 6 8 7 NA 9
## TotRecall_2011 N_04 N_11
## 1 NA 4 0
## 2 11 3 3
## 3 9 3 3
## 4 NA 3 0
## 5 11 4 4
## 6 10 3 3
TimeData_TD<-HW2_TimeData[,(1:6)] #subsetting demographic variables of interest
TimeData_T <- HW2_TimeData[,(7:14)] #subsetting variables of interest (cog items)
TimeData_T1 <- TimeData_T[,(1:4)] #subsetting T1 variables of interest
TimeData_T2 <- TimeData_T[,(5:8)] #subsetting T2 variables of interest
vis_miss(TimeData_T1) #viewing missingness at T1. There does seem to be quite a bit of missingess; however, missing data will be estimated using FIML.
## Warning: `gather_()` was deprecated in tidyr 1.2.0.
## ℹ Please use `gather()` instead.
## ℹ The deprecated feature was likely used in the visdat package.
## Please report the issue at <]8;;https://github.com/ropensci/visdat/issueshttps://github.com/ropensci/visdat/issues]8;;>.
vis_miss(TimeData_T2) #viewing missingness at T2. There does seem to be quite a bit of missingess; however, missing data will be estimated using FIML.
alpha(TimeData_T1) #calculating cronbach's alpha for T1 variables. Alpha values for WAIS 2004 (α = .47), Digit Ordering 2004 (α = .52), Letter Fluency 2004 (α = .42), Category Fluency 2004 (α = .43) were all less than what has been generally considered acceptable (i.e., α = .70 or higher).
## Number of categories should be increased in order to count frequencies.
##
## Reliability analysis
## Call: alpha(x = TimeData_T1)
##
## raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
## 0.5 0.53 0.47 0.22 1.1 0.0084 9.3 3.4 0.21
##
## 95% confidence boundaries
## lower alpha upper
## Feldt 0.48 0.5 0.52
## Duhachek 0.49 0.5 0.52
##
## Reliability if an item is dropped:
## raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
## Simil_2004 0.46 0.47 0.38 0.23 0.90 0.0099 0.00823 0.19
## Digits_2004 0.48 0.52 0.42 0.27 1.08 0.0090 0.00351 0.23
## LFLU_2004 0.34 0.42 0.32 0.19 0.72 0.0110 0.00103 0.18
## CFLU_2004 0.40 0.43 0.34 0.20 0.76 0.0114 0.00079 0.19
##
## Item statistics
## n raw.r std.r r.cor r.drop mean sd
## Simil_2004 6808 0.54 0.64 0.42 0.31 6.6 2.4
## Digits_2004 5310 0.48 0.60 0.34 0.24 7.2 3.1
## LFLU_2004 4952 0.63 0.68 0.51 0.38 11.4 4.4
## CFLU_2004 3246 0.81 0.67 0.49 0.37 20.9 6.1
alpha(TimeData_T2) #calculating cronbach's alpha for T2 variables. Alpha values for WAIS 2011 (α = .56), Digit Ordering 2011 (α = .54), Letter Fluency 2011 (α = .48), and Category Fluency 2011 (α = .49) were all less than what has been generally considered acceptable (i.e., α = .70 or higher).
## Number of categories should be increased in order to count frequencies.
##
## Reliability analysis
## Call: alpha(x = TimeData_T2)
##
## raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
## 0.55 0.59 0.52 0.26 1.4 0.0075 9.5 3 0.26
##
## 95% confidence boundaries
## lower alpha upper
## Feldt 0.53 0.55 0.56
## Duhachek 0.53 0.55 0.56
##
## Reliability if an item is dropped:
## raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
## Simil_2011 0.52 0.56 0.46 0.29 1.25 0.0086 0.00211 0.27
## Digits_2011 0.49 0.54 0.44 0.28 1.16 0.0087 0.00364 0.25
## LFLU_2011 0.40 0.48 0.39 0.24 0.94 0.0095 0.00083 0.24
## CFLU_2011 0.46 0.49 0.39 0.24 0.96 0.0100 0.00098 0.25
##
## Item statistics
## n raw.r std.r r.cor r.drop mean sd
## Simil_2011 5400 0.51 0.63 0.41 0.31 6.4 2.3
## Digits_2011 4252 0.52 0.65 0.45 0.34 6.8 2.6
## LFLU_2011 5052 0.70 0.70 0.54 0.42 11.2 4.2
## CFLU_2011 2559 0.83 0.69 0.53 0.41 19.6 6.0
describe(TimeData_TD) #finding descriptives of demographic variables. Females make up a little over half of the sample. Participants' mean age is reaching emerging older adulthood at T1. Participants' mean age has reached older adulthood at T2. Mean number of years of education based on highest degree earned was 13.71. Skewness and kurtosis do not seem to be an issue, they are all acceptable. Data seem to meet normality assumptions. No outliers seem to be present.
## vars n mean sd median trimmed mad min max
## idpub 1 7078 916920.25 9813.33 916866.5 916905.45 12668.82 900021 933957
## sexrsp 2 7078 1.54 0.50 2.0 1.55 0.00 1 2
## byear 3 7078 38.86 0.50 39.0 38.91 0.00 37 40
## educ92 4 6858 13.71 2.30 12.0 13.32 0.00 12 21
## age04 5 7078 64.35 0.71 64.0 64.34 0.00 63 67
## age11 6 5534 71.22 0.92 71.0 71.14 1.48 70 74
## range skew kurtosis se
## idpub 33936 0.01 -1.20 116.64
## sexrsp 1 -0.15 -1.98 0.01
## byear 3 -1.04 2.77 0.01
## educ92 9 1.05 -0.17 0.03
## age04 4 0.48 0.54 0.01
## age11 4 0.59 -0.02 0.01
describe(TimeData_T1) #finding descriptives of variables of interest at T1. Means of simil_2004 and digits_2004 are lower than means for LFLU_2004 and CFLU_2004. Skewness and kurtosis do not seem to be an issue, they are all acceptable. Data seem to meet normality assumptions.
## vars n mean sd median trimmed mad min max range skew
## Simil_2004 1 6808 6.58 2.38 7 6.60 2.97 0 12 12 -0.06
## Digits_2004 2 5310 7.23 3.07 7 7.44 2.97 0 12 12 -0.51
## LFLU_2004 3 4952 11.44 4.35 11 11.25 4.45 0 31 31 0.44
## CFLU_2004 4 3246 20.85 6.14 20 20.65 5.93 0 47 47 0.35
## kurtosis se
## Simil_2004 -0.46 0.03
## Digits_2004 -0.02 0.04
## LFLU_2004 0.26 0.06
## CFLU_2004 0.33 0.11
describe(TimeData_T2) #finding descriptives of variables of interest at T2. Means of simil_2011 and digits_2011 are lower than means for LFLU_2011 and CFLU_2011.Skewness and kurtosis do not seem to be an issue, they are all acceptable. Data seem to meet normality assumptions.
## vars n mean sd median trimmed mad min max range skew
## Simil_2011 1 5400 6.36 2.32 6 6.34 2.97 0 12 12 0.03
## Digits_2011 2 4252 6.81 2.63 6 6.94 2.97 0 12 12 -0.45
## LFLU_2011 3 5052 11.21 4.18 11 11.05 4.45 0 31 31 0.38
## CFLU_2011 4 2559 19.60 5.97 19 19.48 5.93 0 47 47 0.21
## kurtosis se
## Simil_2011 -0.44 0.03
## Digits_2011 0.42 0.04
## LFLU_2011 0.09 0.06
## CFLU_2011 0.54 0.12
SexT1 <- factor(TimeData_TD$sexrsp, levels = 1:2, labels = c("Male", "Female")) #turning sex into a factor
summary(SexT1) #getting summary/frequency of sex. Females made up approximately 54% (n = 3,801) and males made up approximately 46% (n = 3,277) of the sample.
## Male Female
## 3277 3801
Variable means and standard deviations decreased slightly across time.
var(TimeData_TD$sexrsp)
## [1] 0.2486649
var(TimeData_TD$byear)
## [1] 0.2460696
var(TimeData_T1$Simil_2004, na.rm=TRUE)
## [1] 5.657111
var(TimeData_T1$Digits_2004, na.rm=TRUE)
## [1] 9.417145
var(TimeData_T1$LFLU_2004, na.rm=TRUE)
## [1] 18.94036
var(TimeData_T1$CFLU_2004, na.rm=TRUE) #finding variances of participants' sex, birth year, and cognitive measures at T1. All variances do not warrant concern.
## [1] 37.75414
var(TimeData_TD$sexrsp)
## [1] 0.2486649
var(TimeData_TD$byear)
## [1] 0.2460696
var(TimeData_T2$Simil_2011, na.rm=TRUE)
## [1] 5.384844
var(TimeData_T2$Digits_2011, na.rm=TRUE)
## [1] 6.90269
var(TimeData_T2$LFLU_2011, na.rm=TRUE)
## [1] 17.48802
var(TimeData_T2$CFLU_2011, na.rm=TRUE) #finding variances of participants' sex, birth year, and cognitive measures at T2. All variances do not warrant concern.
## [1] 35.66045
corMat <- cor(HW2_TimeData, use = "pairwise.complete.obs")
corMat #correlation matrix. No item shared a coefficient large enough to warrant concern for multicollinearity. Based on correlation coefficients, no items shared a coefficient large enough to warrant concern for multicollinearity (all r’s ≤ .59). In addition, relationships between age at time point 1 and 2 and cognitive functioning variables were weak and negative. Education and cognitive functioning variables had a weak to moderate, positive relationship. Also, within-time variables were weakly associated at time point 1 (r = .17-.34) and time point 2 (r = .21-.35), thus variables exhibited good test-retest reliability and measure different components of overall cognitive functioning. Time point 1 cognitive functioning variables had strong, positive associations with the same variables at time point 2 (r < .50), except for the Digit Ordering variable, which had a moderate, positive association from time point 1 to time point 2 (r < .35).
## idpub sexrsp byear educ92 age04
## idpub 1.0000000000 -0.005308263 0.006871993 0.00337777 -0.01151801
## sexrsp -0.0053082626 1.000000000 0.110564254 -0.16200261 -0.09015242
## byear 0.0068719927 0.110564254 1.000000000 0.13381537 -0.56774438
## educ92 0.0033777703 -0.162002605 0.133815369 1.00000000 -0.10763001
## age04 -0.0115180085 -0.090152422 -0.567744375 -0.10763001 1.00000000
## age11 -0.0254198991 -0.027381266 -0.430587301 -0.13831503 0.42456697
## Simil_2004 0.0171345646 0.001839766 0.147486416 0.38315537 -0.14487527
## Digits_2004 0.0260883796 0.079716217 0.137958318 0.17248550 -0.13175250
## LFLU_2004 0.0115240402 0.120019945 0.096690054 0.21692665 -0.09089293
## CFLU_2004 0.0009888218 0.149956418 0.124615114 0.25304066 -0.11155449
## Simil_2011 -0.0045767474 -0.019505341 0.146671506 0.37633723 -0.13103808
## Digits_2011 0.0189885631 0.044389664 0.123559119 0.17840004 -0.13508921
## LFLU_2011 0.0101217591 0.136385641 0.131554061 0.24523448 -0.11727568
## CFLU_2011 0.0223604114 0.164166325 0.128996328 0.19733989 -0.08882468
## TotRecall_2004 0.0026152467 0.255187644 0.095912290 0.13664526 -0.07762805
## TotRecall_2011 0.0105892632 0.236808047 0.166278052 0.16438511 -0.13781502
## N_04 -0.0228501975 0.009320027 0.038472019 0.01902736 -0.06960679
## N_11 -0.0072923491 -0.002311953 0.044665930 0.09361322 -0.08213913
## age11 Simil_2004 Digits_2004 LFLU_2004 CFLU_2004
## idpub -0.02541990 0.017134565 0.02608838 0.011524040 0.0009888218
## sexrsp -0.02738127 0.001839766 0.07971622 0.120019945 0.1499564176
## byear -0.43058730 0.147486416 0.13795832 0.096690054 0.1246151136
## educ92 -0.13831503 0.383155375 0.17248550 0.216926654 0.2530406626
## age04 0.42456697 -0.144875274 -0.13175250 -0.090892928 -0.1115544855
## age11 1.00000000 -0.145524530 -0.09946018 -0.100222416 -0.1226535281
## Simil_2004 -0.14552453 1.000000000 0.18568314 0.238716614 0.2349456386
## Digits_2004 -0.09946018 0.185683142 1.00000000 0.190241061 0.1690607562
## LFLU_2004 -0.10022242 0.238716614 0.19024106 1.000000000 0.3370050497
## CFLU_2004 -0.12265353 0.234945639 0.16906076 0.337005050 1.0000000000
## Simil_2011 -0.16896115 0.556810600 0.15011026 0.205458267 0.2384257351
## Digits_2011 -0.11321128 0.163421925 0.34789799 0.210788789 0.2326793004
## LFLU_2011 -0.11945583 0.239586951 0.19556915 0.591650184 0.3155062961
## CFLU_2011 -0.13170105 0.218056814 0.17845534 0.296953581 0.5905127640
## TotRecall_2004 -0.05681533 0.125805029 0.30052972 0.176975804 0.2010712961
## TotRecall_2011 -0.13482718 0.229851012 0.21725412 0.201517136 0.2653682210
## N_04 -0.01576978 0.116262831 0.01448163 0.002896705 0.0951432560
## N_11 -0.02770080 0.130674051 0.04261629 0.079454664 0.1162335475
## Simil_2011 Digits_2011 LFLU_2011 CFLU_2011 TotRecall_2004
## idpub -0.004576747 0.01898856 0.01012176 0.02236041 0.002615247
## sexrsp -0.019505341 0.04438966 0.13638564 0.16416633 0.255187644
## byear 0.146671506 0.12355912 0.13155406 0.12899633 0.095912290
## educ92 0.376337229 0.17840004 0.24523448 0.19733989 0.136645258
## age04 -0.131038085 -0.13508921 -0.11727568 -0.08882468 -0.077628046
## age11 -0.168961152 -0.11321128 -0.11945583 -0.13170105 -0.056815331
## Simil_2004 0.556810600 0.16342193 0.23958695 0.21805681 0.125805029
## Digits_2004 0.150110259 0.34789799 0.19556915 0.17845534 0.300529721
## LFLU_2004 0.205458267 0.21078879 0.59165018 0.29695358 0.176975804
## CFLU_2004 0.238425735 0.23267930 0.31550630 0.59051276 0.201071296
## Simil_2011 1.000000000 0.20951685 0.24995424 0.24298900 0.109913707
## Digits_2011 0.209516848 1.00000000 0.27392305 0.27039944 0.146164190
## LFLU_2011 0.249954240 0.27392305 1.00000000 0.34936256 0.192947526
## CFLU_2011 0.242989005 0.27039944 0.34936256 1.00000000 0.206898949
## TotRecall_2004 0.109913707 0.14616419 0.19294753 0.20689895 1.000000000
## TotRecall_2011 0.263933247 0.25748201 0.25687735 0.30583860 0.362090540
## N_04 0.045494272 0.01918534 0.02687200 0.02058211 0.038936317
## N_11 0.051935223 0.04426760 0.01561521 0.09634205 0.041379857
## TotRecall_2011 N_04 N_11
## idpub 0.01058926 -0.022850197 -0.007292349
## sexrsp 0.23680805 0.009320027 -0.002311953
## byear 0.16627805 0.038472019 0.044665930
## educ92 0.16438511 0.019027363 0.093613219
## age04 -0.13781502 -0.069606795 -0.082139127
## age11 -0.13482718 -0.015769777 -0.027700803
## Simil_2004 0.22985101 0.116262831 0.130674051
## Digits_2004 0.21725412 0.014481631 0.042616285
## LFLU_2004 0.20151714 0.002896705 0.079454664
## CFLU_2004 0.26536822 0.095143256 0.116233548
## Simil_2011 0.26393325 0.045494272 0.051935223
## Digits_2011 0.25748201 0.019185340 0.044267602
## LFLU_2011 0.25687735 0.026871999 0.015615212
## CFLU_2011 0.30583860 0.020582107 0.096342054
## TotRecall_2004 0.36209054 0.038936317 0.041379857
## TotRecall_2011 1.00000000 0.021339543 0.035201834
## N_04 0.02133954 1.000000000 0.380387431
## N_11 0.03520183 0.380387431 1.000000000
covMat <- cov(HW2_TimeData, use = "pairwise.complete.obs")
covMat #covariance matrix. Matrix appears normal, no causes of concern for items. Diagonal elements of the variance/covariance matrix decreased slightly across time.
## idpub sexrsp byear educ92 age04
## idpub 9.630140e+07 -25.976221819 33.45245270 76.27440740 -79.83193624
## sexrsp -2.597622e+01 0.248664940 0.02734960 -0.18574520 -0.03175175
## byear 3.345245e+01 0.027349600 0.24606958 0.15187346 -0.19891373
## educ92 7.627441e+01 -0.185745203 0.15187346 5.28943410 -0.17302605
## age04 -7.983194e+01 -0.031751748 -0.19891373 -0.17302605 0.49884534
## age11 -2.299804e+02 -0.012586439 -0.19670455 -0.30006221 0.26989788
## Simil_2004 3.991450e+02 0.002182165 0.17333070 2.09102156 -0.24187824
## Digits_2004 7.826589e+02 0.121934965 0.20652436 1.22397854 -0.27440473
## LFLU_2004 4.899378e+02 0.260187846 0.20358504 2.19548522 -0.27152235
## CFLU_2004 5.881858e+01 0.459651941 0.37705917 3.62154933 -0.47671692
## Simil_2011 -1.045130e+02 -0.022579078 0.16913832 2.06106307 -0.20976724
## Digits_2011 4.882571e+02 0.058183477 0.15718613 1.10982916 -0.23940734
## LFLU_2011 4.175385e+02 0.284057797 0.27022839 2.42386590 -0.33441980
## CFLU_2011 1.299244e+03 0.489563579 0.37530786 2.80755167 -0.35986359
## TotRecall_2004 9.391789e+01 0.467079738 0.17235568 1.16511815 -0.19413600
## TotRecall_2011 3.013551e+02 0.343295182 0.23389400 1.13429372 -0.27067073
## N_04 -2.725737e+02 0.005649397 0.02319806 0.05320233 -0.05976023
## N_11 -1.097166e+02 -0.001767563 0.03396987 0.32811365 -0.08894501
## age11 Simil_2004 Digits_2004 LFLU_2004 CFLU_2004
## idpub -229.98035838 399.144970197 782.6589198 489.937830113 58.8185802
## sexrsp -0.01258644 0.002182165 0.1219350 0.260187846 0.4596519
## byear -0.19670455 0.173330700 0.2065244 0.203585036 0.3770592
## educ92 -0.30006221 2.091021558 1.2239785 2.195485222 3.6215493
## age04 0.26989788 -0.241878241 -0.2744047 -0.271522349 -0.4767169
## age11 0.84917707 -0.317451191 -0.2751803 -0.397880823 -0.6991227
## Simil_2004 -0.31745119 5.657111437 1.3311314 2.417781727 3.3461103
## Digits_2004 -0.27518025 1.331131405 9.4171447 2.510843415 3.1579402
## LFLU_2004 -0.39788082 2.417781727 2.5108434 18.940356324 8.9280685
## CFLU_2004 -0.69912265 3.346110301 3.1579402 8.928068528 37.7541443
## Simil_2011 -0.35911053 3.044747455 1.0520110 2.057132210 3.3285151
## Digits_2011 -0.27213994 1.006587351 2.7628833 2.397620286 3.6799624
## LFLU_2011 -0.45159790 2.327008014 2.4643644 10.640388029 7.8602722
## CFLU_2011 -0.72534182 2.993916532 3.2001397 7.657133909 21.2654822
## TotRecall_2004 -0.18851395 1.079735337 3.3745014 2.786483399 4.5382462
## TotRecall_2011 -0.35737180 1.560607296 1.8921297 2.533224810 4.6626632
## N_04 -0.01758030 0.326925741 0.0342083 0.006641092 0.1769225
## N_11 -0.02399269 0.474910026 0.2028156 0.534026595 1.1804908
## Simil_2011 Digits_2011 LFLU_2011 CFLU_2011
## idpub -104.51299459 488.25712449 417.53854430 1299.24434526
## sexrsp -0.02257908 0.05818348 0.28405780 0.48956358
## byear 0.16913832 0.15718613 0.27022839 0.37530786
## educ92 2.06106307 1.10982916 2.42386590 2.80755167
## age04 -0.20976724 -0.23940734 -0.33441980 -0.35986359
## age11 -0.35911053 -0.27213994 -0.45159790 -0.72534182
## Simil_2004 3.04474746 1.00658735 2.32700801 2.99391653
## Digits_2004 1.05201099 2.76288333 2.46436444 3.20013968
## LFLU_2004 2.05713221 2.39762029 10.64038803 7.65713391
## CFLU_2004 3.32851511 3.67996243 7.86027219 21.26548220
## Simil_2011 5.38484411 1.27168624 2.39948407 3.32311370
## Digits_2011 1.27168624 6.90268988 2.97387346 4.17310228
## LFLU_2011 2.39948407 2.97387346 17.48801731 8.68513275
## CFLU_2011 3.32311370 4.17310228 8.68513275 35.66045150
## TotRecall_2004 0.91983711 1.38864206 2.91433472 4.48433010
## TotRecall_2011 1.77304168 1.95105453 3.09111418 5.19984001
## N_04 0.12770595 0.03941887 0.13575019 0.08632917
## N_11 0.10314379 0.07616021 0.05187397 0.11475618
## TotRecall_2004 TotRecall_2011 N_04 N_11
## idpub 93.9178875 301.35513526 -2.725737e+02 -1.097166e+02
## sexrsp 0.4670797 0.34329518 5.649397e-03 -1.767563e-03
## byear 0.1723557 0.23389400 2.319806e-02 3.396987e-02
## educ92 1.1651182 1.13429372 5.320233e-02 3.281137e-01
## age04 -0.1941360 -0.27067073 -5.976023e-02 -8.894501e-02
## age11 -0.1885139 -0.35737180 -1.758030e-02 -2.399269e-02
## Simil_2004 1.0797353 1.56060730 3.269257e-01 4.749100e-01
## Digits_2004 3.3745014 1.89212967 3.420830e-02 2.028156e-01
## LFLU_2004 2.7864834 2.53322481 6.641092e-03 5.340266e-01
## CFLU_2004 4.5382462 4.66266321 1.769225e-01 1.180491e+00
## Simil_2011 0.9198371 1.77304168 1.277060e-01 1.031438e-01
## Digits_2011 1.3886421 1.95105453 3.941887e-02 7.616021e-02
## LFLU_2011 2.9143347 3.09111418 1.357502e-01 5.187397e-02
## CFLU_2011 4.4843301 5.19984001 8.632917e-02 1.147562e-01
## TotRecall_2004 13.4775018 3.78005292 1.117288e-01 2.353521e-01
## TotRecall_2011 3.7800529 8.44096701 4.875749e-02 6.984301e-02
## N_04 0.1117288 0.04875749 1.477595e+00 7.089121e-01
## N_11 0.2353521 0.06984301 7.089121e-01 2.350591e+00
model.CI <- '
#Latent variables
CogT1 =~ NA*Simil_2004 + a*Simil_2004 + Digits_2004 + LFLU_2004 + CFLU_2004
CogT2 =~ NA*Simil_2011 + a*Simil_2011 + Digits_2011 + LFLU_2011 + CFLU_2011
# Residuals
Simil_2004 ~~ Simil_2004
Simil_2011 ~~ Simil_2011
Digits_2004 ~~ Digits_2004
Digits_2011 ~~ Digits_2011
LFLU_2004 ~~ LFLU_2004
LFLU_2011 ~~ LFLU_2011
CFLU_2004 ~~ CFLU_2004
CFLU_2011 ~~ CFLU_2011
# Residual covariances
Simil_2004 ~~ Simil_2011
Digits_2004 ~~ Digits_2011
LFLU_2004 ~~ LFLU_2011
CFLU_2004 ~~ CFLU_2011
# Intercepts
Simil_2004 ~ nu1*1
Simil_2011 ~ nu1*1
Digits_2004 ~ nu12*1
Digits_2011 ~ nu22*1
LFLU_2004 ~ nu13*1
LFLU_2011 ~ nu23*1
CFLU_2004 ~ nu14*1
CFLU_2011 ~ nu24*1
#Latent variances/covariances
#Standardized CogT1
CogT1 ~~ 1*CogT1
#covariance
CogT2 ~~ cov*CogT1
#variance Time 2
CogT2 ~~ NA*CogT2
#Latent means
CogT1 ~ a1*1
CogT2 ~ a2*1
a1 == 0
'
model.CI.fit <- sem(model.CI, data=HW2_TimeData, missing = "FIML")
model.CI.fit
## lavaan 0.6.15 ended normally after 107 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 32
## Number of equality constraints 3
##
## Number of observations 7078
## Number of missing patterns 75
##
## Model Test User Model:
##
## Test statistic 28.999
## Degrees of freedom 15
## P-value (Chi-square) 0.016
summary(model.CI.fit, fit.measures = TRUE, standardized = T)
## lavaan 0.6.15 ended normally after 107 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 32
## Number of equality constraints 3
##
## Number of observations 7078
## Number of missing patterns 75
##
## Model Test User Model:
##
## Test statistic 28.999
## Degrees of freedom 15
## P-value (Chi-square) 0.016
##
## Model Test Baseline Model:
##
## Test statistic 7086.446
## Degrees of freedom 28
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.998
## Tucker-Lewis Index (TLI) 0.996
##
## Robust Comparative Fit Index (CFI) 0.998
## Robust Tucker-Lewis Index (TLI) 0.996
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -95272.349
## Loglikelihood unrestricted model (H1) -95257.849
##
## Akaike (AIC) 190602.698
## Bayesian (BIC) 190801.775
## Sample-size adjusted Bayesian (SABIC) 190709.620
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.011
## 90 Percent confidence interval - lower 0.005
## 90 Percent confidence interval - upper 0.018
## P-value H_0: RMSEA <= 0.050 1.000
## P-value H_0: RMSEA >= 0.080 0.000
##
## Robust RMSEA 0.016
## 90 Percent confidence interval - lower 0.004
## 90 Percent confidence interval - upper 0.026
## P-value H_0: Robust RMSEA <= 0.050 1.000
## P-value H_0: Robust RMSEA >= 0.080 0.000
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.010
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Observed
## Observed information based on Hessian
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## CogT1 =~
## Simil_2004 (a) 1.059 0.041 25.767 0.000 1.059 0.445
## Digts_2004 1.105 0.057 19.421 0.000 1.105 0.360
## LFLU_2004 2.491 0.086 28.845 0.000 2.491 0.570
## CFLU_2004 3.496 0.138 25.380 0.000 3.496 0.568
## CogT2 =~
## Simil_2011 (a) 1.059 0.041 25.767 0.000 1.021 0.439
## Digts_2011 1.252 0.073 17.163 0.000 1.207 0.458
## LFLU_2011 2.700 0.142 19.020 0.000 2.604 0.620
## CFLU_2011 3.600 0.205 17.582 0.000 3.472 0.578
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .Simil_2004 ~~
## .Sml_2011 2.117 0.082 25.680 0.000 2.117 0.475
## .Digits_2004 ~~
## .Dgt_2011 1.658 0.125 13.276 0.000 1.658 0.247
## .LFLU_2004 ~~
## .LFLU_201 5.098 0.328 15.523 0.000 5.098 0.431
## .CFLU_2004 ~~
## .CFLU_201 11.024 0.750 14.698 0.000 11.024 0.444
## CogT1 ~~
## CogT2 (cov) 0.883 0.039 22.402 0.000 0.915 0.915
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .Sm_2004 (nu1) 6.577 0.029 229.089 0.000 6.577 2.763
## .Sm_2011 (nu1) 6.577 0.029 229.089 0.000 6.577 2.827
## .Dg_2004 (nu12) 7.197 0.042 171.902 0.000 7.197 2.344
## .Dg_2011 (nu22) 7.086 0.055 129.049 0.000 7.086 2.690
## .LFLU_20 (nu13) 11.327 0.059 190.461 0.000 11.327 2.592
## .LFLU_20 (nu23) 11.782 0.100 117.506 0.000 11.782 2.804
## .CFLU_20 (nu14) 20.782 0.103 201.946 0.000 20.782 3.376
## .CFLU_20 (nu24) 20.306 0.155 130.890 0.000 20.306 3.381
## CogT1 (a1) 0.000 0.000 0.000
## CogT2 (a2) -0.281 0.030 -9.391 0.000 -0.292 -0.292
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .Simil_2004 4.543 0.102 44.745 0.000 4.543 0.802
## .Simil_2011 4.371 0.103 42.293 0.000 4.371 0.807
## .Digits_2004 8.207 0.181 45.225 0.000 8.207 0.871
## .Digits_2011 5.483 0.145 37.705 0.000 5.483 0.790
## .LFLU_2004 12.890 0.414 31.121 0.000 12.890 0.675
## .LFLU_2011 10.878 0.397 27.434 0.000 10.878 0.616
## .CFLU_2004 25.668 0.922 27.830 0.000 25.668 0.677
## .CFLU_2011 24.018 0.937 25.621 0.000 24.018 0.666
## CogT1 1.000 1.000 1.000
## CogT2 0.930 0.075 12.335 0.000 1.000 1.000
##
## Constraints:
## |Slack|
## a1 - 0 0.000
semPaths(model.CI.fit, what = "est") #Configural invariance model. Equate 1 set of lambdas/loadings for Simil_2004 and Simil_2011 ("a") and one set of intercepts ("nu1"). Latent variables include Cog_T1 (cognitive function at T1) amd Cog_T2 (cognitive function at T2). Observed variables include Simil_2004 (WAIS similarities at T1), Digits_2004 (digital ordering at T1), LFLU_2004 (letter fluency at T1), CFLU_2004 (category fluency at T1), Simil_2011 (WAIS similarities at T2), Digits_2011 (digital ordering at T2), LFLU_2011 (letter fluency at T2), and CFLU_2011 (category fluency at T2). All of the tested models had high χ2 values and the corresponding p-values were highly significant. Because χ2 is sensitive to sample size, other fit indices were considered in order to determine model fit. Both the configural invariance model and weak invariance model achieved excellent fit (CFI and TLI >.95; RMSEA < .06).
model.WI <- '
#Latent variables
CogT1 =~ NA*Simil_2004 + a*Simil_2004 + b*Digits_2004 + c*LFLU_2004 + d*CFLU_2004
CogT2 =~ NA*Simil_2011 + a*Simil_2011 + b*Digits_2011 + c*LFLU_2011 + d*CFLU_2011
# Residuals
Simil_2004 ~~ Simil_2004
Simil_2011 ~~ Simil_2011
Digits_2004 ~~ Digits_2004
Digits_2011 ~~ Digits_2011
LFLU_2004 ~~ LFLU_2004
LFLU_2011 ~~ LFLU_2011
CFLU_2004 ~~ CFLU_2004
CFLU_2011 ~~ CFLU_2011
# Residual covariances
Simil_2004 ~~ Simil_2011
Digits_2004 ~~ Digits_2011
LFLU_2004 ~~ LFLU_2011
CFLU_2004 ~~ CFLU_2011
# Intercepts
Simil_2004 ~ nu1*1
Simil_2011 ~ nu1*1
Digits_2004 ~ nu12*1
Digits_2011 ~ nu22*1
LFLU_2004 ~ nu13*1
LFLU_2011 ~ nu23*1
CFLU_2004 ~ nu14*1
CFLU_2011 ~ nu24*1
#Latent variances/covariances
#Standardized CogT1
CogT1 ~~ 1*CogT1
#covariance
CogT2 ~~ cov*CogT1
#variance Time 2
CogT2 ~~ NA*CogT2
#Latent means
CogT1 ~ a1*1
CogT2 ~ a2*1
a1 == 0
'
model.WI.fit <- sem(model.WI, data=HW2_TimeData, missing = "FIML")
model.WI.fit
## lavaan 0.6.15 ended normally after 92 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 32
## Number of equality constraints 6
##
## Number of observations 7078
## Number of missing patterns 75
##
## Model Test User Model:
##
## Test statistic 33.392
## Degrees of freedom 18
## P-value (Chi-square) 0.015
summary(model.WI.fit, fit.measures = TRUE, standardized = T)
## lavaan 0.6.15 ended normally after 92 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 32
## Number of equality constraints 6
##
## Number of observations 7078
## Number of missing patterns 75
##
## Model Test User Model:
##
## Test statistic 33.392
## Degrees of freedom 18
## P-value (Chi-square) 0.015
##
## Model Test Baseline Model:
##
## Test statistic 7086.446
## Degrees of freedom 28
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.998
## Tucker-Lewis Index (TLI) 0.997
##
## Robust Comparative Fit Index (CFI) 0.998
## Robust Tucker-Lewis Index (TLI) 0.997
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -95274.545
## Loglikelihood unrestricted model (H1) -95257.849
##
## Akaike (AIC) 190601.091
## Bayesian (BIC) 190779.574
## Sample-size adjusted Bayesian (SABIC) 190696.952
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.011
## 90 Percent confidence interval - lower 0.005
## 90 Percent confidence interval - upper 0.017
## P-value H_0: RMSEA <= 0.050 1.000
## P-value H_0: RMSEA >= 0.080 0.000
##
## Robust RMSEA 0.015
## 90 Percent confidence interval - lower 0.003
## 90 Percent confidence interval - upper 0.024
## P-value H_0: Robust RMSEA <= 0.050 1.000
## P-value H_0: Robust RMSEA >= 0.080 0.000
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.012
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Observed
## Observed information based on Hessian
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## CogT1 =~
## Simil_2004 (a) 1.034 0.038 27.566 0.000 1.034 0.435
## Digts_2004 (b) 1.153 0.044 26.035 0.000 1.153 0.374
## LFLU_2004 (c) 2.526 0.077 32.628 0.000 2.526 0.577
## CFLU_2004 (d) 3.457 0.123 28.184 0.000 3.457 0.563
## CogT2 =~
## Simil_2011 (a) 1.034 0.038 27.566 0.000 1.051 0.450
## Digts_2011 (b) 1.153 0.044 26.035 0.000 1.172 0.446
## LFLU_2011 (c) 2.526 0.077 32.628 0.000 2.567 0.612
## CFLU_2011 (d) 3.457 0.123 28.184 0.000 3.513 0.584
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .Simil_2004 ~~
## .Sml_2011 2.113 0.083 25.584 0.000 2.113 0.474
## .Digits_2004 ~~
## .Dgt_2011 1.649 0.125 13.223 0.000 1.649 0.246
## .LFLU_2004 ~~
## .LFLU_201 5.101 0.329 15.525 0.000 5.101 0.430
## .CFLU_2004 ~~
## .CFLU_201 11.011 0.750 14.682 0.000 11.011 0.443
## CogT1 ~~
## CogT2 (cov) 0.932 0.025 37.366 0.000 0.917 0.917
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .Sm_2004 (nu1) 6.577 0.029 229.588 0.000 6.577 2.770
## .Sm_2011 (nu1) 6.577 0.029 229.588 0.000 6.577 2.819
## .Dg_2004 (nu12) 7.196 0.042 171.458 0.000 7.196 2.336
## .Dg_2011 (nu22) 7.070 0.053 134.534 0.000 7.070 2.693
## .LFLU_20 (nu13) 11.327 0.060 190.161 0.000 11.327 2.586
## .LFLU_20 (nu23) 11.756 0.095 123.203 0.000 11.756 2.803
## .CFLU_20 (nu14) 20.786 0.103 202.173 0.000 20.786 3.383
## .CFLU_20 (nu24) 20.292 0.152 133.925 0.000 20.292 3.371
## CogT1 (a1) 0.000 NA 0.000 0.000
## CogT2 (a2) -0.289 0.030 -9.544 0.000 -0.285 -0.285
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .Simil_2004 4.571 0.099 46.015 0.000 4.571 0.810
## .Simil_2011 4.340 0.102 42.628 0.000 4.340 0.797
## .Digits_2004 8.158 0.177 45.969 0.000 8.158 0.860
## .Digits_2011 5.520 0.143 38.626 0.000 5.520 0.801
## .LFLU_2004 12.796 0.402 31.810 0.000 12.796 0.667
## .LFLU_2011 11.001 0.380 28.968 0.000 11.001 0.625
## .CFLU_2004 25.811 0.891 28.954 0.000 25.811 0.684
## .CFLU_2011 23.884 0.916 26.060 0.000 23.884 0.659
## CogT1 1.000 1.000 1.000
## CogT2 1.033 0.043 24.023 0.000 1.000 1.000
##
## Constraints:
## |Slack|
## a1 - 0 0.000
semPaths(model.WI.fit, what = "est") #Weak invariance model. Equate all loadings/lambdas ("a", "b", "c", and "d") and one set of intercepts ("nu1"). All of the tested models had high χ2 values and the corresponding p-values were highly significant. Because χ2 is sensitive to sample size, other fit indices were considered in order to determine model fit. Both the configural invariance model and weak invariance model achieved excellent fit (CFI and TLI >.95; RMSEA < .06). In addition, there was no significant worsening of fit when moving from the configural to the weak model (Δχ2 = 4.39, p = .22).
model.SI <- '
#Latent variables
CogT1 =~ NA*Simil_2004 + a*Simil_2004 + b*Digits_2004 + c*LFLU_2004 + d*CFLU_2004
CogT2 =~ NA*Simil_2011 + a*Simil_2011 + b*Digits_2011 + c*LFLU_2011 + d*CFLU_2011
# Residuals
Simil_2004 ~~ Simil_2004
Simil_2011 ~~ Simil_2011
Digits_2004 ~~ Digits_2004
Digits_2011 ~~ Digits_2011
LFLU_2004 ~~ LFLU_2004
LFLU_2011 ~~ LFLU_2011
CFLU_2004 ~~ CFLU_2004
CFLU_2011 ~~ CFLU_2011
# Residual covariances
Simil_2004 ~~ Simil_2011
Digits_2004 ~~ Digits_2011
LFLU_2004 ~~ LFLU_2011
CFLU_2004 ~~ CFLU_2011
# Intercepts
Simil_2004 ~ nu1*1
Simil_2011 ~ nu1*1
Digits_2004 ~ nu2*1
Digits_2011 ~ nu2*1
LFLU_2004 ~ nu3*1
LFLU_2011 ~ nu3*1
CFLU_2004 ~ nu4*1
CFLU_2011 ~ nu4*1
#Latent variances/covariances
#Standardized CogT1
CogT1 ~~ 1*CogT1
#covariance
CogT2 ~~ cov*CogT1
#variance Time 2
CogT2 ~~ NA*CogT2
#Latent means
CogT1 ~ a1*1
CogT2 ~ a2*1
a1 == 0
'
model.SI.fit <- sem(model.SI, data=HW2_TimeData, missing = "FIML")
model.SI.fit
## lavaan 0.6.15 ended normally after 87 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 32
## Number of equality constraints 9
##
## Number of observations 7078
## Number of missing patterns 75
##
## Model Test User Model:
##
## Test statistic 109.972
## Degrees of freedom 21
## P-value (Chi-square) 0.000
summary(model.SI.fit, fit.measures = TRUE, standardized = T)
## lavaan 0.6.15 ended normally after 87 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 32
## Number of equality constraints 9
##
## Number of observations 7078
## Number of missing patterns 75
##
## Model Test User Model:
##
## Test statistic 109.972
## Degrees of freedom 21
## P-value (Chi-square) 0.000
##
## Model Test Baseline Model:
##
## Test statistic 7086.446
## Degrees of freedom 28
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.987
## Tucker-Lewis Index (TLI) 0.983
##
## Robust Comparative Fit Index (CFI) 0.987
## Robust Tucker-Lewis Index (TLI) 0.983
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -95312.835
## Loglikelihood unrestricted model (H1) -95257.849
##
## Akaike (AIC) 190671.670
## Bayesian (BIC) 190829.560
## Sample-size adjusted Bayesian (SABIC) 190756.471
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.024
## 90 Percent confidence interval - lower 0.020
## 90 Percent confidence interval - upper 0.029
## P-value H_0: RMSEA <= 0.050 1.000
## P-value H_0: RMSEA >= 0.080 0.000
##
## Robust RMSEA 0.034
## 90 Percent confidence interval - lower 0.028
## 90 Percent confidence interval - upper 0.041
## P-value H_0: Robust RMSEA <= 0.050 1.000
## P-value H_0: Robust RMSEA >= 0.080 0.000
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.021
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Observed
## Observed information based on Hessian
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## CogT1 =~
## Simil_2004 (a) 1.046 0.036 28.741 0.000 1.046 0.440
## Digts_2004 (b) 1.182 0.044 27.108 0.000 1.182 0.383
## LFLU_2004 (c) 2.361 0.074 31.954 0.000 2.361 0.542
## CFLU_2004 (d) 3.624 0.120 30.146 0.000 3.624 0.586
## CogT2 =~
## Simil_2011 (a) 1.046 0.036 28.741 0.000 1.069 0.458
## Digts_2011 (b) 1.182 0.044 27.108 0.000 1.208 0.459
## LFLU_2011 (c) 2.361 0.074 31.954 0.000 2.412 0.578
## CFLU_2011 (d) 3.624 0.120 30.146 0.000 3.704 0.610
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .Simil_2004 ~~
## .Sml_2011 2.084 0.082 25.493 0.000 2.084 0.471
## .Digits_2004 ~~
## .Dgt_2011 1.599 0.124 12.852 0.000 1.599 0.240
## .LFLU_2004 ~~
## .LFLU_201 5.563 0.314 17.693 0.000 5.563 0.446
## .CFLU_2004 ~~
## .CFLU_201 10.176 0.746 13.633 0.000 10.176 0.422
## CogT1 ~~
## CogT2 (cov) 0.941 0.025 37.130 0.000 0.920 0.920
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .Sml_2004 (nu1) 6.572 0.027 245.557 0.000 6.572 2.766
## .Sml_2011 (nu1) 6.572 0.027 245.557 0.000 6.572 2.816
## .Dgt_2004 (nu2) 7.124 0.035 205.432 0.000 7.124 2.309
## .Dgt_2011 (nu2) 7.124 0.035 205.432 0.000 7.124 2.706
## .LFLU_200 (nu3) 11.528 0.054 214.558 0.000 11.528 2.648
## .LFLU_201 (nu3) 11.528 0.054 214.558 0.000 11.528 2.761
## .CFLU_200 (nu4) 20.567 0.096 213.699 0.000 20.567 3.323
## .CFLU_201 (nu4) 20.567 0.096 213.699 0.000 20.567 3.389
## CogT1 (a1) 0.000 0.000 0.000
## CogT2 (a2) -0.275 0.017 -16.088 0.000 -0.269 -0.269
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .Simil_2004 4.550 0.099 45.980 0.000 4.550 0.806
## .Simil_2011 4.304 0.101 42.642 0.000 4.304 0.790
## .Digits_2004 8.126 0.178 45.630 0.000 8.126 0.853
## .Digits_2011 5.472 0.143 38.216 0.000 5.472 0.790
## .LFLU_2004 13.387 0.383 34.915 0.000 13.387 0.706
## .LFLU_2011 11.608 0.361 32.174 0.000 11.608 0.666
## .CFLU_2004 25.170 0.903 27.881 0.000 25.170 0.657
## .CFLU_2011 23.105 0.923 25.044 0.000 23.105 0.627
## CogT1 1.000 1.000 1.000
## CogT2 1.045 0.044 23.829 0.000 1.000 1.000
##
## Constraints:
## |Slack|
## a1 - 0 0.000
semPaths(model.SI.fit, what = "est") #Strong invariance model. Equate all loadings/lambdas ("a", "b", "c", and "d") and intercepts ("nu1", "nu2", "nu3", and "nu4"). When further constraining the weak invariance model to the strong invariance model the fit significantly worsened (Δχ2 = 76.58, p < .001). However, the strong invariance model still demonstrated excellent fit indices (CFI and TLI >.95; RMSEA < .06), thus strong invariance measurement was achieved.
model.STI <- '
#Latent variables
CogT1 =~ NA*Simil_2004 + a*Simil_2004 + b*Digits_2004 + c*LFLU_2004 + d*CFLU_2004
CogT2 =~ NA*Simil_2011 + a*Simil_2011 + b*Digits_2011 + c*LFLU_2011 + d*CFLU_2011
# Residuals
Simil_2004 ~~ f*Simil_2004
Simil_2011 ~~ f*Simil_2011
Digits_2004 ~~ g*Digits_2004
Digits_2011 ~~ g*Digits_2011
LFLU_2004 ~~ h*LFLU_2004
LFLU_2011 ~~ h*LFLU_2011
CFLU_2004 ~~ i*CFLU_2004
CFLU_2011 ~~ i*CFLU_2011
# Residual covariances
Simil_2004 ~~ Simil_2011
Digits_2004 ~~ Digits_2011
LFLU_2004 ~~ LFLU_2011
CFLU_2004 ~~ CFLU_2011
# Intercepts
Simil_2004 ~ nu1*1
Simil_2011 ~ nu1*1
Digits_2004 ~ nu2*1
Digits_2011 ~ nu2*1
LFLU_2004 ~ nu3*1
LFLU_2011 ~ nu3*1
CFLU_2004 ~ nu4*1
CFLU_2011 ~ nu4*1
#Latent variances/covariances
#Standardized CogT1
CogT1 ~~ 1*CogT1
#covariance
CogT2 ~~ cov*CogT1
#variance Time 2
CogT2 ~~ NA*CogT2
#Latent means
CogT1 ~ a1*1
CogT2 ~ a2*1
a1 == 0
'
model.STI.fit <- sem(model.STI, data=HW2_TimeData, missing = "FIML")
model.STI.fit
## lavaan 0.6.15 ended normally after 75 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 32
## Number of equality constraints 13
##
## Number of observations 7078
## Number of missing patterns 75
##
## Model Test User Model:
##
## Test statistic 291.616
## Degrees of freedom 25
## P-value (Chi-square) 0.000
summary(model.STI.fit, fit.measures = TRUE, standardized = T)
## lavaan 0.6.15 ended normally after 75 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 32
## Number of equality constraints 13
##
## Number of observations 7078
## Number of missing patterns 75
##
## Model Test User Model:
##
## Test statistic 291.616
## Degrees of freedom 25
## P-value (Chi-square) 0.000
##
## Model Test Baseline Model:
##
## Test statistic 7086.446
## Degrees of freedom 28
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.962
## Tucker-Lewis Index (TLI) 0.958
##
## Robust Comparative Fit Index (CFI) 0.965
## Robust Tucker-Lewis Index (TLI) 0.961
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -95403.657
## Loglikelihood unrestricted model (H1) -95257.849
##
## Akaike (AIC) 190845.314
## Bayesian (BIC) 190975.744
## Sample-size adjusted Bayesian (SABIC) 190915.367
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.039
## 90 Percent confidence interval - lower 0.035
## 90 Percent confidence interval - upper 0.043
## P-value H_0: RMSEA <= 0.050 1.000
## P-value H_0: RMSEA >= 0.080 0.000
##
## Robust RMSEA 0.052
## 90 Percent confidence interval - lower 0.046
## 90 Percent confidence interval - upper 0.058
## P-value H_0: Robust RMSEA <= 0.050 0.280
## P-value H_0: Robust RMSEA >= 0.080 0.000
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.041
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Observed
## Observed information based on Hessian
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## CogT1 =~
## Simil_2004 (a) 1.091 0.037 29.821 0.000 1.091 0.461
## Digts_2004 (b) 1.208 0.046 26.532 0.000 1.208 0.416
## LFLU_2004 (c) 2.425 0.075 32.527 0.000 2.425 0.565
## CFLU_2004 (d) 3.703 0.121 30.602 0.000 3.703 0.599
## CogT2 =~
## Simil_2011 (a) 1.091 0.037 29.821 0.000 1.046 0.446
## Digts_2011 (b) 1.208 0.046 26.532 0.000 1.158 0.402
## LFLU_2011 (c) 2.425 0.075 32.527 0.000 2.324 0.549
## CFLU_2011 (d) 3.703 0.121 30.602 0.000 3.549 0.583
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .Simil_2004 ~~
## .Sml_2011 2.069 0.083 25.044 0.000 2.069 0.469
## .Digits_2004 ~~
## .Dgt_2011 1.702 0.131 12.992 0.000 1.702 0.244
## .LFLU_2004 ~~
## .LFLU_201 5.569 0.318 17.540 0.000 5.569 0.444
## .CFLU_2004 ~~
## .CFLU_201 10.412 0.754 13.816 0.000 10.412 0.426
## CogT1 ~~
## CogT2 (cov) 0.885 0.022 40.260 0.000 0.923 0.923
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .Sml_2004 (nu1) 6.572 0.027 244.621 0.000 6.572 2.776
## .Sml_2011 (nu1) 6.572 0.027 244.621 0.000 6.572 2.801
## .Dgt_2004 (nu2) 7.136 0.035 206.075 0.000 7.136 2.459
## .Dgt_2011 (nu2) 7.136 0.035 206.075 0.000 7.136 2.476
## .LFLU_200 (nu3) 11.504 0.054 214.995 0.000 11.504 2.681
## .LFLU_201 (nu3) 11.504 0.054 214.995 0.000 11.504 2.716
## .CFLU_200 (nu4) 20.573 0.096 213.681 0.000 20.573 3.331
## .CFLU_201 (nu4) 20.573 0.096 213.681 0.000 20.573 3.380
## CogT1 (a1) 0.000 0.000 0.000
## CogT2 (a2) -0.264 0.016 -16.084 0.000 -0.276 -0.276
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .Simil_2004 (f) 4.414 0.083 53.253 0.000 4.414 0.788
## .Simil_2011 (f) 4.414 0.083 53.253 0.000 4.414 0.801
## .Digts_2004 (g) 6.966 0.126 55.373 0.000 6.966 0.827
## .Digts_2011 (g) 6.966 0.126 55.373 0.000 6.966 0.839
## .LFLU_2004 (h) 12.534 0.314 39.936 0.000 12.534 0.681
## .LFLU_2011 (h) 12.534 0.314 39.936 0.000 12.534 0.699
## .CFLU_2004 (i) 24.448 0.762 32.101 0.000 24.448 0.641
## .CFLU_2011 (i) 24.448 0.762 32.101 0.000 24.448 0.660
## CogT1 1.000 1.000 1.000
## CogT2 0.919 0.036 25.423 0.000 1.000 1.000
##
## Constraints:
## |Slack|
## a1 - 0 0.000
semPaths(model.STI.fit, what = "est") #Strict invariance model. Equate all loadings/lambdas ("a", "b", "c", and "d"), intercepts ("nu1", "nu2", "nu3", and "nu4"), and residuals ("f", "g", "h", and "i"). In addition, when further constraining the strong invariance model to the strict invariance model the fit significantly worsened (Δχ2 = 181.64, p < .001). However, the strict invariance model still demonstrated excellent fit indices (CFI and TLI >.95; RMSEA < .06).
Mod.Fit.Comp <- compareFit(model.CI.fit, model.WI.fit, model.SI.fit, model.STI.fit)
summary(Mod.Fit.Comp) #fit comparisons across models. Based on these nested model comparisons, strict invariance measurement was established, thus latent changes in cognitive functioning between timepoint 1 and timepoint 2 cannot be assumed to be because of measurement error. Given that at time point 2 the standardized latent mean score was -.26 with a variance of .92, it can be concluded that there was a slight decrease in overall cognitive functioning over time. In summary, despite the strict invariance model not being the best-fitting model in comparison to the configural invariance model, weak invariance model, and strong invariance model, the fit indices were still excellent, thus it can be determined that overall cognitive functioning was measured at both time points.
## ################### Nested Model Comparison #########################
##
## Chi-Squared Difference Test
##
## Df AIC BIC Chisq Chisq diff RMSEA Df diff Pr(>Chisq)
## model.CI.fit 15 190603 190802 28.999
## model.WI.fit 18 190601 190780 33.392 4.393 0.008100 3 0.222
## model.SI.fit 21 190672 190830 109.972 76.580 0.058866 3 <2e-16
## model.STI.fit 25 190845 190976 291.616 181.644 0.079212 4 <2e-16
##
## model.CI.fit
## model.WI.fit
## model.SI.fit ***
## model.STI.fit ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## ####################### Model Fit Indices ###########################
## chisq df pvalue rmsea cfi tli srmr aic
## model.CI.fit 28.999† 15 .016 .011 0.998† 0.996 .010† 190602.698
## model.WI.fit 33.392 18 .015 .011† 0.998 0.997† .012 190601.091†
## model.SI.fit 109.972 21 .000 .024 .987 .983 .021 190671.670
## model.STI.fit 291.616 25 .000 .039 .962 .958 .041 190845.314
## bic
## model.CI.fit 190801.775
## model.WI.fit 190779.574†
## model.SI.fit 190829.560
## model.STI.fit 190975.744
##
## ################## Differences in Fit Indices #######################
## df rmsea cfi tli srmr aic bic
## model.WI.fit - model.CI.fit 3 0.000 0.000 0.000 0.001 -1.607 -22.201
## model.SI.fit - model.WI.fit 3 0.013 -0.010 -0.013 0.009 70.580 49.985
## model.STI.fit - model.SI.fit 4 0.014 -0.025 -0.025 0.020 173.644 146.185
CI.Conf <- CI.RMSEA(rmsea = .011, df = 15, N=7078, clevel = .95)
CI.Conf
## $Lower.CI
## [1] 0.00135613
##
## $RMSEA
## [1] 0.011
##
## $Upper.CI
## [1] 0.01837454
CI.Weak <- CI.RMSEA(rmsea = .011, df = 18, N=7078, clevel = .95)
CI.Weak
## $Lower.CI
## [1] 0.00293246
##
## $RMSEA
## [1] 0.011
##
## $Upper.CI
## [1] 0.0177394
CI.Strong <- CI.RMSEA(rmsea = .024, df = 21, N=7078, clevel = .95)
CI.Strong
## $Lower.CI
## [1] 0.01871014
##
## $RMSEA
## [1] 0.024
##
## $Upper.CI
## [1] 0.02946891
CI.Strict <- CI.RMSEA(rmsea = .039, df = 25, N=7078, clevel = .95)
CI.Strict #confidence intervals for each model
## $Lower.CI
## [1] 0.03429982
##
## $RMSEA
## [1] 0.039
##
## $Upper.CI
## [1] 0.04382587
sessionInfo() #Retrieving session information
## R version 4.2.2 (2022-10-31)
## Platform: aarch64-apple-darwin20 (64-bit)
## Running under: macOS Ventura 13.2.1
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] naniar_0.6.1 GAIPE_1.1 psych_2.2.5 haven_2.5.1 semPlot_1.1.6
## [6] semTools_0.5-6 lavaan_0.6-15
##
## loaded via a namespace (and not attached):
## [1] minqa_1.2.5 colorspace_2.0-3 deldir_1.0-6
## [4] ellipsis_0.3.2 visdat_0.5.3 htmlTable_2.4.1
## [7] corpcor_1.6.10 base64enc_0.1-3 rstudioapi_0.14
## [10] farver_2.1.1 fansi_1.0.3 splines_4.2.2
## [13] mnormt_2.1.0 cachem_1.0.6 knitr_1.40
## [16] glasso_1.11 Formula_1.2-4 jsonlite_1.8.0
## [19] nloptr_2.0.3 cluster_2.1.4 png_0.1-7
## [22] compiler_4.2.2 backports_1.4.1 assertthat_0.2.1
## [25] Matrix_1.5-1 fastmap_1.1.0 cli_3.4.0
## [28] htmltools_0.5.5 tools_4.2.2 igraph_1.4.2
## [31] OpenMx_2.21.8 coda_0.19-4 gtable_0.3.1
## [34] glue_1.6.2 reshape2_1.4.4 dplyr_1.0.10
## [37] Rcpp_1.0.9 carData_3.0-5 jquerylib_0.1.4
## [40] vctrs_0.5.1 nlme_3.1-160 lisrelToR_0.1.5
## [43] xfun_0.33 stringr_1.4.1 openxlsx_4.2.5.1
## [46] lme4_1.1-30 lifecycle_1.0.3 gtools_3.9.4
## [49] XML_3.99-0.14 MASS_7.3-58.1 scales_1.2.1
## [52] hms_1.1.2 kutils_1.70 parallel_4.2.2
## [55] RColorBrewer_1.1-3 yaml_2.3.5 pbapply_1.7-0
## [58] gridExtra_2.3 ggplot2_3.4.0 sass_0.4.2
## [61] rpart_4.1.19 latticeExtra_0.6-30 stringi_1.7.8
## [64] highr_0.9 sem_3.1-15 checkmate_2.1.0
## [67] boot_1.3-28 zip_2.2.2 rlang_1.0.6
## [70] pkgconfig_2.0.3 arm_1.13-1 evaluate_0.16
## [73] lattice_0.20-45 purrr_0.3.4 labeling_0.4.2
## [76] htmlwidgets_1.6.2 tidyselect_1.1.2 plyr_1.8.7
## [79] magrittr_2.0.3 R6_2.5.1 generics_0.1.3
## [82] Hmisc_4.7-1 DBI_1.1.3 pillar_1.8.1
## [85] foreign_0.8-83 withr_2.5.0 rockchalk_1.8.157
## [88] survival_3.4-0 abind_1.4-5 nnet_7.3-18
## [91] tibble_3.1.8 interp_1.1-3 fdrtool_1.2.17
## [94] utf8_1.2.2 rmarkdown_2.16 jpeg_0.1-9
## [97] grid_4.2.2 qgraph_1.9.4 data.table_1.14.2
## [100] pbivnorm_0.6.0 forcats_0.5.2 digest_0.6.29
## [103] xtable_1.8-4 mi_1.1 tidyr_1.2.1
## [106] RcppParallel_5.1.7 stats4_4.2.2 munsell_0.5.0
## [109] bslib_0.4.0 quadprog_1.5-8
citation("lavaan")
##
## To cite lavaan in publications use:
##
## Yves Rosseel (2012). lavaan: An R Package for Structural Equation
## Modeling. Journal of Statistical Software, 48(2), 1-36.
## https://doi.org/10.18637/jss.v048.i02
##
## A BibTeX entry for LaTeX users is
##
## @Article{,
## title = {{lavaan}: An {R} Package for Structural Equation Modeling},
## author = {Yves Rosseel},
## journal = {Journal of Statistical Software},
## year = {2012},
## volume = {48},
## number = {2},
## pages = {1--36},
## doi = {10.18637/jss.v048.i02},
## }
citation("semPlot")
##
## To cite package 'semPlot' in publications use:
##
## Epskamp S (2022). _semPlot: Path Diagrams and Visual Analysis of
## Various SEM Packages' Output_. R package version 1.1.6,
## <https://CRAN.R-project.org/package=semPlot>.
##
## A BibTeX entry for LaTeX users is
##
## @Manual{,
## title = {semPlot: Path Diagrams and Visual Analysis of Various SEM Packages'
## Output},
## author = {Sacha Epskamp},
## year = {2022},
## note = {R package version 1.1.6},
## url = {https://CRAN.R-project.org/package=semPlot},
## }
citation("semTools")
##
## The maintainer and *primary* contributors to this package are listed as
## authors, but this package is a collaborative work. The maintainer(s)
## cannot take credit for others' contributions. Whenever possible, please
## cite the paper(s) associated with the development of a particular
## function (e.g., permuteMeasEq or parcelAllocation) or tutorials about
## how to use them (e.g., probe2WayMC and related functions), which are
## listed in the References section of its associated help page.
## Otherwise, please use the following citation for the package as a
## whole:
##
## Jorgensen, T. D., Pornprasertmanit, S., Schoemann, A. M., & Rosseel,
## Y. (2022). semTools: Useful tools for structural equation modeling. R
## package version 0.5-6. Retrieved from
## https://CRAN.R-project.org/package=semTools
##
## A BibTeX entry for LaTeX users is
##
## @Manual{,
## title = {\texttt{semTools}: {U}seful tools for structural equation modeling},
## author = {Terrence D. Jorgensen and Sunthud Pornprasertmanit and Alexander M. Schoemann and Yves Rosseel},
## year = {2022},
## note = {R package version 0.5-6},
## url = {https://CRAN.R-project.org/package=semTools},
## }
citation ("haven")
##
## To cite package 'haven' in publications use:
##
## Wickham H, Miller E, Smith D (2022). _haven: Import and Export
## 'SPSS', 'Stata' and 'SAS' Files_. R package version 2.5.1,
## <https://CRAN.R-project.org/package=haven>.
##
## A BibTeX entry for LaTeX users is
##
## @Manual{,
## title = {haven: Import and Export 'SPSS', 'Stata' and 'SAS' Files},
## author = {Hadley Wickham and Evan Miller and Danny Smith},
## year = {2022},
## note = {R package version 2.5.1},
## url = {https://CRAN.R-project.org/package=haven},
## }
citation("psych")
##
## To cite the psych package in publications use:
##
## Revelle, W. (2022) psych: Procedures for Personality and
## Psychological Research, Northwestern University, Evanston, Illinois,
## USA, https://CRAN.R-project.org/package=psych Version = 2.2.5.
##
## A BibTeX entry for LaTeX users is
##
## @Manual{,
## title = {psych: Procedures for Psychological, Psychometric, and Personality Research},
## author = {William Revelle},
## organization = { Northwestern University},
## address = { Evanston, Illinois},
## year = {2022},
## note = {R package version 2.2.5},
## url = {https://CRAN.R-project.org/package=psych},
## }
citation("GAIPE")
##
## To cite package 'GAIPE' in publications use:
##
## Lin T (2022). _GAIPE: Graphical Extension with Accuracy in Parameter
## Estimation (GAIPE)_. R package version 1.1,
## <https://CRAN.R-project.org/package=GAIPE>.
##
## A BibTeX entry for LaTeX users is
##
## @Manual{,
## title = {GAIPE: Graphical Extension with Accuracy in Parameter Estimation
## (GAIPE)},
## author = {Tzu-Yao Lin},
## year = {2022},
## note = {R package version 1.1},
## url = {https://CRAN.R-project.org/package=GAIPE},
## }
##
## ATTENTION: This citation information has been auto-generated from the
## package DESCRIPTION file and may need manual editing, see
## 'help("citation")'.
citation("naniar") #getting package citations
##
## To cite package 'naniar' in publications use:
##
## Tierney N, Cook D, McBain M, Fay C (2021). _naniar: Data Structures,
## Summaries, and Visualisations for Missing Data_. R package version
## 0.6.1, <https://CRAN.R-project.org/package=naniar>.
##
## A BibTeX entry for LaTeX users is
##
## @Manual{,
## title = {naniar: Data Structures, Summaries, and Visualisations for Missing Data},
## author = {Nicholas Tierney and Di Cook and Miles McBain and Colin Fay},
## year = {2021},
## note = {R package version 0.6.1},
## url = {https://CRAN.R-project.org/package=naniar},
## }