Multifactor Specification Erin Buchanan Professor DataCamp - - PowerPoint PPT Presentation

multifactor specification
SMART_READER_LITE
LIVE PREVIEW

Multifactor Specification Erin Buchanan Professor DataCamp - - PowerPoint PPT Presentation

DataCamp Structural Equation Modeling with lavaan in R STRUCTURAL EQUATION MODELING WITH LAVAAN IN R Multifactor Specification Erin Buchanan Professor DataCamp Structural Equation Modeling with lavaan in R Multifactor models visual.model


slide-1
SLIDE 1

DataCamp Structural Equation Modeling with lavaan in R

Multifactor Specification

STRUCTURAL EQUATION MODELING WITH LAVAAN IN R

Erin Buchanan

Professor

slide-2
SLIDE 2

DataCamp Structural Equation Modeling with lavaan in R

Multifactor models

visual.model <- 'visual =~ x1 + x2 + x3 + x7 + x8 + x9' visual.fit <- cfa(model = visual.model, data = HolzingerSwineford1939) summary(visual.fit, standardized = TRUE, fit.measures = TRUE) User model versus baseline model: Comparative Fit Index (CFI) 0.701 Tucker-Lewis Index (TLI) 0.502 ___output shortened___ Root Mean Square Error of Approximation: RMSEA 0.190 90 Percent Confidence Interval 0.158 0.223 P-value RMSEA <= 0.05 0.000 Standardized Root Mean Square Residual: SRMR 0.111

slide-3
SLIDE 3

DataCamp Structural Equation Modeling with lavaan in R

Why not two small models?

Possible parameters = 3*(3+1)/2 = 6 Estimated parameters = 2 coefficients + 4 variances = 6 df = 6 - 6 = 0

visual.model <- 'visual =~ x1 + x2 + x3' visual.fit <- cfa(model = visual.model, data = HolzingerSwineford1939) summary(visual.fit, standardized = TRUE, fit.measures = TRUE) speed.model <- 'speed =~ x7 + x8 + x9' speed.fit <- cfa(model = speed.model, data = HolzingerSwineford1939) summary(speed.fit, standardized = TRUE, fit.measures = TRUE) Number of observations 301 Estimator ML Minimum Function Test Statistic 0.000 Degrees of freedom 0 Minimum Function Value 0.0000000000000

slide-4
SLIDE 4

DataCamp Structural Equation Modeling with lavaan in R

Specify Constraints

Constraints set parameters to be equal Gain df by estimating less numbers Use words to set equality constraints

visual.model <- 'visual =~ x1 + a*x2 + a*x3'

slide-5
SLIDE 5

DataCamp Structural Equation Modeling with lavaan in R

Output with Constraints

visual.model <- 'visual =~ x1 + a*x2 + a*x3' visual.fit <- cfa(model = visual.model, data = HolzingerSwineford1939) summary(visual.fit, standardized = TRUE, fit.measures = TRUE) Number of observations 301 Estimator ML Minimum Function Test Statistic 3.783 Degrees of freedom 1 P-value (Chi-square) 0.052 ___ Latent Variables: Estimate Std.Err z-value P(>|z|) Std.lv Std.all visual =~ x1 1.000 0.745 0.639 x2 (a) 0.910 0.142 6.397 0.000 0.678 0.562 x3 (a) 0.910 0.142 6.397 0.000 0.678 0.614

slide-6
SLIDE 6

DataCamp Structural Equation Modeling with lavaan in R

Specify a Multifactor Model

twofactor.model <- 'visual =~ x1 + x2 + x3 speed =~ x7 + x8 + x9' twofactor.fit <- cfa(model = twofactor.model, data = HolzingerSwineford1939) summary(twofactor.fit, standardized = TRUE, fit.measures = TRUE) Number of observations 301 Estimator ML Minimum Function Test Statistic 47.413 Degrees of freedom 8 P-value (Chi-square) 0.000

slide-7
SLIDE 7

DataCamp Structural Equation Modeling with lavaan in R

Let's practice!

STRUCTURAL EQUATION MODELING WITH LAVAAN IN R

slide-8
SLIDE 8

DataCamp Structural Equation Modeling with lavaan in R

Model Structure

STRUCTURAL EQUATION MODELING WITH LAVAAN IN R

Erin Buchanan

Professor

slide-9
SLIDE 9

DataCamp Structural Equation Modeling with lavaan in R

Multifactor Model Estimation

twofactor.model <- 'visual =~ x1 + x2 + x3 speed =~ x7 + x8 + x9'

slide-10
SLIDE 10

DataCamp Structural Equation Modeling with lavaan in R

Multifactor Model Estimation

twofactor.model <- 'visual =~ x1 + x2 + x3 speed =~ x7 + x8 + x9'

slide-11
SLIDE 11

