# Note: These examples can't be run via example() because the default file
# argument of specifyModel() requires that the model specification be entered
# at the command prompt. The examples can be copied and run in the R console,
# however.
model.dhp <- specifyModel()
RParAsp -> RGenAsp, gam11, NA
RIQ -> RGenAsp, gam12, NA
RSES -> RGenAsp, gam13, NA
FSES -> RGenAsp, gam14, NA
RSES -> FGenAsp, gam23, NA
FSES -> FGenAsp, gam24, NA
FIQ -> FGenAsp, gam25, NA
FParAsp -> FGenAsp, gam26, NA
FGenAsp -> RGenAsp, beta12, NA
RGenAsp -> FGenAsp, beta21, NA
RGenAsp -> ROccAsp, NA, 1
RGenAsp -> REdAsp, lam21, NA
FGenAsp -> FOccAsp, NA, 1
FGenAsp -> FEdAsp, lam42, NA
RGenAsp <-> RGenAsp, ps11, NA
FGenAsp <-> FGenAsp, ps22, NA
RGenAsp <-> FGenAsp, ps12, NA
ROccAsp <-> ROccAsp, theta1, NA
REdAsp <-> REdAsp, theta2, NA
FOccAsp <-> FOccAsp, theta3, NA
FEdAsp <-> FEdAsp, theta4, NA
model.dhp
# an equivalent specification, allowing specifyModel() to generate
# variance parameters for endogenous variables (and suppressing
# the unnecessary trailing NAs):
model.dhp <- specifyModel()
RParAsp -> RGenAsp, gam11
RIQ -> RGenAsp, gam12
RSES -> RGenAsp, gam13
FSES -> RGenAsp, gam14
RSES -> FGenAsp, gam23
FSES -> FGenAsp, gam24
FIQ -> FGenAsp, gam25
FParAsp -> FGenAsp, gam26
FGenAsp -> RGenAsp, beta12
RGenAsp -> FGenAsp, beta21
RGenAsp -> ROccAsp, NA, 1
RGenAsp -> REdAsp, lam21
FGenAsp -> FOccAsp, NA, 1
FGenAsp -> FEdAsp, lam42
RGenAsp <-> FGenAsp, ps12
model.dhp
# Another equivalent specification, telling specifyModel to add paths for
# variances and covariance of RGenAsp and FGenAsp:
model.dhp <- specifyModel(covs="RGenAsp, FGenAsp")
RParAsp -> RGenAsp, gam11
RIQ -> RGenAsp, gam12
RSES -> RGenAsp, gam13
FSES -> RGenAsp, gam14
RSES -> FGenAsp, gam23
FSES -> FGenAsp, gam24
FIQ -> FGenAsp, gam25
FParAsp -> FGenAsp, gam26
FGenAsp -> RGenAsp, beta12
RGenAsp -> FGenAsp, beta21
RGenAsp -> ROccAsp, NA, 1
RGenAsp -> REdAsp, lam21
FGenAsp -> FOccAsp, NA, 1
FGenAsp -> FEdAsp, lam42
model.dhp
# The same model in equation format:
model.dhp.1 <- specifyEquations(covs="RGenAsp, FGenAsp")
RGenAsp = gam11*RParAsp + gam12*RIQ + gam13*RSES + gam14*FSES + beta12*FGenAsp
FGenAsp = gam23*RSES + gam24*FSES + gam25*FIQ + gam26*FParAsp + beta21*RGenAsp
ROccAsp = 1*RGenAsp
REdAsp = lam21(1)*RGenAsp # to illustrate setting start values
FOccAsp = 1*FGenAsp
FEdAsp = lam42(1)*FGenAsp
model.dhp
classifyVariables(model.dhp)
# updating the model to impose equality constraints
# and to rename the latent variables and gamma parameters
model.dhp.eq <- update(model.dhp)
delete, RSES -> FGenAsp
delete, FSES -> FGenAsp
delete, FIQ -> FGenAsp
delete, FParAsp -> FGenAs
delete, RGenAsp -> FGenAsp
add, RSES -> FGenAsp, gam14, NA
add, FSES -> FGenAsp, gam13, NA
add, FIQ -> FGenAsp, gam12, NA
add, FParAsp -> FGenAsp, gam26, NA
add, RGenAsp -> FGenAsp, beta12, NA
replace, gam, gamma
replace, Gen, General
model.dhp.eq
Run the code above in your browser using DataLab