Using sample weights in lavaan

1,861 views
Skip to first unread message

alexander....@gmail.com

unread,
Jun 1, 2018, 4:33:12 AM6/1/18
to lavaan
Hi lavaan-users group,

I read at lavaan.org that sample weights can now be used in lavaan, but I did not find an example (or argument) on how to do this. Are there any hints about it?

Thank you and best regards,
Alexander

Yves Rosseel

unread,
Jun 1, 2018, 6:25:37 AM6/1/18
to lav...@googlegroups.com
On 06/01/2018 10:33 AM, alexander....@gmail.com wrote:
> Hi lavaan-users group,
>
> I read at lavaan.org that sample weights can now be used in lavaan, but
> I did not find an example (or argument) on how to do this. Are there any
> hints about it?

The argument is 'sampling.weights'. Below is a small (artificial) example.

Yves.



library(lavaan)

# generate data
set.seed(1234)
pop.model <- '
f =~ x1 + x2 + x3 + x4 + x5
'
Data <- simulateData(pop.model, sample.nobs = 1000)

# add sampling weights
N <- nrow(Data)
wt <- abs(rnorm(N, mean = 1, sd = 2)); wt <- wt/sum(wt)*N
Data$wt <- wt

model <- '
f =~ x1 + x2 + x3 + x4 + x5
'

fit <- sem(model, data = Data, sampling.weights = "wt", estimator = "ML")
summary(fit)


alexander....@gmail.com

unread,
Jun 1, 2018, 7:33:52 AM6/1/18
to lavaan
Thank you!

Reply all
Reply to author
Forward
0 new messages