DataCamp Structural Equation Modeling with lavaan in R

Summary Output

twofactor.model <- 'visual =~ x1 + x2 + x3 speed =~ x7 + x8 + x9' twofactor.fit <- cfa(model = twofactor.model, data = HolzingerSwineford1939) summary(twofactor.fit, standardized = TRUE, fit.measures = TRUE) Latent Variables: Estimate Std.Err z-value P(>|z|) Std.lv Std.all visual =~ x1 1.000 0.777 0.667 x2 0.690 0.124 5.585 0.000 0.536 0.456 x3 0.985 0.160 6.157 0.000 0.766 0.678 speed =~ x7 1.000 0.622 0.572 x8 1.204 0.170 7.090 0.000 0.749 0.741 x9 1.052 0.147 7.142 0.000 0.654 0.649 Covariances: Estimate Std.Err z-value P(>|z|) Std.lv Std.all visual ~~ speed 0.223 0.052 4.290 0.000 0.460 0.460

slide-12
SLIDE 12

DataCamp Structural Equation Modeling with lavaan in R

Model Specification Syntax

=~ creates latent variables ~~ creates covariance between variables ~ creates direct prediction between variables

Remember, y ~ x to specify direction

Covariances: Estimate Std.Err z-value P(>|z|) Std.lv Std.all visual ~~ speed 0.223 0.052 4.290 0.000 0.460 0.460

slide-13
SLIDE 13

DataCamp Structural Equation Modeling with lavaan in R

Edit the Model

twofactor.model <- 'visual =~ x1 + x2 + x3 speed =~ x7 + x8 + x9 speed ~~ 0*visual' Covariances: Estimate Std.Err z-value P(>|z|) Std.lv Std.all speed ~~ visual 0.000 0.000 0.000 twofactor.model <- 'visual =~ x1 + x2 + x3 speed =~ x7 + x8 + x9 speed~visual' Regressions: Estimate Std.Err z-value P(>|z|) Std.lv Std.all speed ~ visual 0.368 0.083 4.439 0.000 0.460 0.460

slide-14
SLIDE 14

DataCamp Structural Equation Modeling with lavaan in R

Let's practice!

STRUCTURAL EQUATION MODELING WITH LAVAAN IN R

slide-15
SLIDE 15

DataCamp Structural Equation Modeling with lavaan in R

Modification Indices

STRUCTURAL EQUATION MODELING WITH LAVAAN IN R

Erin Buchanan

Professor

slide-16
SLIDE 16

DataCamp Structural Equation Modeling with lavaan in R

Updating Poor Models

twofactor.model <- 'visual =~ x1 + x2 + x3 speed =~ x7 + x8 + x9' twofactor.fit <- cfa(model = twofactor.model, data = HolzingerSwineford1939) summary(twofactor.fit, standardized = TRUE, fit.measures = TRUE) User model versus baseline model: Comparative Fit Index (CFI) 0.879 Tucker-Lewis Index (TLI) 0.774 _ _ _ Root Mean Square Error of Approximation: RMSEA 0.128 90 Percent Confidence Interval 0.094 0.164 P-value RMSEA <= 0.05 0.000 Standardized Root Mean Square Residual: SRMR 0.079

slide-17
SLIDE 17

DataCamp Structural Equation Modeling with lavaan in R

Updating Poor Models

Latent Variables: Estimate Std.Err z-value P(>|z|) Std.lv Std.all visual =~ x1 1.000 0.777 0.667 x2 0.690 0.124 5.585 0.000 0.536 0.456 x3 0.985 0.160 6.157 0.000 0.766 0.678 speed =~ x7 1.000 0.622 0.572 x8 1.204 0.170 7.090 0.000 0.749 0.741 x9 1.052 0.147 7.142 0.000 0.654 0.649 Variances: Estimate Std.Err z-value P(>|z|) Std.lv Std.all .x1 0.754 0.110 6.838 0.000 0.754 0.555 .x2 1.094 0.103 10.661 0.000 1.094 0.792 .x3 0.688 0.105 6.557 0.000 0.688 0.540 .x7 0.796 0.082 9.756 0.000 0.796 0.673 .x8 0.461 0.077 6.002 0.000 0.461 0.451 .x9 0.587 0.071 8.273 0.000 0.587 0.578 visual 0.604 0.130 4.650 0.000 1.000 1.000 speed 0.387 0.087 4.457 0.000 1.000 1.000 var(HolzingerSwineford1939$x1) [1] 1.362898

slide-18
SLIDE 18

DataCamp Structural Equation Modeling with lavaan in R

Modification Indices

Add one at a time Add parameters that make sense

