Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Degrees of freedom #369

Closed
2 tasks done
M-E-Rademaker opened this issue Feb 21, 2020 · 1 comment
Closed
2 tasks done

Degrees of freedom #369

M-E-Rademaker opened this issue Feb 21, 2020 · 1 comment
Labels
question Further information is requested Review existing code Issues related to reviewing existing code
Projects

Comments

@M-E-Rademaker
Copy link
Collaborator

M-E-Rademaker commented Feb 21, 2020

There are still some open questions concerning the degrees of freedom calculation

  • Check degrees of freedom calculation for results for common factor models with lavaan
  • How should nonlinear terms be handled? Does including nonlinear terms affect the degrees of freedom calculation (other than that the number of dfs is diminished by one, since one more structural parameter has to be estimated).?
@M-E-Rademaker M-E-Rademaker added question Further information is requested Review existing code Issues related to reviewing existing code labels Feb 21, 2020
@M-E-Rademaker M-E-Rademaker added this to the For version 0.2.0 milestone Feb 21, 2020
@M-E-Rademaker M-E-Rademaker added this to To do in cSEM via automation Feb 21, 2020
@M-E-Rademaker
Copy link
Collaborator Author

Comparison to lavaan is ok:

require(cSEM)
require(lavaan)
require(cSEM.DGP)

model_linear <- "
# Structural model
eta2 ~ eta1
eta3 ~ eta1 + eta2

# (Reflective) measurement model
eta1 =~ y11 + y12 + y13
eta2 =~ y21 + y22 + y23
eta3 =~ y31 + y32 + y33
"

dgp_linear_2 <- '
# Measurement model
A =~ 0.8*x11 + 0.8*x12 + 0.7*x13
B =~ 0.7*x21 + 0.8*x22
C =~ 0.7*x31 + 0.9*x32 + 0.7*x33
D =~ 0.9*x41 + 0.8*x42 + 0.8*x43

# Structural model
C ~ 0.1*A + 0.2*B
D ~ 0.3*A + 0.3*C

x11 ~~ 0.3*x12
'

model_linear_2 <- '
# Measurement model
A =~ x11 + x12 + x13
B =~ x21 + x22
C =~ x31 + x32 + x33
D =~ x41 + x42 + x43

# Structural model
C ~ A + B
D ~ A + C

x11 ~~ x12
'

myData <- cSEM.DGP::generateData(.model = dgp_linear_2, 
                                 .return_type = "data.frame",
                                 .empirical = FALSE,
                                 .N = 1000)

model_2nd <- "
# Path model / Regressions 
c4   ~ eta1
eta2 ~ eta1 + c4

# Reflective measurement model
c1   =~ y11 + y12 
c2   =~ y21 + y22 + y23 + y24
c3   =~ y31 + y32 + y33 + y34 + y35 + y36 + y37 + y38
eta1 =~ y41 + y42 + y43
eta2 =~ y51 + y52 + y53

# Composite model (second order)
c4   =~ c1 + c2 + c3
"

sem(model_linear, threecommonfactors) # 24 + 3 construct variances = 27
sem(model_linear_2, myData, auto.fix.first = FALSE, std.lv = TRUE) # 38 + 4 construct variances = 42
sem(model_2nd, dgp_2ndorder_cf_of_c) # 164 + 6 construct variances = 170

calculateDf(csem(threecommonfactors, model_linear))
calculateDf(csem(myData, model_linear_2))
calculateDf(csem(dgp_2ndorder_cf_of_c, model_2nd))

cSEM automation moved this from To do to Done Feb 24, 2020
M-E-Rademaker added a commit that referenced this issue Feb 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Review existing code Issues related to reviewing existing code
Projects
cSEM
  
Done
Development

No branches or pull requests

1 participant