Using FIML with Sample.weights in Lavaan with fixed .X = F

60 Views Asked by At

I am hoping that someone can help me understand why I can not fit the model when I set FIML to impute my X and Y variables (as would occur in the joint model specification in MICE) .

I have a data set with multiple variables that have NA on them. I previously used Lavaan.Survey to do this with MI, but it was removed from CRAN and is not supported for the new version of R. The approach I used to take was:

# NON IMPUTED
dat <- svydesign(ids = ~pidp, weights =~indbdub_xw, data = usoc)
# IMPUTED
impdat <- svydesign(ids = ~pidp, weights =~indbdub_xw, data = impd)

um1a <- '
  lcrp ~ famc+famv+frdc+nsize+sogrp+hsize+spouse+
  age+sex # AGE & SEX ADJUSTMENTS
'

m1a <- sem(model = um1a, data = usoc, estimator = "MLR")
summary(m1a,standardized=T,fit.measures=T, ci = TRUE)
# WEIGHTED
m1a_w <- lavaan.survey(m1a, dat)
summary(m1a_w,standardized=T,fit.measures=T,rsquare=T, ci = TRUE)
# IMPUTED (N=13258)
m1a_wi <- lavaan.survey(m1a, impdat)
summary(m1a_wi,standardized=T,fit.measures=T,rsquare=T, ci = TRUE)

However, now that Lavaan supports weights, I am looking to do similar here. for the 1) unimputed and unweighted model its fine (of course) as I'm not using any calls outside of the base SEM

um1a <- '
  lcrp ~ famc+famv+frdc+nsize+sogrp+hsize+spouse+
  age+sex # AGE & SEX ADJUSTMENTS
'

m1a <- sem(model = um1a, 
           data = usoc, 
           estimator = "MLR")
summary(m1a,standardized=T,fit.measures=T, ci = TRUE)

The weighted model works fine too

um1a <- '
  lcrp ~ famc+famv+frdc+nsize+sogrp+hsize+spouse+
  age+sex # AGE & SEX ADJUSTMENTS
'

m1a_w <- sem(model = um1a, 
           data = usoc, 
           sampling.weights = "indbdub_xw",
           estimator = "MLR")
summary(m1a_w,standardized=T,fit.measures=T, ci = TRUE)

As does the weighted and FIML model with fixed.X = TRUE

um1a <- '
  lcrp ~ famc+famv+frdc+nsize+sogrp+hsize+spouse+
  age+sex # AGE & SEX ADJUSTMENTS
'

m1a_wi <- sem(model = um1a, 
              data = usoc, 
              sampling.weights = "indbdub_xw",
              missing = "fiml",
              estimator = "MLR")
summary(m1a_wi,standardized=T,fit.measures=T, ci = TRUE)

with the following expected warning: "Warning message: In lav_data_full(data = data, group = group, cluster = cluster, : lavaan WARNING: 8176 cases were deleted due to missing values in exogenous variable(s), while fixed.x = TRUE."

However, if I try to specify fully imputing my data, using fixed.x = FALSE:

m1a_wi <- sem(model = um1a, 
             data = usoc, 
             sampling.weights = "indbdub_xw",
             missing = "fiml",
             fixed.x = FALSE,
             estimator = "MLR")

I get: "Error in stats::cov.wt(RAW, wt = wt[Mp$case.idx[[p]]], method = "ML") : weights must be non-negative and not all zero In addition: Warning message: In lav_data_full(data = data, group = group, cluster = cluster, : lavaan WARNING: some observed variances are (at least) a factor 1000 times larger than others; use varTable(fit) to investigate"

I looked at the weights and none are below 0 or are they all 0

 describe(usoc$indbdub_xw)
   vars     n mean   sd median trimmed  mad min  max range skew kurtosis   se
X1    1 13258  0.9 0.68   0.78    0.83 0.34   0 5.38  5.38 2.48     10.7 0.01

Any advice or guidance as to how to counteract this error would be appreciated. is there anyway to specify which variables are not considered in the FIML calculation? would excluding the weights fix this error?

Kind regards,

Steven

0

There are 0 best solutions below