modificationindices(twofactor.fit, sort = TRUE) lhs op rhs mi epc sepc.lv sepc.all sepc.nox 34 x7 ~~ x8 35.521 0.624 0.624 0.568 0.568 18 visual =~ x9 35.521 0.659 0.512 0.508 0.508 36 x8 ~~ x9 19.041 -0.527 -0.527 -0.517 -0.517 16 visual =~ x7 19.041 -0.503 -0.391 -0.359 -0.359 26 x1 ~~ x9 11.428 0.177 0.177 0.151 0.151 28 x2 ~~ x7 9.096 -0.184 -0.184 -0.144 -0.144 17 visual =~ x8 3.557 -0.227 -0.176 -0.175 -0.175 35 x7 ~~ x9 3.557 -0.164 -0.164 -0.150 -0.150 24 x1 ~~ x7 3.022 -0.100 -0.100 -0.079 -0.079 19 speed =~ x1 2.815 0.309 0.192 0.165 0.165 27 x2 ~~ x3 2.815 0.174 0.174 0.131 0.131 33 x3 ~~ x9 2.793 0.085 0.085 0.074 0.074 23 x1 ~~ x3 2.632 -0.298 -0.298 -0.227 -0.227 _ _ _

slide-19
SLIDE 19

DataCamp Structural Equation Modeling with lavaan in R

Updating the Model

34 x7 ~~ x8 35.521 0.624 0.624 0.568 0.568 twofactor.model <- 'visual =~ x1 + x2 + x3 speed =~ x7 + x8 + x9 x7 ~~ x8' twofactor.fit <- cfa(model = twofactor.model, data = HolzingerSwineford1939) summary(twofactor.fit, standardized = TRUE, fit.measures = TRUE) User model versus baseline model: Comparative Fit Index (CFI) 0.976 Tucker-Lewis Index (TLI) 0.949 _ _ _ Root Mean Square Error of Approximation: RMSEA 0.061 90 Percent Confidence Interval 0.013 0.104 P-value RMSEA <= 0.05 0.295 Standardized Root Mean Square Residual: SRMR 0.044

slide-20
SLIDE 20

DataCamp Structural Equation Modeling with lavaan in R

Let's practice!

STRUCTURAL EQUATION MODELING WITH LAVAAN IN R

slide-21
SLIDE 21

DataCamp Structural Equation Modeling with lavaan in R

Model Comparison

STRUCTURAL EQUATION MODELING WITH LAVAAN IN R

Erin Buchanan

Professor

slide-22
SLIDE 22

DataCamp Structural Equation Modeling with lavaan in R

Create Two Models

twofactor.model <- 'visual =~ x1 + x2 + x3 speed =~ x7 + x8 + x9' twofactor.model1 <- 'visual =~ x1 + x2 + x3 speed =~ x7 + x8 + x9 x7 ~~ x8' twofactor.fit <- cfa(model = twofactor.model, data = HolzingerSwineford1939) twofactor.fit1 <- cfa(model = twofactor.model1, data = HolzingerSwineford1939)

slide-23
SLIDE 23

DataCamp Structural Equation Modeling with lavaan in R

Chi-Square Comparison

Chi-square difference created by subtracting models Must increase by at least 3.84 to be significant at p < .05 Only useful for models with the same variables

anova(twofactor.fit, twofactor.fit1) Chi Square Difference Test Df AIC BIC Chisq Chisq diff Df diff Pr(>Chisq) twofactor.fit1 7 5150.5 5202.4 14.753 twofactor.fit 8 5181.2 5229.4 47.413 32.661 1 0.00000001097 ***

  • Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
slide-24
SLIDE 24

DataCamp Structural Equation Modeling with lavaan in R

Fit Index Comparison

Compare fit indices for non-nested models Get more fit indices with fitmeasures()

fitmeasures(twofactor.fit) npar fmin chisq 13.000 0.079 47.413 df pvalue baseline.chisq 8.000 0.000 341.721 baseline.df baseline.pvalue cfi 15.000 0.000 0.879 tli nnfi rfi 0.774 0.774 0.740 nfi pnfi ifi 0.861 0.459 0.882 rni logl unrestricted.logl 0.879 -2577.584 -2553.877 aic bic ntotal 5181.168 5229.361 301.000 bic2 rmsea rmsea.ci.lower 5188.132 0.128 0.094 rmsea.ci.upper rmsea.pvalue rmr 0.164 0.000 0.096 _ _ _

slide-25
SLIDE 25

DataCamp Structural Equation Modeling with lavaan in R

Fit Index Comparison

fitmeasures(twofactor.fit, c("aic", "ecvi")) aic ecvi 5181.168 0.244 fitmeasures(twofactor.fit1, c("aic", "ecvi")) aic ecvi 5150.508 0.142

slide-26
SLIDE 26

DataCamp Structural Equation Modeling with lavaan in R

Let's practice!

STRUCTURAL EQUATION MODELING WITH LAVAAN IN R