This helper function provides a simple way to retrieve the
lavaan model syntax from a fitted dpm()
object.
get_syntax(model, print = TRUE)
A dpm
object.
Print the syntax to the console so it is formatted properly? Default is TRUE.
Returns a string with the lavaan model syntax for model
. If print
is
TRUE, it is printed to the console as well.
data("WageData", package = "panelr")
wages <- panel_data(WageData, id = id, wave = t)
fit <- dpm(wks ~ pre(lag(union)) + lag(lwage), data = wages)
get_syntax(fit)
#> ## Main regressions
#>
#> wks_2 ~ en1 * union_1 + ex1 * lwage_1 + p1 * wks_1
#> wks_3 ~ en1 * union_2 + ex1 * lwage_2 + p1 * wks_2
#> wks_4 ~ en1 * union_3 + ex1 * lwage_3 + p1 * wks_3
#> wks_5 ~ en1 * union_4 + ex1 * lwage_4 + p1 * wks_4
#> wks_6 ~ en1 * union_5 + ex1 * lwage_5 + p1 * wks_5
#> wks_7 ~ en1 * union_6 + ex1 * lwage_6 + p1 * wks_6
#>
#> ## Alpha latent variable (random intercept)
#>
#> alpha =~ 1 * wks_2 + 1 * wks_3 + 1 * wks_4 + 1 * wks_5 + 1 * wks_6 + 1 * wks_7
#>
#> ## Alpha free to covary with observed variables (fixed effects)
#>
#> alpha ~~ union_1 + union_2 + union_3 + union_4 + union_5 + union_6 + lwage_1 + lwage_2 + lwage_3 + lwage_4 + lwage_5 + lwage_6 + wks_1
#>
#> ## Correlating DV errors with future values of predetermined predictors
#>
#> wks_5 ~~ union_6
#> wks_4 ~~ union_5 + union_6
#> wks_3 ~~ union_4 + union_5 + union_6
#> wks_2 ~~ union_3 + union_4 + union_5 + union_6
#>
#> ## Predetermined predictors covariances
#>
#> union_1 ~~ lwage_1 + lwage_2 + lwage_3 + lwage_4 + lwage_5 + lwage_6 + wks_1
#> union_2 ~~ lwage_1 + lwage_2 + lwage_3 + lwage_4 + lwage_5 + lwage_6 + union_1 + wks_1
#> union_3 ~~ lwage_1 + lwage_2 + lwage_3 + lwage_4 + lwage_5 + lwage_6 + union_1 + union_2 + wks_1
#> union_4 ~~ lwage_1 + lwage_2 + lwage_3 + lwage_4 + lwage_5 + lwage_6 + union_1 + union_2 + union_3 + wks_1
#> union_5 ~~ lwage_1 + lwage_2 + lwage_3 + lwage_4 + lwage_5 + lwage_6 + union_1 + union_2 + union_3 + union_4 + wks_1
#> union_6 ~~ lwage_1 + lwage_2 + lwage_3 + lwage_4 + lwage_5 + lwage_6 + union_1 + union_2 + union_3 + union_4 + union_5 + wks_1
#>
#> ## Exogenous (time varying and invariant) predictors covariances
#>
#> lwage_1 ~~ wks_1
#> lwage_2 ~~ lwage_1 + wks_1
#> lwage_3 ~~ lwage_1 + lwage_2 + wks_1
#> lwage_4 ~~ lwage_1 + lwage_2 + lwage_3 + wks_1
#> lwage_5 ~~ lwage_1 + lwage_2 + lwage_3 + lwage_4 + wks_1
#> lwage_6 ~~ lwage_1 + lwage_2 + lwage_3 + lwage_4 + lwage_5 + wks_1
#>
#> ## DV error variance free to vary across waves
#>
#> wks_2 ~~ wks_2
#> wks_3 ~~ wks_3
#> wks_4 ~~ wks_4
#> wks_5 ~~ wks_5
#> wks_6 ~~ wks_6
#> wks_7 ~~ wks_7
#>
#> ## Let DV variance vary across waves
#>
#> wks_2 ~ 1
#> wks_3 ~ 1
#> wks_4 ~ 1
#> wks_5 ~ 1
#> wks_6 ~ 1
#> wks_7 ~ 1