How to specify latent variables for SEM with lavaan I would like to use lavaan for SEM. Specifically I want to use the paper: "Original Article Maximum Likelihood for Cross-lagged Panel Models with Fixed Effects", by Paul D. Allison, Richard Williams, and Enrique Moral-Benito. I am have however struggling to get things running (I went through al the examples, but they always deal with these perfect datasets).
I have a quite large two period panel data set. The data consists of many survey questions (ordinal and categorical), some numerical data, and, not unimportantly, it has a lot of scattered NA's.
When I play around with the latent variables I mostly get the error:
Warning message:
In lav_model_vcov(lavmodel = lavmodel2, lavsamplestats = lavsamplestats,  :
  lavaan WARNING:
    Could not compute standard errors! The information matrix could
    not be inverted. This may be a symptom that the model is not
    identified.


*

*If I add more latent variables and regressions, does that mean I further restrict the outcomes? In other words, do I make it generally easier on the estimation?

*Am I allowed to put a simple lags, say y_1 =~ x_2, as latent variables, or do I then have to put them as a regression? What is exactly the difference?

*In a SEM example, the model is specified as follows:
model <- '
  # measurement model
    ind60 =~ x1 + x2 + x3
    dem60 =~ y1 + y2 + y3 + y4
    dem65 =~ y5 + y6 + y7 + y8
  # regressions
    dem60 ~ ind60
    dem65 ~ ind60 + dem60
  # residual correlations
    y1 ~~ y5
    y2 ~~ y4 + y6
    y3 ~~ y7
    y4 ~~ y8
    y6 ~~ y8
'
In the paper I mention, they are however sometimes specified with letters in front of them:
wks2 ~ a*wks1 + b*union1 + c*lwage1 + d*ed1
Is this purely to restrict the coefficients? In other words, are all coefficients allowed to be free in the SEM example?
 A: 

*

*If I add more latent variables and regressions, does that mean I further restrict the outcomes? In other words, do I make it generally easier on the estimation?


For the same number of observed variables, adding regression relationships or latent variables can either improve or worsen the performance of the estimation. Any variables that don't have a regression or correlation relation between them are assumed to have a correlation of 0 (conditional on the rest of the model). If that assumption is realistic, then not including a regression or correlation will improve estimation, and including a regression or correlation will add another parameter to be estimated, which can either makes things just slightly worse or lead to the complete unidentifiability of the model. You need to read about model identification before performing SEM. It is a vital concept that is often overlooked. If your model is not identified, you will likely get an error like the one you got.



*Am I allowed to put a simple lags, say y_1 =~ x_2, as latent variables, or do I then have to put them as a regression? What is exactly the difference?


The left side of the =~ must be a latent variable, one you do not have in your dataset. You can have latent variables measured by other latent variables without any problem. You can also regress a latent variable on another latent variable. When y is latent and regardless of whether x is, y =~ x means the same thing as x ~ y. How lavaan treats them might be different, though; lavaan might report the slope as a loading in the form and as a slope in the latter. It's best to use the symbol that most accurately reflects your intentions (i.e., is x a measurement of y or just a consequence of y?).

In the paper I mention, they are however sometimes specified with letters in front of them: wks2 ~ a*wks1 + b*union1 + c*lwage1 + d*ed1
Is this purely to restrict the coefficients? In other words, are all coefficients allowed to be free in the SEM example?

Putting those labels before the variables just labels the coefficients. You would want to do this not only if you wanted to constrain coefficients to have the same value but also if you wanted to define other coefficients that are functions of them. For example, in mediation, the indirect effect is the product of two coefficients, so you might write the following for your model:
m ~ a*x
y ~ b*m + c*x
ind := a*b
tot := ind+c

Doing so allows you to test for the indirect (ind) and total (tot) effects in the mediation model. Labeling the coefficients allows you to reference them later. This is explained in the lavaan documentation.
