ecmerkle/blavaan

blavaan NOTE: two-level models are new, please report bugs!

Ramos-Chernenko opened this issue · 4 comments

I am trying to impute my survey design to the sem I have modelled using blavaan.

Specifically, I am trying to accout for the clusters I have in my design. So my survey design is the following. I have sampled 8 cities. In each city I have chosen 10 squares. The strata is the type of urban development: LSH or LSP. Thus, in each city I have 5 LSH squares and 5 LSP squares. Therefore, I have set the cluster argument in the bsem function like that:

When I run this code: blavaan.fit<- bsem(model=data, cluster = ~city + square.code)

But then R is returning me this error:

blavaan NOTE: two-level models are new, please report bugs!
https://github.com/ecmerkle/blavaan/issues

Error en match(x, table, nomatch = 0L):
'match' requiere argumentos vectoriales

If someone has some valuable input to give, I would appreciate it highly

cluster = ~city + square.code

It looks like you are trying to use syntax that would be employed in the survey package, but that is not legal syntax in (b)lavaan. There is no support for strata in (b)lavaan. There was a lavaan.survey package on CRAN that interfaced between survey and lavaan, but it was orphaned as most of its functionality was eventually implemented in lavaan(cluster=, sampling.weights=). You can still download a source package from the CRAN archive, if you want to use the stratum= argument in a frequentist framework.

Hi, thanks very much for the very informative answer.

Only to check I have understood properly, the stratum= argument you mentioned, it is only available in the lavaan.survey package, right?

It's available in the survey package, which lavaan.survey can utilize to pass summary stats as input data to lavaan.

Thanks very much once more! Kind regards, Anna