Convergence Issues using FIML

809 views
Skip to first unread message

Alysha Ramirez

unread,
Sep 9, 2014, 1:47:22 PM9/9/14
to lav...@googlegroups.com
I am trying to impute a data set that utilized planned missingness. The syntax is below:

fit.fiml = cfa(Test2.model, data=W12, estimator = "ML", missing = "FIML", control=list(rel.tol=1e-8, iter.max=1000), verbose=TRUE)
fit.aux <- auxiliary(fit.fiml, aux = auxvars, data = W12, estimator = "ML", missing = "FIML", fun= "cfa",  control=list(rel.tol=1e-8, iter.max=1000), verbose=TRUE)

I am new to R and firstly would like to know if this is the correct syntax for adding auxiliary variables.


When this runs I get the following errors:

Error in validObject(.Object) : 
  invalid class “Fit” object: invalid object for slot "fx.group" in class "Fit": got class "NULL", should be or extend class "numeric"
In addition: Warning messages:
1: In lav_data_full(data = data, group = group, group.label = group.label,  :
  lavaan WARNING: some cases are empty and will be removed:
  2 73 106
2: In lav_data_full(data = data, group = group, group.label = group.label,  :
  lavaan WARNING: due to missing values, some pairwise combinations have less than 10% coverage
3: In lavaan::lavaan(model = list(id = 1:589, lhs = c("OA", "OA", "OA",  :
  lavaan WARNING: model has NOT converged!

Any advice would be helpful. Thanks!

Sunthud Pornprasertmanit

unread,
Sep 9, 2014, 3:48:42 PM9/9/14
to lav...@googlegroups.com
Could you please show your lavaan script? I would be really hard to know the problems without the script.

Further, which function did you have this problem: cfa or auxiliary?

--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at http://groups.google.com/group/lavaan.
For more options, visit https://groups.google.com/d/optout.

Alysha Ramirez

unread,
Sep 9, 2014, 4:17:01 PM9/9/14
to lav...@googlegroups.com
I wrote the syntax based on this post https://groups.google.com/forum/#!searchin/lavaan/fiml/lavaan/CEbasmWCKQs/_ZcuJJxkb1UJ

And the error occurred with the auxiliary. 

Sunthud Pornprasertmanit

unread,
Sep 9, 2014, 5:58:48 PM9/9/14
to lav...@googlegroups.com
I am not sure which versions of lavaan and semTools you are using. Let's update both packages to the latest versions:

install.packages("lavaan", repos="http://www.da.ugent.be", type="source")
install.packages("semTools", repos="http://rweb.quant.ku.edu/kran", type="source")

I have modified the code as follows:

############### Script for data generation and impose missing data
library(boot) # need for the inv.logit function
library(semTools)
set.seed(1234)
x <- rnorm(200, 0, 1)
y <- 0.5*x + rnorm(200, 0, sqrt(0.75))
a <- 0.4*x + 0.4*y + rnorm(200, 0, 1)
pmiss <- inv.logit(-0.9 + 0.7*a)
miss <- runif(200) > (1 - pmiss)
y[miss] <- NA
dat <- data.frame(x = x, y = y, a = a)

################ The analysis part
model1 <- 'y ~ x' # target regression model
fit.fiml <- sem(model1, dat, estimator="ML", missing="FIML", fixed.x = FALSE) # if you have exogenous variable, it is needed to treat as fixed to use the auxiliary function
fit.aux <- sem.auxiliary(fit.fiml, aux = "a", data=dat, missing="FIML")
summary(fit.aux)


Alysha Ramirez

unread,
Sep 10, 2014, 12:09:41 PM9/10/14
to lav...@googlegroups.com
After updating both packages I ran the following and received the following errors:

> fit.fiml <- cfa(Test2.model, W12, estimator="ML", missing="FIML", fixed.x = FALSE) # if you have exogenous variable, it is needed to treat as fixed to use the auxiliary function
Warning messages:
1: In lav_data_full(data = data, group = group, group.label = group.label,  :
  lavaan WARNING: some cases are empty and will be removed:
  2 18 73 87 106
2: In lav_data_full(data = data, group = group, group.label = group.label,  :
  lavaan WARNING: due to missing values, some pairwise combinations have less than 10% coverage
3: In lavaan::lavaan(model = Test2.model, data = W12, fixed.x = FALSE,  :
  lavaan WARNING: model has NOT converged!
> fit.aux <- cfa.auxiliary(fit.fiml, aux = "auxvars", data=W12, missing="FIML")
Error in lav_data_full(data = data, group = group, group.label = group.label,  : 
  lavaan ERROR: missing observed variables in dataset: auxvars
> summary(fit.aux)
Error in summary(fit.aux) : 
  error in evaluating the argument 'object' in selecting a method for function 'summary': Error: object 'fit.aux' not found

Fixing the convergence in the first analyses is the main issue.

Sunthud Pornprasertmanit

unread,
Sep 10, 2014, 12:41:45 PM9/10/14
to lav...@googlegroups.com
1. Your lavaan model is not convergent. I am not sure which model you are using. I also do not know about the characteristics of your data.
2. The "auxvars" variable is not in your data set. You need to put the name of auxiliary variables from your data set.

Terrence Jorgensen

unread,
Sep 11, 2014, 11:19:23 AM9/11/14
to lav...@googlegroups.com


2. The "auxvars" variable is not in your data set. You need to put the name of auxiliary variables from your data set.


If you saved the character strings of all your auxiliary variables in vector object named "auxvars", then you don't put quotations around the object name when you call it:

auxvars <- c("auxvar1", "auxvar2", "auxvar3")

fit.aux <- cfa.auxiliary(fit.fiml, aux = auxvars, data = W12, missing = "FIML")


Terry
Reply all
Reply to author
Forward
0 new messages